Package org.coliper.ibean
Class IBeanTypeMetaInfo<T>
- java.lang.Object
-
- org.coliper.ibean.IBeanTypeMetaInfo<T>
-
public class IBeanTypeMetaInfo<T> extends Object
Class that holds all IBean relevant meta information about a specific bean type, mainly a list of all contained fields.This class is created once via constructor and is then immutable afterwards.
-
-
Constructor Summary
Constructors Constructor Description IBeanTypeMetaInfo(Class<T> beanType, BeanStyle beanStyle, List<IBeanFieldMetaInfo> fieldMetaInfos, Method customEqualsMethod, Method customHashCodeMethod)Creates a newIBeanTypeMetaInfowith all contained information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BeanStylebeanStyle()Gives the bean style the bean type complies to.Class<T>beanType()Gives the related bean type.Optional<Method>customEqualsMethod()Provides a method containing custom implementation ofObject.equals().Optional<Method>customHashCodeMethod()Provides a method containing custom implementation ofObject.hashCode().booleanequals(Object obj)Compares this instance with any other object preferably with anotherIBeanTypeMetaInfo.List<IBeanFieldMetaInfo>fieldMetaInfos()ProvidesIBeanFieldMetaInfofor all fields of the bean type.Optional<IBeanFieldMetaInfo>findFieldMetaWithFieldName(String fieldName)Iterates over all containedIBeanFieldMetaInfoand returns the field meta info that belongs to a field with a given name.Optional<IBeanFieldMetaInfo>findFieldMetaWithMethod(Method method)Iterates over all containedIBeanFieldMetaInfoand returns the field meta info that contains the given method either as setter or as getter.inthashCode()intnoOfFields()Convenience method returning the number of fields contained in the bean type.StringtoString()
-
-
-
Constructor Detail
-
IBeanTypeMetaInfo
public IBeanTypeMetaInfo(Class<T> beanType, BeanStyle beanStyle, List<IBeanFieldMetaInfo> fieldMetaInfos, Method customEqualsMethod, Method customHashCodeMethod)
Creates a newIBeanTypeMetaInfowith all contained information.- Parameters:
beanType- the IBean type the meta information is related tobeanStyle- the bean style that was used for parsing the bean typefieldMetaInfos- meta information about all fields contained in the bean type; may not benullbut may be an empty listcustomEqualsMethod- aMethodthat contains a bean type individual implementation ofObject.equals(); may benullcustomHashCodeMethod- aMethodthat contains a bean type individual implementation ofObject.hashCode(); may benull
-
-
Method Detail
-
beanType
public Class<T> beanType()
Gives the related bean type.- Returns:
- the bean class this meta information is related to
-
beanStyle
public BeanStyle beanStyle()
Gives the bean style the bean type complies to.- Returns:
- the
BeanStylethat was used for parsing the bean type
-
fieldMetaInfos
public List<IBeanFieldMetaInfo> fieldMetaInfos()
ProvidesIBeanFieldMetaInfofor all fields of the bean type.- Returns:
- the meta information about all contained fields of the bean type
-
customEqualsMethod
public Optional<Method> customEqualsMethod()
Provides a method containing custom implementation ofObject.equals(). The method is named_equalsby convention.- Returns:
- the optional method
-
customHashCodeMethod
public Optional<Method> customHashCodeMethod()
Provides a method containing custom implementation ofObject.hashCode(). The method is named_hashCodeby convention.- Returns:
- the optional method
-
noOfFields
public int noOfFields()
Convenience method returning the number of fields contained in the bean type.- Returns:
- same as
this.fieldMetaInfos.size()
-
findFieldMetaWithMethod
public Optional<IBeanFieldMetaInfo> findFieldMetaWithMethod(Method method)
Iterates over all containedIBeanFieldMetaInfoand returns the field meta info that contains the given method either as setter or as getter.- Parameters:
method- the getter or setter to search for- Returns:
- the field meta info or an empty
Optionalif no field info matches
-
findFieldMetaWithFieldName
public Optional<IBeanFieldMetaInfo> findFieldMetaWithFieldName(String fieldName)
Iterates over all containedIBeanFieldMetaInfoand returns the field meta info that belongs to a field with a given name.- Parameters:
fieldName- the name of a field to search for- Returns:
- the field meta info or an empty
Optionalif no field name matches
-
equals
public boolean equals(Object obj)
Compares this instance with any other object preferably with anotherIBeanTypeMetaInfo. TwoIBeanTypeMetaInfoare equal if they have the same bean type and the same bean style.- Overrides:
equalsin classObject- See Also:
Object.equals(java.lang.Object)
-
-