Package org.eclipse.rdf4j.spring.dao.support.operation

## Class OperationUtils

- java.lang.Object
- - org.eclipse.rdf4j.spring.dao.support.operation.OperationUtils

-     public class OperationUtils
      extends Object

  Since:
    4.0.0
  Author:
    Florian Kleedorfer

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `OperationUtils()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static <T> Optional<T>` | `atMostOne​(Collection<T> objects)` | Returns the object in the `Collection` wrapped in an `Optional`, an empty Optional if the collection is empty, throwing an Exception if the Collection contains more than one element.
    `static <T> T` | `exactlyOne​(Collection<T> objects)` | Returns the element in the `Collection`, throwing an exception if the collection is empty or contains more than one element.
    `static <T> T` | `require​(Optional<T> required)` | Returns the object contained in the specified `Optional`, throwing an Exception if it is empty.
    `static void` | `setBindings​(Operation operation, Map<String,​Value> bindings)` |
    `static <T> Collector<T,​?,​T>` | `toSingleton()` | Returns the element in the `Stream`, throwing an exception if the stream is empty or contains more than one element.
    `static <T> Collector<T,​?,​T>` | `toSingletonMaybe()` | Returns the element in the `Stream`, or null if the stream is empty, throwing an exception if the stream contains more than one element.
    `static <T> Collector<T,​?,​Optional<T>>` | `toSingletonOptional()` | Returns the element in the `Stream` wrapped in an `Optional` throwing an exception if the stream contains more than one element.

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

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

- - ### Constructor Detail

    - #### OperationUtils

          public OperationUtils()

  - ### Method Detail

    - #### atMostOne

          public static <T> Optional<T> atMostOne​(Collection<T> objects)

      Returns the object in the `Collection` wrapped in an `Optional`, an empty Optional if the collection is empty, throwing an Exception if the Collection contains more than one element.

    - #### require

          public static <T> T require​(Optional<T> required)

      Returns the object contained in the specified `Optional`, throwing an Exception if it is empty.

    - #### exactlyOne

          public static <T> T exactlyOne​(Collection<T> objects)

      Returns the element in the `Collection`, throwing an exception if the collection is empty or contains more than one element.

    - #### toSingleton

          public static <T> Collector<T,​?,​T> toSingleton()

      Returns the element in the `Stream`, throwing an exception if the stream is empty or contains more than one element.

    - #### toSingletonMaybe

          public static <T> Collector<T,​?,​T> toSingletonMaybe()

      Returns the element in the `Stream`, or null if the stream is empty, throwing an exception if the stream contains more than one element.

    - #### toSingletonOptional

          public static <T> Collector<T,​?,​Optional<T>> toSingletonOptional()

      Returns the element in the `Stream` wrapped in an `Optional` throwing an exception if the stream contains more than one element.

    - #### setBindings

          public static void setBindings​(Operation operation,
                                         Map<String,​Value> bindings)