Class JavaBeanAttributesCollector
java.lang.Object
org.immutables.value.processor.meta.JavaBeanAttributesCollector
Collects 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.
ValueAttribute will
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 getFoo method (without parameters) create attribute foo.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classCollects and caches list of fields for current typeprivate classCollects and caches list of getters for current typeprivate class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final JavaBeanAttributesCollector.Fieldsprivate final JavaBeanAttributesCollector.Gettersprivate final Proto.Protoclassprivate final JavaBeanAttributesCollector.Settersprivate final Stylesprivate final ValueType -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidcollect()private TypeElementprivate static booleanisJavaLangObject(Element element) Checks if current element isObject.private ValueAttributetoAttribute(String name, Element element) Create attribute from JavaBean getter
-
Field Details
-
type
-
protoclass
-
fields
-
getters
-
setters
-
styles
-
-
Constructor Details
-
JavaBeanAttributesCollector
JavaBeanAttributesCollector(Proto.Protoclass protoclass, ValueType type)
-
-
Method Details
-
isJavaLangObject
Checks if current element isObject. Usually no processing is necessary for top-levelObjectclass. -
getCachedTypeElement
-
collect
void collect() -
toAttribute
Create attribute from JavaBean getter
-