List of usage examples for com.google.common.base Optional fromNullable
public static <T> Optional<T> fromNullable(@Nullable T nullableReference)
From source file:io.crate.sql.tree.FrameBound.java
public FrameBound(Type type, Expression value) { this.type = checkNotNull(type, "type is null"); this.value = Optional.fromNullable(value); }
From source file:org.eclipse.recommenders.models.dependencies.DependencyInfo.java
public Optional<String> getAttribute(String key) { return Optional.fromNullable(attributes.get(key)); }
From source file:org.geogit.osm.internal.log.ReadOSMMappingLogEntry.java
@Override public Optional<OSMMappingLogEntry> call() { final File osmMapFolder = command(ResolveOSMMappingLogFolder.class).call(); File file = new File(osmMapFolder, path); OSMMappingLogEntry entry = null;//www. ja v a2s . co m if (file.exists()) { try { synchronized (file.getCanonicalPath().intern()) { String line = Files.readFirstLine(file, Charsets.UTF_8); entry = OSMMappingLogEntry.fromString(line); } } catch (IOException e) { throw Throwables.propagate(e); } } return Optional.fromNullable(entry); }
From source file:org.apache.aurora.scheduler.cron.SanitizedCronJob.java
/** * Get the default cron collision policy. * * @param policy A (possibly null) policy. * @return The given policy or a default if the policy was null. *///from ww w . j a v a2 s .c om public static CronCollisionPolicy orDefault(@Nullable CronCollisionPolicy policy) { return Optional.fromNullable(policy).or(CronCollisionPolicy.KILL_EXISTING); }
From source file:io.crate.sql.tree.CreateAnalyzer.java
public CreateAnalyzer(String ident, @Nullable String extendedAnalyzer, List<AnalyzerElement> elements) { this.ident = ident; this.extendedAnalyzer = Optional.fromNullable(extendedAnalyzer); this.elements = elements; this.properties = new GenericProperties(); for (AnalyzerElement element : elements) { if (element instanceof GenericProperty) { this.properties.add((GenericProperty) element); }/*from w ww .j a v a2 s. com*/ } }
From source file:org.locationtech.geogig.api.Node.java
public Optional<ObjectId> getMetadataId() { return Optional.fromNullable(metadataId); }
From source file:org.feature4j.FeatureBundle.java
public <T> Optional<T> get(String key, Class<T> valueClass) { final Object featureValue = features.get(key); if (featureValue == null || !featureValue.getClass().isAssignableFrom(valueClass)) { return Optional.absent(); }/*from w w w . j a va 2 s .c o m*/ return Optional.fromNullable((T) featureValue); }
From source file:org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType.java
/** * The node's id, the prefix of the string, the last value returned * @param node The node to search from (required) * @param prefix The optional prefix/*from w w w . j a v a2 s .c o m*/ * @param last The optional last */ public SimpleSearchEdgeType(final Id node, final String prefix, final Optional<String> last) { ValidationUtils.verifyIdentity(node); this.node = node; this.prefix = Optional.fromNullable(prefix); this.last = last == null ? Optional.<String>absent() : last; }
From source file:org.basepom.mojo.propertyhelper.macros.DemoMacro.java
@Override public Optional<String> getValue(@Nonnull final MacroDefinition macroDefinition, @Nonnull final ValueProvider valueProvider, @Nonnull final AbstractPropertyHelperMojo mojo) { Preconditions.checkState(mojo != null, "inserted mojo is null!"); final String type = Objects.firstNonNull(macroDefinition.getProperties().get("type"), "static"); if ("static".equals(type)) { return Optional.of("static-value"); } else if ("property".equals(type)) { return valueProvider.getValue(); } else {//ww w . java2s. co m return Optional.fromNullable(macroDefinition.getProperties().get("value")); } }
From source file:com.replaymod.sponge.recording.ReplayMetaData.java
@SuppressWarnings("unchecked") public final <T> Optional<T> get(String key) { return Optional.fromNullable((T) metaData.get(key)); }