List of usage examples for com.google.common.base Optional isPresent
public abstract boolean isPresent();
From source file:org.apache.gobblin.source.extractor.extract.google.GoogleCommon.java
private static FileSystem getFileSystem(Optional<String> fsUri) throws IOException { if (fsUri.isPresent()) { return FileSystem.get(URI.create(fsUri.get()), new Configuration()); }/* w w w. j av a2s.c om*/ return FileSystem.get(new Configuration()); }
From source file:org.eclipse.viatra.addon.querybasedfeatures.runtime.QueryBasedFeatureSetup.java
private static Set<EStructuralFeature> initializeFeatures(Notifier rootNotifier, QueryBasedFeatureSettingDelegateFactory qbfFactory, Set<EStructuralFeature> qbfFeatures) { Set<EStructuralFeature> initializedQBFFeatures = Sets.newHashSet(); for (EStructuralFeature eStructuralFeature : qbfFeatures) { Optional<QueryBasedFeatureSettingDelegate> optional = qbfFactory.getSettingDelegate(eStructuralFeature); if (optional.isPresent()) { QueryBasedFeatureSettingDelegate delegate = optional.get(); delegate.initializeSettingDelegate(rootNotifier); initializedQBFFeatures.add(eStructuralFeature); }/*from ww w . ja va 2 s .c o m*/ } return initializedQBFFeatures; }
From source file:com.google.errorprone.bugpatterns.threadsafety.AbstractLockMethodChecker.java
private static Optional<ImmutableSet<GuardedByExpression>> parseLockExpressions(List<String> lockExpressions, Tree tree, VisitorState state) { ImmutableSet.Builder<GuardedByExpression> builder = ImmutableSet.builder(); for (String lockExpression : lockExpressions) { Optional<GuardedByExpression> guard = GuardedByBinder.bindString(lockExpression, GuardedBySymbolResolver.from(tree, state)); if (!guard.isPresent()) { return Optional.absent(); }/*from w w w . j a v a 2 s.c o m*/ builder.add(guard.get()); } return Optional.of(builder.build()); }
From source file:io.mesosphere.mesos.util.ProtoUtils.java
@NotNull public static Optional<String> resourceValueRole(@NotNull final Optional<Resource> resource) { if (resource.isPresent()) { return Optional.of(resource.get().getRole()); } else {/* w w w .j a va 2 s .co m*/ return Optional.absent(); } }
From source file:io.mesosphere.mesos.util.ProtoUtils.java
@NotNull public static TreeSet<Long> resourceValueRange(@NotNull final Optional<Resource> resource) { if (resource.isPresent()) { return resourceValueRange(resource.get()); } else {//from w w w .ja v a2 s . c o m return newTreeSet(); } }
From source file:de.azapps.mirakel.model.tags.Tag.java
@NonNull public static Tag newTag(final String name, final boolean dark, final int color) { final Optional<Tag> t = getByName(name); if (t.isPresent()) { return t.get(); }// w w w. ja v a 2 s .com final ContentValues cv = new ContentValues(); cv.put(ModelBase.NAME, name); cv.put(DARK_TEXT, dark); cv.put(BACKGROUND_COLOR, color); final long id = insert(URI, cv); return get(id).get(); }
From source file:org.opendaylight.vpnservice.utilities.InterfaceUtils.java
public static String getEndpointIpAddressForDPN(DataBroker broker, BigInteger dpnId) { String nextHopIp = null;//from w w w. j av a 2s.c o m InstanceIdentifier<DPNTEPsInfo> tunnelInfoId = InstanceIdentifier.builder(DpnEndpoints.class) .child(DPNTEPsInfo.class, new DPNTEPsInfoKey(dpnId)).build(); Optional<DPNTEPsInfo> tunnelInfo = VpnUtil.read(broker, LogicalDatastoreType.CONFIGURATION, tunnelInfoId); if (tunnelInfo.isPresent()) { List<TunnelEndPoints> nexthopIpList = tunnelInfo.get().getTunnelEndPoints(); if (nexthopIpList != null && !nexthopIpList.isEmpty()) { nextHopIp = nexthopIpList.get(0).getIpAddress().getIpv4Address().getValue(); } } return nextHopIp; }
From source file:org.opendaylight.vpnservice.utilities.InterfaceUtils.java
public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface getInterfaceStateFromOperDS( DataBroker dataBroker, String interfaceName) { InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = buildStateInterfaceId( interfaceName);//w w w. j a v a 2 s.co m Optional<Interface> ifStateOptional = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, ifStateId); if (ifStateOptional.isPresent()) { return ifStateOptional.get(); } return null; }
From source file:org.opendaylight.netconf.mdsal.connector.MdsalNetconfOperationServiceFactory.java
static Set<Capability> transformCapabilities(final SchemaContext currentContext, final SchemaSourceProvider<YangTextSchemaSource> rootSchemaSourceProviderDependency) { final Set<Capability> capabilities = new HashSet<>(); // Added by netconf-impl by default // capabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0")); final Set<Module> modules = currentContext.getModules(); for (final Module module : modules) { Optional<YangModuleCapability> cap = moduleToCapability(module, rootSchemaSourceProviderDependency); if (cap.isPresent()) { capabilities.add(cap.get()); }/* w ww.j av a 2 s. c o m*/ for (final Module submodule : module.getSubmodules()) { cap = moduleToCapability(submodule, rootSchemaSourceProviderDependency); if (cap.isPresent()) { capabilities.add(cap.get()); } } } return capabilities; }
From source file:ec.nbdemetra.spreadsheet.SpreadsheetProviderBuddy.java
private static SpreadSheetCollection.AlignType getAlignType(DataSet dataSet) { Optional<SpreadSheetProvider> p = TsProviders.lookup(SpreadSheetProvider.class, SpreadSheetProvider.SOURCE); if (p.isPresent()) { try {/*from w w w .j av a2s . co m*/ return p.get().getSeries(dataSet).alignType; } catch (IOException ex) { // TODO: log this? } } return SpreadSheetCollection.AlignType.UNKNOWN; }