Class AbstractBean

  • All Implemented Interfaces:
    ReadableBean, WritableBean, io.github.mmm.marshall.MarshallableObject, io.github.mmm.marshall.Marshaller<Object>, io.github.mmm.marshall.Marshalling<Object>, io.github.mmm.marshall.MarshallingObject, io.github.mmm.marshall.UnmarshallableObject, io.github.mmm.marshall.Unmarshaller<Object>, io.github.mmm.property.AttributeReadOnly, io.github.mmm.validation.Validatable, io.github.mmm.value.ReadablePath, io.github.mmm.value.WritablePath
    Direct Known Subclasses:
    AbstractVirtualBean, Bean

    public abstract class AbstractBean
    extends Object
    implements WritableBean
    Abstract base implementation of WritableBean.
    See Also:
    Bean
    • Constructor Detail

      • AbstractBean

        public AbstractBean()
        The constructor.
    • Method Detail

      • path

        public String path()
        Specified by:
        path in interface ReadableBean
        Specified by:
        path in interface io.github.mmm.value.ReadablePath
        Returns:
        the path of this bean. It will be appended as prefix to the ReadableBean.path() of all properties. This is useful for criteria API to build queries. So e.g. set to "e." if this bean should have the query alias "e".
      • path

        public void path​(String path)
        Specified by:
        path in interface io.github.mmm.value.WritablePath
      • path

        public void path​(Supplier<String> pathExpression)
        Specified by:
        path in interface io.github.mmm.value.WritablePath
      • isThreadSafe

        protected boolean isThreadSafe()
        Returns:
        true if the Bean shall be thread-safe (use concurrent collections, etc.), false otherwise.
      • isDynamic

        public boolean isDynamic()
        Specified by:
        isDynamic in interface ReadableBean
        Returns:
        true if this Bean is dynamic meaning that is not strictly typed but allows to dynamically add properties, false otherwise.
        See Also:
        VirtualBean
      • requireWritable

        protected void requireWritable()
        Verifies that this Bean is writable (not read-only).
      • requireDynamic

        protected void requireDynamic()
        Verifies that this Bean is dynamic (extensible).
      • copy

        public WritableBean copy​(boolean isReadOnly)
        Specified by:
        copy in interface ReadableBean
        Parameters:
        isReadOnly - - true if the copy shall be read-only.
        Returns:
        a copy of this WritableBean that has the same values for all properties.
      • isReadOnly

        public final boolean isReadOnly()
        Specified by:
        isReadOnly in interface io.github.mmm.property.AttributeReadOnly
      • create

        protected AbstractBean create()
        Creates a new instance of this Bean implementation. The default implementation uses reflection. To improve performance please override this method. Please note, that if you do so, you also need to override this method again for all sub-classes of the hierarchy.
        Returns:
        the new Bean instance. Has to be of the same type as the current class.
      • createProperty

        public <V> io.github.mmm.property.WritableProperty<V> createProperty​(String name,
                                                                             Class<V> valueClass,
                                                                             Type valueType)
        Description copied from interface: WritableBean
        Creates and adds a WritableProperty with the given value class dynamically.
        Specified by:
        createProperty in interface WritableBean
        Type Parameters:
        V - the generic type of the value class.
        Parameters:
        name - the property name.
        valueClass - the value class.
        valueType - the Type reflecting the property value.
        Returns:
        the newly created and added property.
      • addProperty

        public <P extends io.github.mmm.property.WritableProperty<?>> P addProperty​(P property)
        Description copied from interface: WritableBean
        Adds the given WritableProperty to this bean.
        Specified by:
        addProperty in interface WritableBean
        Type Parameters:
        P - type of the WritableProperty to add.
        Parameters:
        property - the WritableProperty to add.
        Returns:
        the given property.
      • add

        protected <V,​P extends io.github.mmm.property.WritableProperty<V>> P add​(P property)
        Internal method for addProperty(WritableProperty), without verification. Will be called from constructor of bean class implementations to register properties.
        Type Parameters:
        V - type of the property value.
        P - type of the WritableProperty to add.
        Parameters:
        property - the WritableProperty to add.
        Returns:
        the given property.
      • isLockOwnerInternal

        protected boolean isLockOwnerInternal​(io.github.mmm.property.AttributeReadOnly lock)
        Parameters:
        lock - the lock to check.
        Returns:
        true if this bean is the lock owner, false otherwise.
      • add

        protected io.github.mmm.property.builder.PropertyBuilders add()
        Returns:
        the builder factory to build properties to be added to this bean.
      • onPropertyAdded

        protected void onPropertyAdded​(io.github.mmm.property.WritableProperty<?> property)
        Parameters:
        property - the WritableProperty that has been added.