Class ReflectiveMetaBean<T extends Bean>

  • Type Parameters:
    T - the type of the bean
    All Implemented Interfaces:
    MetaBean, TypedMetaBean<T>

    public final class ReflectiveMetaBean<T extends Bean>
    extends java.lang.Object
    implements TypedMetaBean<T>
    A meta-bean implementation that uses reflection.

    This is implementation of a meta-bean can be used directly by applications without code generation. It requires that the bean implements Bean and has a no-arguments constructor. Therefore, it is only suitable for mutable beans.

    Typically, the meta-bean will be created as a public static final constant. Only one method from Bean needs to be implemented, which simply returns the meta-bean.

    • Method Detail

      • of

        public static <B extends BeanReflectiveMetaBean<B> of​(java.lang.Class<B> beanClass,
                                                                java.lang.String... propertyNames)
        Create a meta-bean and meta properties.

        The meta-properties will be created from the property names by searching for a getter and setter.

        Type Parameters:
        B - the type of the bean
        beanClass - the bean class, not null
        propertyNames - the property names, not null
        the meta-bean, not null
      • isBuildable

        public boolean isBuildable()
        Description copied from interface: MetaBean
        Checks whether this bean is buildable or not.

        A buildable bean can be constructed using MetaBean.builder(). If this method returns true then builder() must return a valid builder. If this method returns false then builder() must throw UnsupportedOperationException.

        Specified by:
        isBuildable in interface MetaBean
        true if this bean is buildable
      • builder

        public BeanBuilder<T> builder()
        Description copied from interface: MetaBean
        Creates a bean builder that can be used to create an instance of this bean.

        The builder is used in two main ways. The first is to allow immutable beans to be constructed. The second is to enable automated tools like serialization/deserialization.

        The builder can be thought of as a Map of MetaProperty to value. Note that the implementation is not necessarily an actual map.

        Specified by:
        builder in interface MetaBean
        Specified by:
        builder in interface TypedMetaBean<T extends Bean>
        the bean builder, not null
      • beanType

        public java.lang.Class<T> beanType()
        Description copied from interface: MetaBean
        Get the type of the bean, represented as a Class.

        A MetaBean can be thought of as the equivalent of Class but for beans. This method allows the actual Class instance of the bean to be obtained.

        Specified by:
        beanType in interface MetaBean
        Specified by:
        beanType in interface TypedMetaBean<T extends Bean>
        the type of the bean, not null
      • metaPropertyMap

        public java.util.Map<java.lang.String,​MetaProperty<?>> metaPropertyMap()
        Description copied from interface: MetaBean
        Gets the map of meta-properties, keyed by property name.

        Where possible, use MetaBean.metaPropertyIterable() instead as it typically has better performance.

        Specified by:
        metaPropertyMap in interface MetaBean
        the unmodifiable map of meta property objects, not null
      • equals

        public boolean equals​(java.lang.Object obj)
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Returns a string that summarises the meta-bean.
        toString in class java.lang.Object
        a summary string, not null