Class SynchronizedPropertyAccess<R,​T>

java.lang.Object
org.iworkz.habitat.sync.SynchronizedPropertyAccess<R,​T>
Type Parameters:
R -
T -

public class SynchronizedPropertyAccess<R,​T>
extends Object
Convenient support for 'double-checked locking'-pattern for properties of an Object.
  • Field Details

    • object

      protected final R object
    • getterInvocation

      protected final Supplier<T> getterInvocation
    • setterInvocation

      protected final Consumer<T> setterInvocation
  • Constructor Details

    • SynchronizedPropertyAccess

      public SynchronizedPropertyAccess​(R object, Supplier<T> getterInvocation, Consumer<T> setterInvocation)
  • Method Details

    • get

      public T get()
    • isDefined

      public boolean isDefined()
    • getOrCreate

      public T getOrCreate​(Supplier<T> valueSupplier)
    • getOrCreate

      public T getOrCreate​(Consumer<T> valueModifier)
    • createAndSet

      public void createAndSet​(Supplier<T> valueSupplier)
    • create

      public void create​(Consumer<R> valueConsumer)
    • create

      protected T create()