com.holonplatform.core.property

## Interface VirtualProperty<T>

- Type Parameters:
    `T` - Property type
  All Superinterfaces:
    ConverterExpression<T>, Expression, HasConfiguration<PropertyConfiguration>, Localizable, Property<T>, Serializable, TypedExpression<T>, Validator.Validatable<T>
  All Known Subinterfaces:
    ListVirtualProperty<T>, ListVirtualProperty.ListVirtualPropertyBuilder<T>, SetVirtualProperty<T>, SetVirtualProperty.SetVirtualPropertyBuilder<T>, VirtualProperty.Builder<T,P,B>, VirtualProperty.VirtualPropertyBuilder<T>

      public interface VirtualProperty<T>
      extends Property<T>

  A virtual `Property` which relies on a `PropertyValueProvider` to provide its value, and it is not directly bound to a data model attribute.

  By default, a `VirtualProperty` is always read-only.

  The natural lifecycle of a `VirtualProperty` is within a `PropertyBox` instance. The `PropertyBox` instance will be provided to the `PropertyValueProvider` when the value of a `VirtualProperty` is requested through the `PropertyBox.getValue(Property)` method. This way, the values of other properties contained in the `PropertyBox` can be used by the virtual property to calculate the value to provide.

  The symbolic property name (made avaialable by `Property.getName()`) can be setted using the `VirtualProperty.Builder.name(String)` method. If a specific name is not provided, the name of a virtual property will be a default name composed by the class name and the instance hash code.

  The `create(Class)` and `create(Class, PropertyValueProvider)` builder methods can be used to create and configure a new `PathProperty` instance.

  Since:
    5.0.0
  See Also:
    `PropertyValueProvider`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `VirtualProperty.Builder<T,P extends VirtualProperty<T>,B extends VirtualProperty.Builder<T,P,B>>` Base `VirtualProperty` builder.
    `static interface` | `VirtualProperty.VirtualPropertyBuilder<T>` Default `VirtualProperty` builder.

    - ### Nested classes/interfaces inherited from interface com.holonplatform.core.property.Property

      `Property.PropertyAccessException, Property.PropertyNotFoundException, Property.PropertyReadException, Property.PropertyReadOnlyException, Property.PropertyWriteException`

    - ### Nested classes/interfaces inherited from interface com.holonplatform.core.i18n.Localizable

      `Localizable.LocalizableBuilder, Localizable.LocalizationException`

    - ### Nested classes/interfaces inherited from interface com.holonplatform.core.Expression

      `Expression.ExpressionResolverFunction<E extends Expression,R extends Expression>, Expression.InvalidExpressionException`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> VirtualProperty.VirtualPropertyBuilder<T>` | `create(Class<? extends T> type)` Create a new VirtualProperty with given `type`
    `static <T> VirtualProperty.VirtualPropertyBuilder<T>` | `create(Class<T> type, PropertyValueProvider<T> valueProvider)` Create a new VirtualProperty with given `type` using given `PropertyValueProvider` as property value provider.
    `PropertyValueProvider<T>` | `getValueProvider()` Get property value provider.
    `default boolean` | `isReadOnly()` Gets whether property is read-only, i.e. does not support value setting.

    - ### Methods inherited from interface com.holonplatform.core.property.Property

      `getConfiguration, getConvertedValue, getConverter, getExpressionValueConverter, getName, getTemporalType, getType, present, render, renderIfAvailable`

    - ### Methods inherited from interface com.holonplatform.core.Validator.Validatable

      `getValidators, validate`

    - ### Methods inherited from interface com.holonplatform.core.i18n.Localizable

      `builder, getMessage, getMessageArguments, getMessageCode, of, of`

    - ### Methods inherited from interface com.holonplatform.core.HasConfiguration

      `hasConfiguration`

    - ### Methods inherited from interface com.holonplatform.core.ConverterExpression

      `getModelType, getModelValue`

    - ### Methods inherited from interface com.holonplatform.core.TypedExpression

      `isCollectionExpression, isConverterExpression`

    - ### Methods inherited from interface com.holonplatform.core.Expression

      `validate`

- - ### Method Detail

    - #### getValueProvider

          PropertyValueProvider<T> getValueProvider()

      Get property value provider.
      Returns:
        The property value provider (not null)

    - #### isReadOnly

          default boolean isReadOnly()

      Description copied from interface: `Property`
      Gets whether property is read-only, i.e. does not support value setting.

      When a property is read-only, a `Property.PropertyReadOnlyException` should be thrown by property value setting methods.

      Specified by:
        `isReadOnly` in interface `Property<T>`
      Returns:
        `true` if property is read-only

    - #### create

          static <T> VirtualProperty.VirtualPropertyBuilder<T> create(Class<? extends T> type)

      Create a new VirtualProperty with given `type`
      Type Parameters:
        `T` - Property value type
      Parameters:
        `type` - Property value type
      Returns:
        A `VirtualProperty.Builder` to setup property attributes

    - #### create

          static <T> VirtualProperty.VirtualPropertyBuilder<T> create(Class<T> type,
                                                                      PropertyValueProvider<T> valueProvider)

      Create a new VirtualProperty with given `type` using given `PropertyValueProvider` as property value provider.
      Type Parameters:
        `T` - Property value type
      Parameters:
        `type` - Property value type
        `valueProvider` - Property value provider
      Returns:
        A `VirtualProperty.Builder` to setup property attributes

Copyright © 2019 The Holon Platform. All rights reserved.