List of usage examples for com.google.common.base Optional isPresent
public abstract boolean isPresent();
From source file:org.opendaylight.bier.driver.common.util.DataGetter.java
public static DataBroker getDataBroker(String nodeId, ConfigurationResult result, MountPointService mountService) { MountPoint mountPoint = getMountPoint(nodeId, result, mountService); if (mountPoint == null) { return null; }//from w w w . j ava2 s . co m Optional<DataBroker> nodeBroker = mountPoint.getService(DataBroker.class); if (!nodeBroker.isPresent()) { LOG.error(ConfigurationResult.DATA_BROKER_FAILUE + nodeId); result.setCfgResult(ConfigurationResult.Result.FAILED); result.setFailureReason(ConfigurationResult.DATA_BROKER_FAILUE + nodeId); return null; } result.setCfgResult(ConfigurationResult.Result.SUCCESSFUL); return nodeBroker.get(); }
From source file:org.opendaylight.mdsal.dom.spi.RpcRoutingStrategy.java
public static RpcRoutingStrategy from(final RpcDefinition rpc) { ContainerSchemaNode input = rpc.getInput(); if (input != null) { for (DataSchemaNode schemaNode : input.getChildNodes()) { Optional<QName> context = getRoutingContext(schemaNode); if (context.isPresent()) { return new RoutedRpcStrategy(rpc.getQName(), context.get(), schemaNode.getQName()); }/*from w w w . j av a 2 s .c om*/ } } return new GlobalRpcStrategy(rpc.getQName()); }
From source file:com.google.devtools.build.xcode.xcodegen.testing.PbxTypes.java
/** * Converts a PBX file reference to its domain equivalent. *///from ww w . j a va2 s.co m public static FileReference fileReference(PBXReference reference) { FileReference fileReference = FileReference.of(reference.getName(), reference.getPath(), reference.getSourceTree()); if (reference instanceof PBXFileReference) { Optional<String> explicitFileType = ((PBXFileReference) reference).getExplicitFileType(); if (explicitFileType.isPresent()) { return fileReference.withExplicitFileType(explicitFileType.get()); } } return fileReference; }
From source file:com.complexible.common.base.Optionals.java
public static <T> T require(final Optional<T> theOptional, final String theMsg) throws IllegalArgumentException { if (theOptional.isPresent()) { return theOptional.get(); }/*w w w .j a v a2 s . c o m*/ throw new IllegalArgumentException(theMsg); }
From source file:org.apache.beam.sdk.extensions.sql.impl.interpreter.operator.date.BeamSqlIntervalMultiplyExpression.java
/** * Output type is null if no operands found with matching types. Execution will later fail when * calling accept()//from ww w . j a v a2 s. c om */ private static SqlTypeName deduceOutputType(List<BeamSqlExpression> operands) { Optional<BeamSqlExpression> intervalOperand = findExpressionOfType(operands, SqlTypeName.INTERVAL_TYPES); return intervalOperand.isPresent() ? intervalOperand.get().getOutputType() : null; }
From source file:dagger2.internal.codegen.MethodSignatureFormatter.java
private static void appendParameter(StringBuilder builder, VariableElement parameter, TypeMirror type) { Optional<AnnotationMirror> qualifier = InjectionAnnotations.getQualifier(parameter); if (qualifier.isPresent()) { builder.append(ErrorMessages.format(qualifier.get())).append(' '); }//from ww w.java 2s .c o m builder.append(nameOfType(type)); }
From source file:org.opennms.newts.rest.Transform.java
static Optional<Duration> toDuration(Optional<DurationParam> value) { return value.isPresent() ? Optional.of(value.get().get()) : Optional.<Duration>absent(); }
From source file:google.registry.flows.FlowReporter.java
/** * Returns the set of unique results of {@link #extractTld} applied to each given domain name, * excluding any absent results (i.e. cases where no TLD was detected). *///from ww w. j a v a 2 s . c o m private static final ImmutableSet<String> extractTlds(Iterable<String> domainNames) { ImmutableSet.Builder<String> set = new ImmutableSet.Builder<>(); for (String domainName : domainNames) { Optional<String> extractedTld = extractTld(domainName); if (extractedTld.isPresent()) { set.add(extractedTld.get()); } } return set.build(); }
From source file:springfox.bean.validators.plugins.BeanValidators.java
@VisibleForTesting static <T extends Annotation> Optional<T> annotationFrom(AnnotatedMember nullableMember, Class<T> annotationType) { Optional<AnnotatedMember> member = Optional.fromNullable(nullableMember); Optional<T> notNull = Optional.absent(); if (member.isPresent()) { notNull = FluentIterable.from(member.get().annotations()).filter(annotationType).first(); }//from www . j ava2 s . co m return notNull; }
From source file:org.anhonesteffort.flock.sync.key.KeySyncUtil.java
private static Optional<HidingCalDavCollection> getKeyCollection(Context context, DavAccount account) throws PropertyParseException, DavException, IOException { HidingCalDavStore store = DavAccountHelper.getHidingCalDavStore(context, account, null); Optional<String> calendarHomeSet = store.getCalendarHomeSet(); if (calendarHomeSet.isPresent()) return store.getCollection(calendarHomeSet.get().concat(PATH_KEY_COLLECTION)); return Optional.absent(); }