Class SingleEntityTypeElementGenerator
java.lang.Object
de.hybris.platform.odata2services.odata.schema.entity.SingleEntityTypeElementGenerator
- All Implemented Interfaces:
SchemaElementGenerator<Set<org.apache.olingo.odata2.api.edm.provider.EntityType>,TypeDescriptor>
- Direct Known Subclasses:
ComposedEntityTypeElementGenerator,LocalizedEntityTypeElementGenerator
public abstract class SingleEntityTypeElementGenerator
extends Object
implements SchemaElementGenerator<Set<org.apache.olingo.odata2.api.edm.provider.EntityType>,TypeDescriptor>
Base implementation class for entity type generators, which generate either a single entity type or no entity types depending
on certain conditions.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSingleEntityTypeElementGenerator(@NotNull KeyGenerator keyGenerator, @NotNull SchemaElementGenerator<List<org.apache.olingo.odata2.api.edm.provider.Property>, TypeDescriptor> propertiesGenerator) Instantiates a new single entity type generator. -
Method Summary
Modifier and TypeMethodDescriptionSet<org.apache.olingo.odata2.api.edm.provider.EntityType>generate(@NotNull TypeDescriptor typeDescriptor) Generates the schema element whose type is defined by T.protected org.apache.olingo.odata2.api.edm.provider.EntityTypegenerateEntityType(TypeDescriptor typeDescriptor) Generates a single entity type for the specified item delegating the entity parts creation to:generateEntityTypeName(TypeDescriptor)for the entity type name generationpropertiesGeneratorfor the entity type properties generationkeyGeneratorfor the entity type key generation.protected abstract StringgenerateEntityTypeName(TypeDescriptor typeDescriptor) Generates name for the entity type being generated.protected org.apache.olingo.odata2.api.edm.provider.KeygenerateKey(String name, List<org.apache.olingo.odata2.api.edm.provider.Property> properties) protected abstract booleanisApplicable(TypeDescriptor typeDescriptor) Determines whether this generator is applicable to the specified item and can generate at least a single EDMX entity type.
-
Constructor Details
-
SingleEntityTypeElementGenerator
protected SingleEntityTypeElementGenerator(@NotNull @NotNull KeyGenerator keyGenerator, @NotNull @NotNull SchemaElementGenerator<List<org.apache.olingo.odata2.api.edm.provider.Property>, TypeDescriptor> propertiesGenerator) Instantiates a new single entity type generator.- Parameters:
keyGenerator- a key generatorpropertiesGenerator- a property generator
-
-
Method Details
-
generate
public Set<org.apache.olingo.odata2.api.edm.provider.EntityType> generate(@NotNull @NotNull TypeDescriptor typeDescriptor) Generates the schema element whose type is defined by T. Implementation checks whether this generator is applicable to the specified item by callingisApplicable(TypeDescriptor)and depending on the result proceeds togenerateEntityType(TypeDescriptor)or returns an empty set.- Specified by:
generatein interfaceSchemaElementGenerator<Set<org.apache.olingo.odata2.api.edm.provider.EntityType>,TypeDescriptor> - Parameters:
typeDescriptor- an item type descriptor, for which an EDMX entity type has to be generated- Returns:
- a list with a single generated entity type or an empty set, if this generator is not
isApplicable().
-
isApplicable
Determines whether this generator is applicable to the specified item and can generate at least a single EDMX entity type.- Parameters:
typeDescriptor- an item type descriptor, 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(TypeDescriptor typeDescriptor) Generates a single entity type for the specified item delegating the entity parts creation to:generateEntityTypeName(TypeDescriptor) 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:
typeDescriptor- an item type descriptor 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(TypeDescriptor)should returnfalseinstead.
-
generateKey
-
generateEntityTypeName
Generates name for the entity type being generated.- Parameters:
typeDescriptor- an item type descriptor, for which entity type is being generated.- Returns:
- a valid EDMX entity type name.
-