class ComponentEntityAdapter extends MetadataNodeEntityAdapter<Component> {

  @Override
  protected void defineType(final ODatabaseDocumentTx db, final OClass type) {
    super.defineType(type);
    type.createProperty(P_GROUP, OType.STRING);
    type.createProperty(P_NAME, OType.STRING)
        .setMandatory(true)
        .setNotNull(true);
    type.createProperty(P_VERSION, OType.STRING);
    type.createProperty(P_CI_NAME, OType.STRING)
        .setCollate(new OCaseInsensitiveCollate())
        .setMandatory(true)
        .setNotNull(true);

    ODocument metadata = db.newInstance()
        .field("ignoreNullValues", false)
        .field("mergeKeys", false);
    type.createIndex(I_BUCKET_GROUP_NAME_VERSION, INDEX_TYPE.UNIQUE.name(), null, metadata,
        new String[]{P_BUCKET, P_GROUP, P_NAME, P_VERSION});
    type.createIndex(I_BUCKET_NAME_VERSION, INDEX_TYPE.NOTUNIQUE.name(), null, metadata,
        new String[]{P_BUCKET, P_NAME, P_VERSION});

    new OIndexBuilder(type, I_GROUP_NAME_VERSION_INSENSITIVE, INDEX_TYPE.NOTUNIQUE)
        .property(P_GROUP, OType.STRING)
        .property(P_NAME, OType.STRING)
        .property(P_VERSION, OType.STRING)
        .caseInsensitive()
        .build(db);

    new OIndexBuilder(type, I_CI_NAME_CASE_INSENSITIVE, INDEX_TYPE.NOTUNIQUE)
        .property(P_CI_NAME, OType.STRING)
        .caseInsensitive()
        .build(db);

    componentEntityAdapterExtensions.forEach(d -> d.defineType(db, type));
  }

  @Inject public  ComponentEntityAdapter(final BucketEntityAdapter bucketEntityAdapter,
                                final ComponentFactory componentFactory,
                                final Set<ComponentEntityAdapterExtension> componentEntityAdapterExtensions);

}