class OCompositeIndexDefinition extends ODocumentWrapperNoClass implements OIndexDefinition {

  public Object createValue(final List<?> params) {
    int currentParamIndex = 0;
    final OCompositeKey firstKey = new OCompositeKey();

    final List<OCompositeKey> compositeKeys = new ArrayList<OCompositeKey>(10);
    compositeKeys.add(firstKey);

    boolean containsCollection = false;

    for (final OIndexDefinition indexDefinition : indexDefinitions) {
      if (currentParamIndex + 1 > params.size())
        break;

      final int endIndex;
      if (currentParamIndex + indexDefinition.getParamCount() > params.size())
        endIndex = params.size();
      else
        endIndex = currentParamIndex + indexDefinition.getParamCount();

      final List<?> indexParams = params.subList(currentParamIndex, endIndex);
      currentParamIndex += indexDefinition.getParamCount();

      final Object keyValue = indexDefinition.createValue(indexParams);

      if (keyValue == null)
        return null;

      containsCollection = addKey(firstKey, compositeKeys, containsCollection, keyValue);
    }

    if (!containsCollection)
      return firstKey;

    return compositeKeys;
  }

  public  OCompositeIndexDefinition();
  public  OCompositeIndexDefinition(final String iClassName);
  public  OCompositeIndexDefinition(final String iClassName, final List<? extends OIndexDefinition> iIndexes);

}