Class Bean

  • All Implemented Interfaces:
    java.lang.Cloneable, java.lang.Iterable<Component>, Property, Replicateable

    public class Bean
    extends PropertyComponent
    implements Property
    A component used to aggregate Property's into a bean object, which may also be a property of a parent bean object itself.

    A bean may only have children that implement Property.

    Since:
    2.0
    • Constructor Detail

      • Bean

        public Bean()
    • Method Detail

      • defines

        public boolean defines​(java.lang.Object bean)
        Specified by:
        defines in interface Property
      • createValue

        public java.lang.Object createValue​(ParsingContext context)
        Description copied from interface: Property
        Creates the property value and returns it.
        Specified by:
        createValue in interface Property
        Parameters:
        context - the ParsingContext
        Returns:
        the property value
      • getValue

        public java.lang.Object getValue​(ParsingContext context)
        Description copied from interface: Property
        Returns the value of this property.

        When unmarshalling, this method should return Value.MISSING if the field was not present in the stream. Or if present, but has no value, null should be returned.

        When marshalling, this method should return Value.MISSING for any optional segment bound to a bean object, or null if required. Null field properties should always return Value.MISSING.

        Specified by:
        getValue in interface Property
        Parameters:
        context - the ParsingContext
        Returns:
        the property value, or Value.MISSING if not present in the stream, or Value.INVALID if the field was invalid
      • setValue

        public void setValue​(ParsingContext context,
                             java.lang.Object value)
        Description copied from interface: Property
        Sets the property value (before marshalling).
        Specified by:
        setValue in interface Property
        Parameters:
        context - the ParsingContext
        value - the property value
      • newInstance

        protected java.lang.Object newInstance​(ParsingContext context)
        Creates a new instance of this bean object.
        Parameters:
        context - the ParsingContext
        Returns:
        the new bean Object
      • isMap

        protected boolean isMap()
        Returns whether the bean object implements Map.
        Returns:
        true if the bean object implements Map, false otherwise
      • getConstructor

        public java.lang.reflect.Constructor<?> getConstructor()
        Returns the Constructor used to instantiate this bean object, or null if the default no-arg constructor is used.
        Returns:
        the Constructor
      • setConstructor

        public void setConstructor​(java.lang.reflect.Constructor<?> constructor)
        Sets the Constructor used to instantiate this bean object.
        Parameters:
        constructor - the Constructor
      • registerLocals

        public void registerLocals​(java.util.Set<ParserLocal<?>> locals)
        Description copied from class: Component
        Called by a stream to register variables stored in the parsing context. This method should be overridden by subclasses that need to register one or more parser context variables.
        Overrides:
        registerLocals in class Component
        Parameters:
        locals - set of local variables
      • isLazy

        public boolean isLazy()
      • setLazy

        public void setLazy​(boolean lazy)