Class JavaBeanAttributesCollector
- java.lang.Object
-
- org.immutables.value.processor.meta.JavaBeanAttributesCollector
-
final class JavaBeanAttributesCollector extends java.lang.ObjectCollects attributes by scanning for getters/setters/fields in a class definition.Current logic is as follows:
- Collect getters (no-arg, non-static, non-void methods). Infer attribute names using JavaBean spec.
- Collect setters (single-arg, non-static, void methods). Infer attribute names using JavaBean spec.
- Collect (non-static) fields including from parent classes. Add alternative field names using primitive heuristics like underscore '_' removal or first letter decapitalization.
ValueAttributewill point to field element. For now we don't allow "derived" attributes and require fields to be present.It is important that attributes are serialized otherwise using criteria on non-marshalable attribute(s) doesn't make sense (we may provide attribute renaming strategies in future). For each
getFoomethod (without parameters) create attributefoo.- See Also:
AccessorAttributesCollector, JavaBeans spec
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classJavaBeanAttributesCollector.FieldsCollects and caches list of fields for current typeprivate classJavaBeanAttributesCollector.GettersCollects and caches list of getters for current typeprivate classJavaBeanAttributesCollector.Setters
-
Field Summary
Fields Modifier and Type Field Description private JavaBeanAttributesCollector.Fieldsfieldsprivate JavaBeanAttributesCollector.Gettersgettersprivate Proto.Protoclassprotoclassprivate JavaBeanAttributesCollector.Setterssettersprivate Stylesstylesprivate ValueTypetype
-
Constructor Summary
Constructors Constructor Description JavaBeanAttributesCollector(Proto.Protoclass protoclass, ValueType type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidcollect()private javax.lang.model.element.TypeElementgetCachedTypeElement()private static booleanisJavaLangObject(javax.lang.model.element.Element element)Checks if current element isObject.private ValueAttributetoAttribute(java.lang.String name, javax.lang.model.element.Element element)Create attribute from JavaBean getter
-
-
-
Field Detail
-
type
private final ValueType type
-
protoclass
private final Proto.Protoclass protoclass
-
fields
private final JavaBeanAttributesCollector.Fields fields
-
getters
private final JavaBeanAttributesCollector.Getters getters
-
setters
private final JavaBeanAttributesCollector.Setters setters
-
styles
private final Styles styles
-
-
Constructor Detail
-
JavaBeanAttributesCollector
JavaBeanAttributesCollector(Proto.Protoclass protoclass, ValueType type)
-
-
Method Detail
-
isJavaLangObject
private static boolean isJavaLangObject(javax.lang.model.element.Element element)
Checks if current element isObject. Usually no processing is necessary for top-levelObjectclass.
-
getCachedTypeElement
private javax.lang.model.element.TypeElement getCachedTypeElement()
-
collect
void collect()
-
toAttribute
private ValueAttribute toAttribute(java.lang.String name, javax.lang.model.element.Element element)
Create attribute from JavaBean getter
-
-