Package com.helixframework.db.repository
Class QueryResult<T>
java.lang.Object
com.helixframework.db.repository.QueryResult<T>
- Type Parameters:
T- the type of elements in the query result
- All Implemented Interfaces:
Iterable<T>
Represents a query result containing a list of results of type T.
-
Constructor Summary
ConstructorsConstructorDescriptionQueryResult(List<T> results) Constructs a QueryResult object with the provided list of results.QueryResult(T result) Constructs a QueryResult object with a single result provided in the parameter. -
Method Summary
Modifier and TypeMethodDescriptiongetList()Returns the list of results contained in this QueryResult object.Retrieves the single result from the QueryResult as an Optional.booleanisEmpty()Checks if the QueryResult object is empty.iterator()intsize()Returns the number of results in this QueryResult object.stream()Returns aStreamof elements contained in this QueryResult object.toList()Returns the results of this QueryResult object as a new ArrayList.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
QueryResult
Constructs a QueryResult object with the provided list of results.- Parameters:
results- the list of results to be added to the QueryResult object
-
QueryResult
Constructs a QueryResult object with a single result provided in the parameter.- Parameters:
result- the single result to be added to the QueryResult object
-
-
Method Details
-
iterator
-
getList
Returns the list of results contained in this QueryResult object.- Returns:
- the list of results
-
getSingle
Retrieves the single result from the QueryResult as an Optional. If there are no results, an empty Optional is returned. If there is more than one result, an IllegalStateException is thrown.- Returns:
- an Optional containing the single result, empty if none
- Throws:
IllegalStateException- if more than one result is present
-
isEmpty
public boolean isEmpty()Checks if the QueryResult object is empty.- Returns:
- true if the QueryResult object contains no results, false otherwise
-
size
public int size()Returns the number of results in this QueryResult object.- Returns:
- the size of the results list
-
stream
Returns aStreamof elements contained in this QueryResult object.- Returns:
- a stream of elements
-
toList
Returns the results of this QueryResult object as a new ArrayList.- Returns:
- a new ArrayList containing the results of this QueryResult object
-