List of usage examples for com.google.common.collect Iterators getOnlyElement
@Nullable public static <T> T getOnlyElement(Iterator<? extends T> iterator, @Nullable T defaultValue)
From source file:com.clarkparsia.sbol.SBOLUtils.java
public static DnaComponent getRootComponent(SBOLDocument doc) { return Iterators.getOnlyElement(Iterators.filter(doc.getContents().iterator(), DnaComponent.class), null); }
From source file:hudson.plugins.timestamper.io.TimestampsReader.java
/** * Read the next time-stamp.// w w w . ja va2s . co m * * @return the next time-stamp, or {@link Optional#absent()} if there are no * more to read * @throws IOException */ public Optional<Timestamp> read() throws IOException { List<Timestamp> timestamps = new ArrayList<Timestamp>(); read(1, Optional.of(timestamps)); return Optional.fromNullable(Iterators.getOnlyElement(timestamps.iterator(), null)); }