List of usage examples for com.google.common.base Optional of
public static <T> Optional<T> of(T reference)
From source file:io.dockstore.webservice.SimpleAuthenticator.java
@Override public Optional<Token> authenticate(String credentials) throws AuthenticationException { LOG.info("SimpleAuthenticator called with {}", credentials); final Token token = dao.findByContent(credentials); if (token != null) { return Optional.of(token); }/* www. java2s . co m*/ return Optional.absent(); }
From source file:se.sics.ktoolbox.croupier.behaviour.CroupierParticipant.java
@Override public Optional<View> getView() { return Optional.of(view); }
From source file:org.sosy_lab.cpachecker.cpa.value.symbolic.type.SymbolicExpression.java
protected SymbolicExpression(final MemoryLocation pRepresentedLocation) { representedLocation = Optional.of(pRepresentedLocation); }
From source file:appeng.items.tools.quartz.ToolQuartzPickaxe.java
public ToolQuartzPickaxe(final AEFeature type) { super(ToolMaterial.IRON); this.type = type; this.feature = new ItemFeatureHandler(EnumSet.of(type, AEFeature.QuartzPickaxe), this, this, Optional.of(type.name())); }
From source file:de.flapdoodle.logparser.io.BufferedReaderAdapter.java
@Override public Optional<String> nextLine() throws IOException { String line = _reader.readLine(); return line != null ? Optional.of(line) : Optional.<String>absent(); }
From source file:org.eclipse.buildship.ui.view.task.TaskNodeSelectionUtils.java
/** * Tries to map the given selection to a Gradle run configuration. * * @param selection the selection to map * @return the mapped run configuration, if possible *///w w w.j a v a2s . c o m public static Optional<GradleRunConfigurationAttributes> tryGetRunConfigurationAttributes( NodeSelection selection) { if (isValidRunConfiguration(selection)) { return Optional.of(getRunConfigurationAttributes(selection)); } else { return Optional.absent(); } }
From source file:com.facebook.presto.metadata.QualifiedTablePrefix.java
public QualifiedTablePrefix(String catalogName, String schemaName) { this.catalogName = checkCatalogName(catalogName); this.schemaName = Optional.of(checkSchemaName(schemaName)); this.tableName = Optional.absent(); }
From source file:org.apache.jclouds.oneandone.rest.handlers.OneAndOneRateLimitRetryHandler.java
@Override protected Optional<Long> millisToNextAvailableRequest(HttpCommand command, HttpResponse response) { String secondsToNextAvailableRequest = response.getFirstHeaderOrNull(RETRY_AFTER_CUSTOM); if (secondsToNextAvailableRequest == null) { return Optional.absent(); }//from w w w .ja va 2s. c o m return Optional.of(millisUntilNextAvailableRequest(Long.parseLong(secondsToNextAvailableRequest))); }
From source file:com.eucalyptus.loadbalancing.dns.LoadBalancerDomainName.java
public static Optional<LoadBalancerDomainName> findMatching(final Name name) { for (final LoadBalancerDomainName domainName : values()) { if (domainName.apply(name)) { return Optional.of(domainName); }//from w ww. j a va2 s. c o m } return Optional.absent(); }
From source file:org.locationtech.geogig.api.plumbing.ResolveBranchId.java
@Override protected Optional<Ref> _call() { Preconditions.checkState(id != null, "id has not been set."); Predicate<Ref> filter = new Predicate<Ref>() { @Override// ww w .j ava 2 s . c o m public boolean apply(@Nullable Ref ref) { return ref.getObjectId().equals(id); } }; ImmutableSet<Ref> refs = command(ForEachRef.class).setFilter(filter).call(); if (refs.isEmpty()) { return Optional.absent(); } else { return Optional.of(refs.iterator().next()); } }