List of usage examples for com.google.common.base Optional get
public abstract T get();
From source file:org.locationtech.geogig.repository.SpatialOps.java
@Nullable public static Envelope boundsOf(RevFeature feat) { Envelope env = null;/*from w w w. j a va 2 s. c om*/ for (Optional<Object> opt : feat.getValues()) { if (opt.isPresent() && opt.get() instanceof Geometry) { if (env == null) { env = new Envelope(); } env.expandToInclude(((Geometry) opt.get()).getEnvelopeInternal()); } } return env; }
From source file:org.opendaylight.controller.config.yangjmxgenerator.plugin.java.GeneratedObjectBuilder.java
private static String maybeAddComment(Optional<String> comment, boolean isJavadoc) { if (comment.isPresent()) { String input = comment.get(); return StringUtil.writeComment(input, isJavadoc); } else {/*from ww w.j ava 2 s . c o m*/ return ""; } }
From source file:org.eclipse.recommenders.utils.rcp.UUIDHelper.java
public static String getUUID() { final Optional<String> uuid = lookupUUIDFromStore(); if (uuid.isPresent()) { return uuid.get(); }// w w w. j ava 2 s. c o m final String newUuid = generateGlobalUUID(); storeUUID(newUuid); return newUuid; }
From source file:org.sonar.server.computation.formula.coverage.CoverageUtils.java
static MeasureVariations getMeasureVariations(CounterInitializationContext counterContext, String metricKey) { Optional<Measure> measure = counterContext.getMeasure(metricKey); if (!measure.isPresent() || !measure.get().hasVariations()) { return DEFAULT_VARIATIONS; }//from ww w . j a va2 s . co m return measure.get().getVariations(); }
From source file:org.opendaylight.protocol.bgp.openconfig.impl.openconfig.BGPNeighborProviderImpl.java
private static String getPasswor(final Optional<Rfc2385Key> maybePassword) { if (maybePassword.isPresent()) { return maybePassword.get().getValue(); }//from w w w . ja v a 2 s . c o m return null; }
From source file:com.github.jsdossier.jscomp.Types.java
private static boolean hasTypeExpression(Optional<JSDocInfo.Marker> marker) { return marker.isPresent() && marker.get().getType() != null; }
From source file:org.assertj.guava.error.OptionalShouldBeAbsent.java
public static <T> ErrorMessageFactory shouldBeAbsent(final Optional<T> actual) { return new OptionalShouldBeAbsent( "Expecting Optional to contain nothing (absent Optional) but contained <%s>", actual.get()); }
From source file:org.apache.usergrid.persistence.model.entity.EntityMap.java
public static Optional<EntityMap> fromEntity(Optional<Entity> entity) { if (entity.isPresent()) { EntityMap map = fromEntity(entity.get()); return Optional.fromNullable(map); } else {/*from w ww. j a v a 2s.c o m*/ return Optional.absent(); } }
From source file:org.apache.aurora.scheduler.http.api.security.FieldGetters.java
public static <P extends TBase<P, ?>, C extends TBase<C, ?>, G extends TBase<G, ?>> FieldGetter<P, G> compose( final FieldGetter<P, C> parent, final FieldGetter<C, G> child) { return new FieldGetter<P, G>() { @Override/*from w ww . j a v a 2 s . c om*/ public Class<P> getStructClass() { return parent.getStructClass(); } @Override public Class<G> getValueClass() { return child.getValueClass(); } @Override public Optional<G> apply(P input) { Optional<C> parentValue = parent.apply(input); if (parentValue.isPresent()) { return child.apply(parentValue.get()); } else { return Optional.absent(); } } }; }
From source file:com.complexible.common.base.Optionals.java
public static <T> List<T> all(final Collection<Optional<T>> theCollection) { List<T> aList = Lists.newArrayList(); for (Optional<T> aOpt : theCollection) { if (aOpt.isPresent()) { aList.add(aOpt.get()); }/*from w w w. java2 s . c o m*/ } return aList; }