Interface WritableBean

  • All Superinterfaces:
    io.github.mmm.property.AttributeReadOnly, io.github.mmm.marshall.MarshallableObject, io.github.mmm.marshall.Marshaller<Object>, io.github.mmm.marshall.Marshalling<Object>, io.github.mmm.marshall.MarshallingObject, ReadableBean, io.github.mmm.value.ReadablePath, io.github.mmm.marshall.UnmarshallableObject, io.github.mmm.marshall.Unmarshaller<Object>, io.github.mmm.validation.Validatable, io.github.mmm.value.WritablePath
    All Known Subinterfaces:
    VirtualBean
    All Known Implementing Classes:
    AbstractBean, AbstractVirtualBean, AdvancedBean, Bean, DynamicBean

    @AbstractInterface
    public interface WritableBean
    extends ReadableBean, io.github.mmm.marshall.MarshallingObject
    Writable interface of ReadableBean.
    • Method Detail

      • getRequiredProperty

        default io.github.mmm.property.WritableProperty<?> getRequiredProperty​(String name)
        Specified by:
        getRequiredProperty in interface ReadableBean
        Parameters:
        name - the name of the requested property.
        Returns:
        the requested property.
      • set

        default void set​(String name,
                         Object value)
        Sets the value of the required property with the given name to the given value.
        Parameters:
        name - the name of the property.
        value - new value of the specified property.
      • set

        default <V> void set​(String name,
                             V value,
                             Class<V> valueClass)
        /** Sets the value of the existing or newly created property with the given name to the given value.
        Type Parameters:
        V - the generic type of the value class.
        Parameters:
        name - the property name.
        value - new value of the specified property.
        valueClass - the value class.
        See Also:
        set(String, Object)
      • set

        default <V> void set​(String name,
                             V value,
                             Class<V> valueClass,
                             Type valueType)
        /** Sets the value of the existing or newly created property with the given name to the given value.
        Type Parameters:
        V - the generic type of the value class.
        Parameters:
        name - the property name.
        value - new value of the specified property.
        valueClass - the value class.
        valueType - the Type reflecting the property value.
        See Also:
        set(String, Object)
      • addProperty

        <P extends io.github.mmm.property.WritableProperty<?>> P addProperty​(P property)
        Adds the given WritableProperty to this bean.
        Type Parameters:
        P - type of the WritableProperty to add.
        Parameters:
        property - the WritableProperty to add.
        Returns:
        the given property.
        Throws:
        IllegalStateException - if this WritableBean is read-only or not dynamic.
      • createProperty

        default <V> io.github.mmm.property.WritableProperty<V> createProperty​(String name,
                                                                              Class<V> valueClass)
        Creates and adds a WritableProperty with the given value class dynamically.
        Type Parameters:
        V - the generic type of the value class.
        Parameters:
        name - the property name.
        valueClass - the value class.
        Returns:
        the newly created and added property.
        Throws:
        IllegalStateException - if this WritableBean already has such property, is read-only, or not dynamic.
      • createProperty

        <V> io.github.mmm.property.WritableProperty<V> createProperty​(String name,
                                                                      Class<V> valueClass,
                                                                      Type valueType)
        Creates and adds a WritableProperty with the given value class dynamically.
        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.
        Throws:
        IllegalStateException - if this WritableBean already has such property, is read-only, or not dynamic.
      • getOrCreateProperty

        default <V> io.github.mmm.property.WritableProperty<V> getOrCreateProperty​(String name,
                                                                                   Class<V> valueClass)
        Gets or creates the specified property.
        Type Parameters:
        V - the generic type of the property value.
        Parameters:
        name - the property name.
        valueClass - the value class of the requested property.
        Returns:
        the requested property. Will be created if it does not already exist.
        Throws:
        IllegalArgumentException - if the requested property already exists but has an incompatible value class.
        IllegalStateException - if the requested property does not exist but this WritableBean is read-only, or not dynamic.
      • getOrCreateProperty

        default <V> io.github.mmm.property.WritableProperty<V> getOrCreateProperty​(String name,
                                                                                   Class<V> valueClass,
                                                                                   Type valueType)
        Gets or creates the specified property.
        Type Parameters:
        V - the generic type of the property value.
        Parameters:
        name - the property name.
        valueClass - the Class reflecting the property value.
        valueType - the Type reflecting the property value.
        Returns:
        the requested property. Will be created if it does not already exist.
        Throws:
        IllegalArgumentException - if the requested property already exists but has an incompatible value class.
        IllegalStateException - if the requested property does not exist but this WritableBean is read-only, or not dynamic.
      • read

        default void read​(io.github.mmm.marshall.StructuredReader reader)
        Specified by:
        read in interface io.github.mmm.marshall.UnmarshallableObject