Here you can find the source of uniqueResult(Collection
Parameter | Description |
---|---|
T | the type of the returned object |
results | the set of results returned from a query |
public static <T> T uniqueResult(Collection<T> results)
//package com.java2s; // Distributed under the OSI-approved BSD 3-Clause License. import java.util.Collection; public class Main { /**/*from ww w . j a va2s .c o m*/ * Method to take a get a unique result from a set and return it or null. * * @param <T> the type of the returned object * @param results the set of results returned from a query * @return the first result in the set or null */ public static <T> T uniqueResult(Collection<T> results) { return results.isEmpty() ? null : results.iterator().next(); } }