Package org.eclipse.net4j.util.concurrent

# Class Holder<T>

java.lang.Object
org.eclipse.net4j.util.concurrent.Holder<T>

All Implemented Interfaces:
  `Consumer<T>`, `Supplier<T>`

public final class Holder<T> extends Object implements Consumer<T>, Supplier<T>
A simple holder for a single element that implements `Consumer` and `Supplier`.

This class is not thread-safe.

Since:
  3.16
Author:
  Eike Stepper

## Constructor Summary

Constructors
Constructor
Description
`Holder()`
`Holder(Supplier<T> creator)`
`Holder(Supplier<T> creator, T unset)`
`Holder(T element)`

## Method Summary

Modifier and Type
Method
Description
`void`
`accept(T element)`
`T`
`get()`
`T`
`getIfSet()`
`T`
`handleIfSet(Consumer<T> consumer)`
`boolean`
`isSet()`
`T`
`set(T element)`

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

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

### Methods inherited from interface java.util.function.Consumer

`andThen`

## Constructor Details

### Holder

public Holder()

### Holder

public Holder(T element)

### Holder

public Holder(Supplier<T> creator)

Since:
  3.29

### Holder

public Holder(Supplier<T> creator, T unset)

Since:
  3.29

## Method Details

### isSet

public boolean isSet()

Since:
  3.29

### handleIfSet

public T handleIfSet(Consumer<T> consumer)

Since:
  3.29

### getIfSet

public T getIfSet()

Since:
  3.29

### get

public T get()

Specified by:
  `get` in interface `Supplier<T>`

### set

public T set(T element)

### accept

public void accept(T element)

Specified by:
  `accept` in interface `Consumer<T>`