OCompositeIndexDefinition extends ODocumentWrapperNoClass implements OIndexDefinition { public Object getDocumentValueToIndex(final ODocument iDocument) { final List<OCompositeKey> compositeKeys = new ArrayList<OCompositeKey>(10); final OCompositeKey firstKey = new OCompositeKey(); boolean containsCollection = false; compositeKeys.add(firstKey); for (final OIndexDefinition indexDefinition : indexDefinitions) { final Object result = indexDefinition.getDocumentValueToIndex(iDocument); if (result == null) return null; containsCollection = addKey(firstKey, compositeKeys, containsCollection, result); } if (!containsCollection) return firstKey; return compositeKeys; } OCompositeIndexDefinition();  OCompositeIndexDefinition(final String iClassName);  OCompositeIndexDefinition(final String iClassName, final List<? extends OIndexDefinition> iIndexes); String getClassName(); void addIndex(final OIndexDefinition indexDefinition); List<String> getFields(); List<String> getFieldsToIndex(); Object getDocumentValueToIndex(final ODocument iDocument); int getMultiValueDefinitionIndex(); String getMultiValueField(); Object createValue(final List<?> params); OIndexDefinitionMultiValue getMultiValueDefinition(); OCompositeKey createSingleValue(final List<?> params); Object createValue(final Object... params); void processChangeEvent(OMultiValueChangeEvent<?, ?> changeEvent, Map<OCompositeKey, Integer> keysToAdd,
      Map<OCompositeKey, Integer> keysToRemove, Object... params); int getParamCount(); OType[] getTypes(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); @Override ODocument toStream(); String toCreateIndexDDL(final String indexName, final String indexType);  }
@Test public void testDocumentToIndexSuccessful() { final ODocument document = new ODocument(); document.field("fOne", 12); document.field("fTwo", "test"); final Object result = compositeIndex.getDocumentValueToIndex(document); Assert.assertEquals(result, new OCompositeKey(Arrays.asList(12, "test"))); }
@Test public void testDocumentToIndexWrongField() { final ODocument document = new ODocument(); document.field("fOne", "1t2"); document.field("fTwo", "test"); final Object result = compositeIndex.getDocumentValueToIndex(document); Assert.assertNull(result); }