Class PojoIntrospector
java.lang.Object
de.hybris.platform.integrationservices.model.impl.PojoIntrospector
A helper class for performing Java Reflections (Java Bean introspections) on POJOs.
-
Constructor Summary
ConstructorsConstructorDescriptionPojoIntrospector(@NotNull IntegrationObjectClassAttributeModel model) Instantiates this introspector -
Method Summary
Modifier and TypeMethodDescriptionfindMethod(Object[] paramTypes) Searches for a method in the context class.findMethod(String methodName) Searches for a method in the context class.To get the property descriptor of the attribute model inside the context IO class.findProperty(String name) Searches for a property descriptor in the context class for this introspector.Class<?>getActualMethodReturnType(Method method) gets return type for a method in the context class.Class<?>getActualPropertyType(PropertyDescriptor property) gets type for a property descriptor in the context class.To get all the declared properties in the IO class.Returns integration object code for the attribute model in the context of this introspectorReturns integration object item code for the attribute model in the context of this introspectorClass<?>Gets key type for a method/property with Map return type in the context class.Class<?>Gets value type for a method/property with Map return type in the context class.Finds the read method of the attribute model in the context class.This method will return the return-type of the read method.booleanChecks whether given return type ofMethodis Collection or not.booleanChecks whether given attribute model is localized or not.booleanisMap()Checks whether given return type ofMethodis Map or not.
-
Constructor Details
-
PojoIntrospector
Instantiates this introspector- Parameters:
model- attribute model to create the introspector for.
-
-
Method Details
-
getAllProperties
To get all the declared properties in the IO class.- Returns:
- A set of declared properties in the parent class.
- Throws:
IntrospectionException- If an exception occurs while getting bean info for the IO class.
-
findProperty
Searches for a property descriptor in the context class for this introspector.- Parameters:
name- name of the property, which is expected to follow the Java Bean conventions. For example, if a bean has methods likegetValueand/orsetValue, then the property name isvalue.- Returns:
- an Optional containing the property descriptor, if such property was found in the context class,
Optional.empty()otherwise. - Throws:
IntrospectionException- if Java failed to introspect the context class.- See Also:
-
findProperty
To get the property descriptor of the attribute model inside the context IO class.- Returns:
- An Optional containing the property descriptor of the attribute model.
- Throws:
IntrospectionException- If Java failed to introspect the context class.
-
findMethod
Searches for a method in the context class.- Parameters:
paramTypes- expected parameter types the method should have.- Returns:
- an Optional containing the
Method, if the method matching the search conditions was found, orOptional.empty()otherwise.
-
findMethod
Searches for a method in the context class.- Parameters:
methodName- name of the method to find.- Returns:
- an Optional containing the
Method, if the method with the matching name was found, orOptional.empty()otherwise. This method does not take method parameters into consideration.
-
getActualMethodReturnType
gets return type for a method in the context class.- Parameters:
method- theMethodto find.- Returns:
- actual method type of
method - Throws:
IllegalArgumentException- ifmethodis null
-
getActualPropertyType
gets type for a property descriptor in the context class.- Parameters:
property- thePropertyDescriptorto find- Returns:
- actual type of the
property - Throws:
IllegalArgumentException- ifpropertyis null
-
getReadMethod
Finds the read method of the attribute model in the context class. This method will first try to look for the read method from the read method name in the attribute model. If there is no read method name provided to the attribute model, this method will use attribute name to search for the read method. For example, if attribute modelattrhas no read method name assigned, this method will try to look for method namegetAttr().- Returns:
- Optional of the read method of the attribute model.
-
getReturnType
This method will return the return-type of the read method.- Returns:
- optional of return type.
-
isLocalized
public boolean isLocalized()Checks whether given attribute model is localized or not. It is considered to be localized if its read method has locale parameter type.- Returns:
trueif attribute is localized, elsefalse.
-
getMapKeyType
Gets key type for a method/property with Map return type in the context class.- Returns:
- type of the
propertyor return null if it is not Map
-
getMapValueType
Gets value type for a method/property with Map return type in the context class.- Returns:
- value type of the
property, or return null if it is not Map
-
getIntegrationObjectCode
Returns integration object code for the attribute model in the context of this introspector- Returns:
- an integration object code
-
getIntegrationObjectItemCode
Returns integration object item code for the attribute model in the context of this introspector- Returns:
- an integration object code
-
isMap
public boolean isMap()Checks whether given return type ofMethodis Map or not.- Returns:
trueif it is Map, elsefalse.
-
isCollection
public boolean isCollection()Checks whether given return type ofMethodis Collection or not.- Returns:
trueif it is Collection, elsefalse.
-