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 theCollection
wrapped in anOptional
, 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 theCollection
, 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 specifiedOptional
, 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 theStream
, throwing an exception if the stream is empty or contains more than one element.static <T> Collector<T,?,T>
toSingletonMaybe()
Returns the element in theStream
, 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()
-
-
-
Method Detail
-
atMostOne
public static <T> Optional<T> atMostOne(Collection<T> objects)
Returns the object in theCollection
wrapped in anOptional
, 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 specifiedOptional
, throwing an Exception if it is empty.
-
exactlyOne
public static <T> T exactlyOne(Collection<T> objects)
Returns the element in theCollection
, 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 theStream
, 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 theStream
, or null if the stream is empty, throwing an exception if the stream contains more than one element.
-
-