BooleanAttribute extends AbstractIndexableAttribute { @Override public int getValueIndex(Object value) { if (value instanceof Boolean) { return values.indexOf((boolean)value); } else if (value instanceof String) { boolean boolValue = Boolean.valueOf((String)value); return values.indexOf(boolValue); } else { return -1; } } BooleanAttribute(String key, AttributeLevel level); @Override int registerXAttribute(XAttribute att); @Override ImmutableList<Object> getValues(); @Override int getValueIndex(Object value); @Override Object getValue(int index); @Override int getValueSize();  }
@Test public void testGetValueIndex() { BooleanAttribute att = this.newWithTwoValues("concept:name", AttributeLevel.EVENT); Assert.assertEquals(att.getValueIndex(true), 0); Assert.assertEquals(att.getValueIndex(false), 1); BooleanAttribute att2 = this.newWithInvalidKeyAttribute("concept:name", AttributeLevel.EVENT); Object result2 = att2.getValueIndex(true); Assert.assertEquals(-1, result2); BooleanAttribute att3 = this.newEmptyAttribute("concept:name", AttributeLevel.EVENT); Object result3 = att3.getValueIndex(true); Assert.assertEquals(-1, result3); }