Class SingleEntityTypeGenerator
- java.lang.Object
-
- de.hybris.platform.odata2services.odata.schema.entity.SingleEntityTypeGenerator
-
- All Implemented Interfaces:
EntityTypeGenerator,SchemaElementGenerator<java.util.List<org.apache.olingo.odata2.api.edm.provider.EntityType>,IntegrationObjectItemModel>
- Direct Known Subclasses:
ComposedEntityTypeGenerator,LocalizedEntityTypeGenerator
public abstract class SingleEntityTypeGenerator extends java.lang.Object implements EntityTypeGenerator
Base implementation class for entity type generators, which generate either a single entity type or no entity types depending on certain conditions.
-
-
Constructor Summary
Constructors Constructor Description SingleEntityTypeGenerator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.List<org.apache.olingo.odata2.api.edm.provider.EntityType>generate(IntegrationObjectItemModel item)Generates the schema element whose type is defined by T.protected org.apache.olingo.odata2.api.edm.provider.EntityTypegenerateEntityType(IntegrationObjectItemModel item)Generates a single entity type for the specified item delegating the entity parts creation to:generateEntityTypeName(IntegrationObjectItemModel)for the entity type name generationpropertiesGeneratorfor the entity type properties generationkeyGeneratorfor the entity type key generation.protected abstract java.lang.StringgenerateEntityTypeName(IntegrationObjectItemModel item)Generates name for the entity type being generated.protected org.apache.olingo.odata2.api.edm.provider.KeygenerateKey(java.lang.String name, java.util.List<org.apache.olingo.odata2.api.edm.provider.Property> properties)protected KeyGeneratorgetKeyGenerator()protected AbstractPropertyListGeneratorgetPropertiesGenerator()protected abstract booleanisApplicable(IntegrationObjectItemModel item)Determines whether this generator is applicable to the specified item and can generate at least a single EDMX entity type.voidsetKeyGenerator(KeyGenerator generator)voidsetPropertiesGenerator(AbstractPropertyListGenerator generator)
-
-
-
Method Detail
-
generate
public java.util.List<org.apache.olingo.odata2.api.edm.provider.EntityType> generate(IntegrationObjectItemModel item)
Generates the schema element whose type is defined by T. Implementation checks whether this generator is applicable to the specified item by callingisApplicable(IntegrationObjectItemModel)and depending on the result proceeds togenerateEntityType(IntegrationObjectItemModel)or returns an empty list.- Specified by:
generatein interfaceSchemaElementGenerator<java.util.List<org.apache.olingo.odata2.api.edm.provider.EntityType>,IntegrationObjectItemModel>- Parameters:
item- an item, for which an EDMX entity type has to be generated- Returns:
- a list with a single generated entity type or an empty list, if this generator is not
isApplicable().
-
isApplicable
protected abstract boolean isApplicable(IntegrationObjectItemModel item)
Determines whether this generator is applicable to the specified item and can generate at least a single EDMX entity type.- Parameters:
item- an item, based on which the decision has to be made.- Returns:
true, if at least one entity type can be generated for the given item;false, otherwise.
-
generateEntityType
protected org.apache.olingo.odata2.api.edm.provider.EntityType generateEntityType(IntegrationObjectItemModel item)
Generates a single entity type for the specified item delegating the entity parts creation to:generateEntityTypeName(IntegrationObjectItemModel) for the entity type name generation
propertiesGenerator for the entity type properties generation
keyGenerator for the entity type key generation. If the key is not generated, i.e.
!Optional<Key>.isPresent(), anIllegalStateExceptionis thrown.- Parameters:
item- an item to generate the EDMX entity type for.- Returns:
- the generated entity type.
Subclasses make sure never returnnullfrom this method. If item cannot be generated, thenisApplicable(IntegrationObjectItemModel)should returnfalseinstead.
-
generateKey
protected org.apache.olingo.odata2.api.edm.provider.Key generateKey(java.lang.String name, java.util.List<org.apache.olingo.odata2.api.edm.provider.Property> properties)
-
generateEntityTypeName
protected abstract java.lang.String generateEntityTypeName(IntegrationObjectItemModel item)
Generates name for the entity type being generated.- Parameters:
item- item, for which entity type is being generated.- Returns:
- a valid EDMX entity type name.
-
setPropertiesGenerator
public void setPropertiesGenerator(AbstractPropertyListGenerator generator)
-
setKeyGenerator
public void setKeyGenerator(KeyGenerator generator)
-
getPropertiesGenerator
protected AbstractPropertyListGenerator getPropertiesGenerator()
-
getKeyGenerator
protected KeyGenerator getKeyGenerator()
-
-