Class PojoIntrospector

java.lang.Object
de.hybris.platform.integrationservices.model.impl.PojoIntrospector

public class PojoIntrospector extends Object
A helper class for performing Java Reflections (Java Bean introspections) on POJOs.
  • Constructor Details

    • PojoIntrospector

      public PojoIntrospector(@NotNull @NotNull IntegrationObjectClassAttributeModel model)
      Instantiates this introspector
      Parameters:
      model - attribute model to create the introspector for.
  • Method Details

    • getAllProperties

      public Set<PropertyDescriptor> getAllProperties() throws IntrospectionException
      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

      public Optional<PropertyDescriptor> findProperty(String name) throws IntrospectionException
      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 like getValue and/or setValue, then the property name is value.
      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

      public Optional<PropertyDescriptor> findProperty() throws IntrospectionException
      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

      public Optional<Method> findMethod(Object[] paramTypes)
      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, or Optional.empty() otherwise.
    • findMethod

      public Optional<Method> findMethod(String methodName)
      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, or Optional.empty() otherwise. This method does not take method parameters into consideration.
    • getActualMethodReturnType

      public Class<?> getActualMethodReturnType(Method method)
      gets return type for a method in the context class.
      Parameters:
      method - the Method to find.
      Returns:
      actual method type of method
      Throws:
      IllegalArgumentException - if method is null
    • getActualPropertyType

      public Class<?> getActualPropertyType(PropertyDescriptor property)
      gets type for a property descriptor in the context class.
      Parameters:
      property - the PropertyDescriptor to find
      Returns:
      actual type of the property
      Throws:
      IllegalArgumentException - if property is null
    • getReadMethod

      public Optional<Method> 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 model attr has no read method name assigned, this method will try to look for method name getAttr().
      Returns:
      Optional of the read method of the attribute model.
    • getReturnType

      public Optional<Class<?>> 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:
      true if attribute is localized, else false.
    • getMapKeyType

      public Class<?> getMapKeyType()
      Gets key type for a method/property with Map return type in the context class.
      Returns:
      type of the property or return null if it is not Map
    • getMapValueType

      public Class<?> 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

      public String getIntegrationObjectCode()
      Returns integration object code for the attribute model in the context of this introspector
      Returns:
      an integration object code
    • getIntegrationObjectItemCode

      public String 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 of Method is Map or not.
      Returns:
      true if it is Map, else false.
    • isCollection

      public boolean isCollection()
      Checks whether given return type of Method is Collection or not.
      Returns:
      true if it is Collection, else false.