Class JavaBeanAttributesCollector


  • final class JavaBeanAttributesCollector
    extends java.lang.Object
    Collects attributes by scanning for getters/setters/fields in a class definition.

    Current logic is as follows:

    1. Collect getters (no-arg, non-static, non-void methods). Infer attribute names using JavaBean spec.
    2. Collect setters (single-arg, non-static, void methods). Infer attribute names using JavaBean spec.
    3. Collect (non-static) fields including from parent classes. Add alternative field names using primitive heuristics like underscore '_' removal or first letter decapitalization.
    Intersection between getter / setter and field names is final attribute set. Created 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:
    AccessorAttributesCollector, JavaBeans spec
    • Method Detail

      • isJavaLangObject

        private static boolean isJavaLangObject​(javax.lang.model.element.Element element)
        Checks if current element is Object. Usually no processing is necessary for top-level Object class.
      • 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