public void updateByModeBits(Mode.Bits bits) {
    // Each index equals to corresponding AclAction's ordinal.
    // E.g. Mode.Bits.READ corresponds to AclAction.READ, the former has index 0 in indexedBits,
    // the later has ordinal 0 in AclAction.
    Mode.Bits[] indexedBits = new Mode.Bits[]{
        Mode.Bits.READ, Mode.Bits.WRITE, Mode.Bits.EXECUTE
    };
    for (int i = 0; i < 3; i++) {
      if (bits.imply(indexedBits[i])) {
        mActions.set(i);
      } else {
        mActions.clear(i);
      }
    }
  }
@Test
  public void updateByModeBits() {
    AclActions actions = new AclActions();
    actions.updateByModeBits(Mode.Bits.NONE);
    assertEquals(Mode.Bits.NONE, actions.toModeBits());

    actions = new AclActions();
    actions.updateByModeBits(Mode.Bits.READ);
    assertEquals(Mode.Bits.READ, actions.toModeBits());

    actions = new AclActions();
    actions.updateByModeBits(Mode.Bits.WRITE);
    assertEquals(Mode.Bits.WRITE, actions.toModeBits());

    actions = new AclActions();
    actions.updateByModeBits(Mode.Bits.EXECUTE);
    assertEquals(Mode.Bits.EXECUTE, actions.toModeBits());

    actions = new AclActions();
    actions.updateByModeBits(Mode.Bits.READ_WRITE);
    assertEquals(Mode.Bits.READ_WRITE, actions.toModeBits());

    actions = new AclActions();
    actions.updateByModeBits(Mode.Bits.READ_EXECUTE);
    assertEquals(Mode.Bits.READ_EXECUTE, actions.toModeBits());

    actions = new AclActions();
    actions.updateByModeBits(Mode.Bits.WRITE_EXECUTE);
    assertEquals(Mode.Bits.WRITE_EXECUTE, actions.toModeBits());

    actions = new AclActions();
    actions.updateByModeBits(Mode.Bits.ALL);
    assertEquals(Mode.Bits.ALL, actions.toModeBits());
  }