com.holonplatform.core.property

## Interface PropertySet<P extends Property>

- Type Parameters:
    `P` - Concrete type of the properties contained in the set
  All Superinterfaces:
    HasConfiguration<ParameterSet>, Iterable<P>
  All Known Subinterfaces:
    BeanPropertySet<T>, PropertyBox

      public interface PropertySet<P extends Property>
      extends Iterable<P>, HasConfiguration<ParameterSet>

  This interface represent an `Iterable` and immutable set of `Property`s.
  Since:
    5.0.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static interface` | `PropertySet.Builder<P extends Property>` Builder to create `PropertySet` instances.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `CONTEXT_KEY` Default `Context` resource reference
    `static ConfigProperty<PropertySet>` | `PROPERTY_CONFIGURATION_ATTRIBUTE` The `PropertyConfiguration` attribute to use to declare the PropertySet for a PropertyBox type `Property`.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `default List<P>` | `asList()` Convert this PropertySet into a `List` of properties.
    `static PropertySet.Builder<Property<?>>` | `builder()` Obtain a builder to create and populate a generic `PropertySet`.
    `static <P extends Property> PropertySet.Builder<P>` | `builder(Class<? extends P> propertyType)` Obtain a builder to create and populate a `PropertySet` which supports given `Property` type.
    `static <P extends Property> PropertySet.Builder<Property<?>>` | `builderOf(P... properties)` Obtain a builder to create and populate a `PropertySet`, and add given `properties` to the property set to build.
    `static <P extends Property> PropertySet.Builder<Property<?>>` | `builderOf(PropertySet<P> propertySet)` Get a builder to create a new `PropertySet` from given `propertySet`, cloning configuration, identifiers and properties of the provided `propertySet`.
    `boolean` | `contains(Property property)` Return `true` if this set contains the given `property`.
    `default <V> V` | `execute(Callable<V> operation)` Execute given `Callable` `operation` on behalf of this PropertySet, i.e.
    `ParameterSet` | `getConfiguration()` Get the property set configuration, which can be used for extensions and application-specific purposes.
    `default Optional<P>` | `getFirstIdentifier()` Get the first property which acts as property set identifier, if available.
    `Set<P>` | `getIdentifiers()` Get the optional identifier properties which represent the unique identifier of this property set.
    `default Stream<P>` | `identifiers()` Get a `Stream` of the properties which represent the unique identifier of this property set.
    `static <P extends Property> PropertySet<P>` | `join(PropertySet<? extends P>... propertySets)` Deprecated. Using this method causes the loss of any property set configuration and/or identifier property declaration. Use the default PropertySet builder to compose a new PropertySet from different property sources.
    `static <P extends Property> PropertySet<P>` | `of(Iterable<P> properties)` Create a new PropertySet containing all given `properties` `Iterable` elements.
    `static <P extends Property> PropertySet<P>` | `of(P... properties)` Create a new PropertySet containing given `properties`.
    `static <P extends Property> PropertySet<P>` | `of(PropertySet<? extends P> propertySet, P... properties)` Create a new `PropertySet` joining given `propertySet` with given additional `properties`.
    `int` | `size()` Returns the number of properties in this set.
    `Stream<P>` | `stream()` Returns a sequential `Stream` of the `Property`s of this set.

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, iterator, spliterator`

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

      `hasConfiguration`

- - ### Field Detail

    - #### CONTEXT_KEY

          static final String CONTEXT_KEY

      Default `Context` resource reference

    - #### PROPERTY_CONFIGURATION_ATTRIBUTE

          static final ConfigProperty<PropertySet> PROPERTY_CONFIGURATION_ATTRIBUTE

      The `PropertyConfiguration` attribute to use to declare the PropertySet for a PropertyBox type `Property`.

  - ### Method Detail

    - #### size

          int size()

      Returns the number of properties in this set. If this set contains more than `Integer.MAX_VALUE` elements, returns `Integer.MAX_VALUE`.
      Returns:
        the number of properties in this set

    - #### contains

          boolean contains(Property property)

      Return `true` if this set contains the given `property`. If the given `property` is `null`, always returns `false`.
      Parameters:
        `property` - Property whose presence in this set is to be tested
      Returns:
        `true` if this set contains the specified property

    - #### stream

          Stream<P> stream()

      Returns a sequential `Stream` of the `Property`s of this set.
      Returns:
        Properties stream

    - #### getIdentifiers

          Set<P> getIdentifiers()

      Get the optional identifier properties which represent the unique identifier of this property set.

      If one or more identifier property is declared, the values of such properties uniquely specify the instance of an object bound to this property set. The identifier properties of the set can be used, for example, as a dicriminator for object equality.

      Returns:
        A `Set` of identifier properties, or an empty `Set` if no identifier is provided
      Since:
        5.1.0

    - #### identifiers

          default Stream<P> identifiers()

      Get a `Stream` of the properties which represent the unique identifier of this property set.
      Returns:
        The identifier properties stream, empty if no identifier is provided by this property set
      Since:
        5.1.0

    - #### getFirstIdentifier

          default Optional<P> getFirstIdentifier()

      Get the first property which acts as property set identifier, if available.
      Returns:
        The first identifier property, or an empty Optional if no identifier is provided
      Since:
        5.1.0

    - #### getConfiguration

          ParameterSet getConfiguration()

      Get the property set configuration, which can be used for extensions and application-specific purposes.

      This configuration is considered as immutable. The configuration parameters has to setted at `PropertySet` build time, using the appropriate `PropertySet.Builder` methods: `PropertySet.Builder.configuration(String, Object)` and `PropertySet.Builder.configuration(ConfigProperty, Object)`.

      Specified by:
        `getConfiguration` in interface `HasConfiguration<ParameterSet>`
      Returns:
        The property set configuration `ParameterSet` (never null)

    - #### asList

          default List<P> asList()

      Convert this PropertySet into a `List` of properties.
      Returns:
        List of set properties

    - #### execute

          default <V> V execute(Callable<V> operation)

      Execute given `Callable` `operation` on behalf of this PropertySet, i.e. binding this PropertySet as `Context` resource to current Thread, and removing the binding after operation execution.
      Type Parameters:
        `V` - Operation result type
      Parameters:
        `operation` - Operation to execute
      Returns:
        Operation result

    - #### builder

          static PropertySet.Builder<Property<?>> builder()

      Obtain a builder to create and populate a generic `PropertySet`.
      Returns:
        A new `PropertySet` builder

    - #### builder

          static <P extends Property> PropertySet.Builder<P> builder(Class<? extends P> propertyType)

      Obtain a builder to create and populate a `PropertySet` which supports given `Property` type.
      Type Parameters:
        `P` - Property type
      Parameters:
        `propertyType` - The property type managed by the `PropertySet` to build (not null)
      Returns:
        A new `PropertySet` builder
      Since:
        5.1.0

    - #### builderOf

          @SafeVarargs
          static <P extends Property> PropertySet.Builder<Property<?>> builderOf(P... properties)

      Obtain a builder to create and populate a `PropertySet`, and add given `properties` to the property set to build.
      Type Parameters:
        `P` - Property type
      Parameters:
        `properties` - Properties to initially add to the property set (not null)
      Returns:
        A new `PropertySet` builder
      Since:
        5.1.0

    - #### builderOf

          static <P extends Property> PropertySet.Builder<Property<?>> builderOf(PropertySet<P> propertySet)

      Get a builder to create a new `PropertySet` from given `propertySet`, cloning configuration, identifiers and properties of the provided `propertySet`.
      Type Parameters:
        `P` - Property type
      Parameters:
        `propertySet` - The property set to clone for the new builder (not null)
      Returns:
        A new `PropertySet` builder
      Since:
        5.3.0

    - #### of

          @SafeVarargs
          static <P extends Property> PropertySet<P> of(P... properties)

      Create a new PropertySet containing given `properties`.
      Type Parameters:
        `P` - Type of the property managed by the property set
      Parameters:
        `properties` - Properties of the set
      Returns:
        PropertySet instance

    - #### of

          static <P extends Property> PropertySet<P> of(Iterable<P> properties)

      Create a new PropertySet containing all given `properties` `Iterable` elements.
      Type Parameters:
        `P` - Type of the property managed by the property set
      Parameters:
        `properties` - Properties of the set
      Returns:
        PropertySet instance

    - #### of

          @SafeVarargs
          static <P extends Property> PropertySet<P> of(PropertySet<? extends P> propertySet,
                                                                      P... properties)

      Create a new `PropertySet` joining given `propertySet` with given additional `properties`.

      Any identifier property declared by given `propertySet` will be an identifier of the new property set too. The original property set configuration is cloned to the new `PropertySet` instance configuration.

      Type Parameters:
        `P` - Property type
      Parameters:
        `propertySet` - Source property set (not null)
        `properties` - Additional properties
      Returns:
        A new `PropertySet` instance containing the properties of given `propertySet` and any additional provided property

    - #### join

          @Deprecated
           @SafeVarargs
          static <P extends Property> PropertySet<P> join(PropertySet<? extends P>... propertySets)

      Deprecated. Using this method causes the loss of any property set configuration and/or identifier property declaration. Use the default PropertySet builder to compose a new PropertySet from different property sources.
      Join given `PropertySet`s and return a new PropertySet containing all the properties of given sets.
      Type Parameters:
        `P` - Actual property type
      Parameters:
        `propertySets` - PropertySet to join (not null and not empty)
      Returns:
        New PropertySet containing all the properties of given sets

Copyright © 2019 The Holon Platform. All rights reserved.