com.hammurapi.store.local

## Class LocalHandle<T,PK,S extends Store<T,PK,S>>

- java.lang.Object
- - com.hammurapi.store.local.LocalHandle<T,PK,S>

- All Implemented Interfaces:
    Store.Handle<T,PK,S>

      public class LocalHandle<T,PK,S extends Store<T,PK,S>>
      extends Object
      implements Store.Handle<T,PK,S>

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `LocalHandle.HandleStrength`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LocalHandle(LocalStoreBase<T,PK,S> store, T obj, PK primaryKey, Map<S,Map<Extractor<T,? super PK,S>,? super PK>> cache, Predicate<T,S>[] validators, LocalHandle.HandleStrength handleStrength, boolean cacheExtracted)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object obj)`
    `<V> V` | `extract(Extractor<T,V,S> extractor)` Extracts value from handle's object using given extractor and internal handle's cache.
    `T` | `get()`
    `protected Map<S,Map<Extractor<T,? super PK,S>,? super PK>>` | `getCache()`
    `PK` | `getPrimaryKey()`
    `int` | `hashCode()`
    `boolean` | `isValid()`
    `void` | `remove()` Removes object referenced by this handle.
    `String` | `toString()`
    `void` | `update()` Clears cache and updates indexes.
    `void` | `update(T obj)` Updates object referenced by this handle.

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### LocalHandle

          public LocalHandle(LocalStoreBase<T,PK,S> store,
                     T obj,
                     PK primaryKey,
                     Map<S,Map<Extractor<T,? super PK,S>,? super PK>> cache,
                     Predicate<T,S>[] validators,
                     LocalHandle.HandleStrength handleStrength,
                     boolean cacheExtracted)

  - ### Method Detail

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### update

          public void update(T obj)

      Description copied from interface: `Store.Handle`
      Updates object referenced by this handle. Clears cache and updates indexes. The new object shall have the same primary key if the store has primary key extractor.
      Specified by:
        `update` in interface `Store.Handle<T,PK,S extends Store<T,PK,S>>`
      Parameters:
        `obj` - New object for the handle (for immutable objects).

    - #### update

          public void update()

      Description copied from interface: `Store.Handle`
      Clears cache and updates indexes. Updated object shall have the same primary key if the store has primary key extractor.
      Specified by:
        `update` in interface `Store.Handle<T,PK,S extends Store<T,PK,S>>`

    - #### remove

          public void remove()

      Description copied from interface: `Store.Handle`
      Removes object referenced by this handle.
      Specified by:
        `remove` in interface `Store.Handle<T,PK,S extends Store<T,PK,S>>`

    - #### getCache

          protected Map<S,Map<Extractor<T,? super PK,S>,? super PK>> getCache()

    - #### get

          public T get()

      Specified by:
        `get` in interface `Store.Handle<T,PK,S extends Store<T,PK,S>>`
      Returns:
        Object referenced by this handle.

    - #### getPrimaryKey

          public PK getPrimaryKey()

      Specified by:
        `getPrimaryKey` in interface `Store.Handle<T,PK,S extends Store<T,PK,S>>`
      Returns:
        Primary key if object store is configured with primary key extractor.

    - #### isValid

          public boolean isValid()

      Specified by:
        `isValid` in interface `Store.Handle<T,PK,S extends Store<T,PK,S>>`
      Returns:
        True if object referenced by this handle is present in the store.

    - #### extract

          public <V> V extract(Extractor<T,V,S> extractor)

      Description copied from interface: `Store.Handle`
      Extracts value from handle's object using given extractor and internal handle's cache.
      Specified by:
        `extract` in interface `Store.Handle<T,PK,S extends Store<T,PK,S>>`
      Type Parameters:
        `V` - Value type
      Parameters:
        `extractor` - Extractor
      Returns:
        extracted value.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`