com.hammurapi.common.concurrent

## Class AbstractPropertySet<KP,KE>

- java.lang.Object
- - com.hammurapi.common.concurrent.AbstractPropertySet<KP,KE>

- Type Parameters:
    `KP` - Key path
    `KE` - Key path element
  All Implemented Interfaces:
    Adaptable, PropertySet<KP>, Versionable<PropertySet<KP>>, ReadWriteLock
  Direct Known Subclasses:
    LocalAbstractPropertySet

      public abstract class AbstractPropertySet<KP,KE>
      extends Object
      implements PropertySet<KP>, ReadWriteLock

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Context` | `context`
    `protected Converter` | `converter`
    `protected ExecutorService` | `executorService`
    `protected PropertySet<KP>[]` | `shadows`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractPropertySet(ExecutorService executorService, Converter converter, Context context, PropertySet<KP>... shadows)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract KP` | `buildPath(int startIdx, Object... elements)`
    `protected abstract KP` | `buildPath(KE prefix, KP suffix)`
    `protected abstract KP` | `buildPath(KP prefix, Object... elements)`
    `protected KP` | `buildPath(Object... elements)`
    `protected void` | `cancel(KE[] path, int idx)`
    `void` | `cancel(KP key)` Removes callable to be cooked from the cooking queue, converting it to lazy, if it is not already cooked.
    `void` | `cancelAll()` Cancels all unfinished background computations.
    `void` | `clear()` Removes all entries from the property set
    `protected void` | `cook(KE[] path, int idx, Callable<?> callable, long delay, TimeUnit timeUnit)`
    `void` | `cook(KP key, Callable<?> callable)` Puts callable to the property set for asynchronous invocation to retrieve value at some point in the future.
    `void` | `cook(KP key, Callable<?> callable, long delay, TimeUnit timeUnit)` Puts callable to the property set for asynchronous invocation to retrieve value at some point in the future after specified delay.
    `void` | `cooking(KP key, Future<?> future)` Puts value which is not ready yet but "is being cooked by another thread" to the property set to be used at some point of time in the future.
    `protected Object` | `get(KE[] path, int idx, Object[] va)`
    `protected Object` | `get(KE[] path, int idx, Object[] va, long timeout, TimeUnit unit)`
    `Object` | `get(KP key)` Retrieves property without conversion.
    `<T> T` | `get(KP key, Class<T> type)` Retrieves property with conversion to target type.
    `<T> T` | `get(KP key, Class<T> type, long timeout, TimeUnit unit)` Retrieves property with conversion to target type.
    `<T> T` | `get(KP key, Class<T> type, T defaultValue)`
    `<T> T` | `get(KP key, Class<T> type, T defaultValue, long timeout, TimeUnit unit)`
    `Object` | `get(KP key, long timeout, TimeUnit unit)` Retrieves property without conversion.
    `Object` | `get(KP key, Object defaultValue)`
    `Object` | `get(KP key, Object defaultValue, long timeout, TimeUnit unit)`
    `protected abstract Map<KE,PropertySet<KP>>` | `getMounts()`
    `protected abstract Map<KE,AbstractPropertySet<KP,KE>>` | `getSubSetStore()`
    `protected abstract Map<KE,Object>` | `getValueStore()`
    `Object` | `invoke(KP key, Object... args)` Invokes invocable at given key.
    `Set<KP>` | `keySet()`
    `void` | `lazy(KP key, Callable<?> callable)` Puts callable to the property set.
    `protected void` | `mount(KE[] path, int idx, PropertySet<KP> source)`
    `void` | `mount(KP prefix, PropertySet<KP> source)` Mounts source property set at specified prefix.
    `protected abstract AbstractPropertySet<KP,KE>` | `newInstance(KE key)` Creates a property set which shares lock and chain with this one.
    `protected void` | `remove(KE[] path, int idx)`
    `void` | `remove(KP key)` Removes property from the set.
    `protected void` | `set(KE[] path, int idx, Object value)`
    `void` | `set(KP key, Object value)` Sets property.
    `void` | `setAll(PropertySet<KP> source)` Copies all entries from the source property set to self.
    `void` | `setInvocable(KP key, Invocable<PropertySet<KP>,?,KP,?> invocable)` Convenience method to set invocable.
    `Object` | `shadowGet(KP key)` Retrieves shadow property without conversion.
    `<T> T` | `shadowGet(KP key, Class<T> type)` Retrieves property with conversion to target type.
    `<T> T` | `shadowGet(KP key, Class<T> type, long timeout, TimeUnit unit)` Retrieves property with conversion to target type.
    `<T> T` | `shadowGet(KP key, Class<T> type, T defaultValue)`
    `<T> T` | `shadowGet(KP key, Class<T> type, T defaultValue, long timeout, TimeUnit unit)`
    `Object` | `shadowGet(KP key, long timeout, TimeUnit unit)` Retrieves shadow property without conversion.
    `Object` | `shadowGet(KP key, Object defaultValue)`
    `Object` | `shadowGet(KP key, Object defaultValue, long timeout, TimeUnit unit)`
    `Object` | `shadowInvoke(KP key, Object... args)` Invokes invocable in the shadow property set at given key.
    `protected PropertySet<KP>` | `subset(KE[] prefix, int idx, boolean create)`
    `PropertySet<KP>` | `subset(KP prefix)`
    `protected abstract KE[]` | `tokenize(KP path)`
    `protected void` | `unmount(KE[] path, int idx)`
    `void` | `unmount(KP prefix)`
    `protected abstract <T> T` | `version(T source)` Versions object for forward-only change propagation purposes.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.hammurapi.common.Adaptable

      `getAdapter`

    - ### Methods inherited from interface com.hammurapi.common.concurrent.Versionable

      `createVersion`

    - ### Methods inherited from interface java.util.concurrent.locks.ReadWriteLock

      `readLock, writeLock`

- - ### Field Detail

    - #### converter

          protected Converter converter

    - #### executorService

          protected ExecutorService executorService

    - #### shadows

          protected PropertySet<KP>[] shadows

    - #### context

          protected Context context

  - ### Constructor Detail

    - #### AbstractPropertySet

          protected AbstractPropertySet(ExecutorService executorService,
                             Converter converter,
                             Context context,
                             PropertySet<KP>... shadows)

  - ### Method Detail

    - #### getValueStore

          protected abstract Map<KE,Object> getValueStore()

      Returns:
        Store for values.

    - #### getSubSetStore

          protected abstract Map<KE,AbstractPropertySet<KP,KE>> getSubSetStore()

      Returns:

    - #### newInstance

          protected abstract AbstractPropertySet<KP,KE> newInstance(KE key)

      Creates a property set which shares lock and chain with this one.
      Returns:

    - #### getMounts

          protected abstract Map<KE,PropertySet<KP>> getMounts()

    - #### buildPath

          protected abstract KP buildPath(int startIdx,
                     Object... elements)

    - #### buildPath

          protected KP buildPath(Object... elements)

    - #### buildPath

          protected abstract KP buildPath(KP prefix,
                     Object... elements)

    - #### buildPath

          protected abstract KP buildPath(KE prefix,
                     KP suffix)

    - #### tokenize

          protected abstract KE[] tokenize(KP path)

    - #### version

          protected abstract <T> T version(T source)

      Versions object for forward-only change propagation purposes.
      Type Parameters:
        `T` -
      Parameters:
        `source` -
      Returns:

    - #### keySet

          public Set<KP> keySet()

      Specified by:
        `keySet` in interface `PropertySet<KP>`
      Returns:
        Names of properties in the set

    - #### subset

          public PropertySet<KP> subset(KP prefix)

      Specified by:
        `subset` in interface `PropertySet<KP>`
      Returns:
        Property set which operates on properties starting with given prefix.

    - #### subset

          protected PropertySet<KP> subset(KE[] prefix,
                               int idx,
                               boolean create)

    - #### remove

          public void remove(KP key)

      Description copied from interface: `PropertySet`
      Removes property from the set. Chained properties are shadowed (appear to be removed).
      Specified by:
        `remove` in interface `PropertySet<KP>`

    - #### remove

          protected void remove(KE[] path,
                    int idx)

    - #### clear

          public void clear()

      Description copied from interface: `PropertySet`
      Removes all entries from the property set
      Specified by:
        `clear` in interface `PropertySet<KP>`

    - #### mount

          public void mount(KP prefix,
                   PropertySet<KP> source)

      Description copied from interface: `PropertySet`
      Mounts source property set at specified prefix. E.g. if source property set has entry 'a' and prefix is 'b/' then that entry will be available as 'b/a'. Mounted entries shadow own entries.
      Specified by:
        `mount` in interface `PropertySet<KP>`

    - #### mount

          protected void mount(KE[] path,
                   int idx,
                   PropertySet<KP> source)

    - #### unmount

          public void unmount(KP prefix)

      Specified by:
        `unmount` in interface `PropertySet<KP>`

    - #### unmount

          protected void unmount(KE[] path,
                     int idx)

    - #### setAll

          public void setAll(PropertySet<KP> source)

      Description copied from interface: `PropertySet`
      Copies all entries from the source property set to self.
      Specified by:
        `setAll` in interface `PropertySet<KP>`

    - #### get

          public Object get(KP key)

      Description copied from interface: `PropertySet`
      Retrieves property without conversion.
      Specified by:
        `get` in interface `PropertySet<KP>`

    - #### get

          public Object get(KP key,
                   long timeout,
                   TimeUnit unit)

      Description copied from interface: `PropertySet`
      Retrieves property without conversion.
      Specified by:
        `get` in interface `PropertySet<KP>`

    - #### get

          protected Object get(KE[] path,
                   int idx,
                   Object[] va)

    - #### get

          protected Object get(KE[] path,
                   int idx,
                   Object[] va,
                   long timeout,
                   TimeUnit unit)

    - #### get

          public Object get(KP key,
                   Object defaultValue)

      Specified by:
        `get` in interface `PropertySet<KP>`
      Parameters:
        `key` - Property key.
        `defaultValue` - Default value.
      Returns:
        Property value or default value if property doesn't exist in the property set.

    - #### get

          public Object get(KP key,
                   Object defaultValue,
                   long timeout,
                   TimeUnit unit)

      Specified by:
        `get` in interface `PropertySet<KP>`
      Parameters:
        `key` - Property key.
        `defaultValue` - Default value.
      Returns:
        Property value or default value if property doesn't exist in the property set.

    - #### get

          public <T> T get(KP key,
                  Class<T> type)

      Description copied from interface: `PropertySet`
      Retrieves property with conversion to target type.
      Specified by:
        `get` in interface `PropertySet<KP>`

    - #### get

          public <T> T get(KP key,
                  Class<T> type,
                  long timeout,
                  TimeUnit unit)

      Description copied from interface: `PropertySet`
      Retrieves property with conversion to target type.
      Specified by:
        `get` in interface `PropertySet<KP>`

    - #### get

          public <T> T get(KP key,
                  Class<T> type,
                  T defaultValue)

      Specified by:
        `get` in interface `PropertySet<KP>`
      Parameters:
        `key` - Property key.
        `type` - target type.
        `defaultValue` - Default value.
      Returns:
        Property value or default value if property doesn't exist in the property set.

    - #### get

          public <T> T get(KP key,
                  Class<T> type,
                  T defaultValue,
                  long timeout,
                  TimeUnit unit)

      Specified by:
        `get` in interface `PropertySet<KP>`
      Parameters:
        `key` - Property key.
        `type` - target type.
        `defaultValue` - Default value.
      Returns:
        Property value or default value if property doesn't exist in the property set.

    - #### set

          public void set(KP key,
                 Object value)

      Description copied from interface: `PropertySet`
      Sets property.
      Specified by:
        `set` in interface `PropertySet<KP>`

    - #### set

          protected void set(KE[] path,
                 int idx,
                 Object value)

    - #### setInvocable

          public void setInvocable(KP key,
                          Invocable<PropertySet<KP>,?,KP,?> invocable)

      Description copied from interface: `PropertySet`
      Convenience method to set invocable.
      Specified by:
        `setInvocable` in interface `PropertySet<KP>`

    - #### cook

          public void cook(KP key,
                  Callable<?> callable)

      Description copied from interface: `PropertySet`
      Puts callable to the property set for asynchronous invocation to retrieve value at some point in the future.
      Specified by:
        `cook` in interface `PropertySet<KP>`

    - #### cook

          protected void cook(KE[] path,
                  int idx,
                  Callable<?> callable,
                  long delay,
                  TimeUnit timeUnit)

    - #### cook

          public void cook(KP key,
                  Callable<?> callable,
                  long delay,
                  TimeUnit timeUnit)

      Description copied from interface: `PropertySet`
      Puts callable to the property set for asynchronous invocation to retrieve value at some point in the future after specified delay.
      Specified by:
        `cook` in interface `PropertySet<KP>`

    - #### cooking

          public void cooking(KP key,
                     Future<?> future)

      Description copied from interface: `PropertySet`
      Puts value which is not ready yet but "is being cooked by another thread" to the property set to be used at some point of time in the future.
      Specified by:
        `cooking` in interface `PropertySet<KP>`
        `future` - Value being cooked.

    - #### lazy

          public void lazy(KP key,
                  Callable<?> callable)

      Description copied from interface: `PropertySet`
      Puts callable to the property set. Value from callable is retrieved when `get()` method for the given name is invoked.
      Specified by:
        `lazy` in interface `PropertySet<KP>`

    - #### cancel

          public void cancel(KP key)

      Description copied from interface: `PropertySet`
      Removes callable to be cooked from the cooking queue, converting it to lazy, if it is not already cooked.
      Specified by:
        `cancel` in interface `PropertySet<KP>`

    - #### cancel

          protected void cancel(KE[] path,
                    int idx)

    - #### cancelAll

          public void cancelAll()

      Description copied from interface: `PropertySet`
      Cancels all unfinished background computations.
      Specified by:
        `cancelAll` in interface `PropertySet<KP>`

    - #### invoke

          public Object invoke(KP key,
                      Object... args)

      Description copied from interface: `PropertySet`
      Invokes invocable at given key. Converts arguments to proper types if needed. Invocation is performed under the write lock, so the invocable can safely modify the property set.
      Specified by:
        `invoke` in interface `PropertySet<KP>`

    - #### shadowInvoke

          public Object shadowInvoke(KP key,
                            Object... args)

      Description copied from interface: `PropertySet`
      Invokes invocable in the shadow property set at given key. Converts arguments to proper types if needed. The shadow invocable is provided a read-only property set as a context and thus any attempt to modify the state of shadow property set(s) will result in exception.
      Specified by:
        `shadowInvoke` in interface `PropertySet<KP>`

    - #### shadowGet

          public Object shadowGet(KP key)

      Description copied from interface: `PropertySet`
      Retrieves shadow property without conversion.
      Specified by:
        `shadowGet` in interface `PropertySet<KP>`

    - #### shadowGet

          public Object shadowGet(KP key,
                         Object defaultValue)

      Specified by:
        `shadowGet` in interface `PropertySet<KP>`
      Parameters:
        `key` - Property key.
        `defaultValue` - Default value.
      Returns:
        Property value or default value if property doesn't exist in the property set.

    - #### shadowGet

          public <T> T shadowGet(KP key,
                        Class<T> type)

      Description copied from interface: `PropertySet`
      Retrieves property with conversion to target type.
      Specified by:
        `shadowGet` in interface `PropertySet<KP>`

    - #### shadowGet

          public <T> T shadowGet(KP key,
                        Class<T> type,
                        T defaultValue)

      Specified by:
        `shadowGet` in interface `PropertySet<KP>`
      Parameters:
        `key` - Property key.
        `type` - target type.
        `defaultValue` - Default value.
      Returns:
        Property value or default value if property doesn't exist in the property set.

    - #### shadowGet

          public Object shadowGet(KP key,
                         long timeout,
                         TimeUnit unit)

      Description copied from interface: `PropertySet`
      Retrieves shadow property without conversion.
      Specified by:
        `shadowGet` in interface `PropertySet<KP>`

    - #### shadowGet

          public Object shadowGet(KP key,
                         Object defaultValue,
                         long timeout,
                         TimeUnit unit)

      Specified by:
        `shadowGet` in interface `PropertySet<KP>`
      Parameters:
        `key` - Property key.
        `defaultValue` - Default value.
      Returns:
        Property value or default value if property doesn't exist in the property set.

    - #### shadowGet

          public <T> T shadowGet(KP key,
                        Class<T> type,
                        long timeout,
                        TimeUnit unit)

      Description copied from interface: `PropertySet`
      Retrieves property with conversion to target type.
      Specified by:
        `shadowGet` in interface `PropertySet<KP>`

    - #### shadowGet

          public <T> T shadowGet(KP key,
                        Class<T> type,
                        T defaultValue,
                        long timeout,
                        TimeUnit unit)

      Specified by:
        `shadowGet` in interface `PropertySet<KP>`
      Parameters:
        `key` - Property key.
        `type` - target type.
        `defaultValue` - Default value.
      Returns:
        Property value or default value if property doesn't exist in the property set.