Class KeyGenerator
java.lang.Object
de.hybris.platform.odata2services.odata.schema.KeyGenerator
- All Implemented Interfaces:
SchemaElementGenerator<Optional<org.apache.olingo.odata2.api.edm.provider.Key>,List<org.apache.olingo.odata2.api.edm.provider.Property>>
- Direct Known Subclasses:
IntegrationKeyGenerator,LocalizedKeyGenerator,UniquePropertiesKeyGenerator
public abstract class KeyGenerator
extends Object
implements SchemaElementGenerator<Optional<org.apache.olingo.odata2.api.edm.provider.Key>,List<org.apache.olingo.odata2.api.edm.provider.Property>>
Any generator responsible for entity type key generation. This class provides a template for key generation. This template uses
only simple properties for the key; navigation properties are not even considered as candidates for the inclusion in the key.
The implementations can just choose which properties make a key and which don't by implementing
isKey(SimpleProperty)
method.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.olingo.odata2.api.edm.provider.KeyCreates a entity type keyOptional<org.apache.olingo.odata2.api.edm.provider.Key>Generates a key object from a set of entity attributes received as a parameterprotected static List<org.apache.olingo.odata2.api.edm.provider.SimpleProperty>getSimpleProperties(List<org.apache.olingo.odata2.api.edm.provider.Property> entityProperties) protected abstract booleanisKey(org.apache.olingo.odata2.api.edm.provider.SimpleProperty simpleProperty) Determines whether the specified property is a key property.
-
Constructor Details
-
KeyGenerator
public KeyGenerator()
-
-
Method Details
-
generate
public Optional<org.apache.olingo.odata2.api.edm.provider.Key> generate(List<org.apache.olingo.odata2.api.edm.provider.Property> entityProperties) Generates a key object from a set of entity attributes received as a parameter- Specified by:
generatein interfaceSchemaElementGenerator<Optional<org.apache.olingo.odata2.api.edm.provider.Key>,List<org.apache.olingo.odata2.api.edm.provider.Property>> - Parameters:
entityProperties- used to generate the key- Returns:
- Key generated containing the property refs of the valid entity attributes received as a parameter
-
isKey
protected abstract boolean isKey(org.apache.olingo.odata2.api.edm.provider.SimpleProperty simpleProperty) Determines whether the specified property is a key property. Any property that is determined to be a key property will be included into the generated entity type key.- Parameters:
simpleProperty- a property to be checked.- Returns:
true, if the property is a key property;falseotherwise.- See Also:
-
createKey
protected org.apache.olingo.odata2.api.edm.provider.Key createKey(List<org.apache.olingo.odata2.api.edm.provider.PropertyRef> keyProperties) Creates a entity type key- Parameters:
keyProperties- references to the properties selected to be the key properties- Returns:
- a key containing all the specified property references.
- See Also:
-
getSimpleProperties
-