List of usage examples for com.google.common.base Optional isPresent
public abstract boolean isPresent();
From source file:de.flapdoodle.java2pandoc.parser.BlockToTypedBlockConverter.java
@Nonnull @VisibleForTesting/*from w w w .j a v a 2 s. com*/ protected static TypedBlock guessTypedBlock(Block block) { Optional<Block> unpackedComment = unpackComment(block); if (unpackedComment.isPresent()) { return new TypedBlock(TypedBlock.Type.Text, unpackedComment.get()); } return new TypedBlock(TypedBlock.Type.Code, block); }
From source file:org.opendaylight.faas.fabric.utils.InterfaceManager.java
@SuppressWarnings("unchecked") public static InstanceIdentifier<TerminationPoint> convDevPort2FabricPort(DataBroker broker, FabricId fabricid, InstanceIdentifier<TerminationPoint> tpIid) { ReadTransaction rt = broker.newReadOnlyTransaction(); Optional<TerminationPoint> opt = MdSalUtils.syncReadOper(rt, tpIid); if (opt.isPresent()) { TerminationPoint tp = opt.get(); return (InstanceIdentifier<TerminationPoint>) tp.getAugmentation(FabricPortAug.class).getPortRef() .getValue();/* w w w. j a va2s. c o m*/ } return null; }
From source file:org.apache.rya.indexing.pcj.fluo.app.export.ParametersBase.java
protected static boolean getBoolean(final Map<String, String> params, final String paramName, final boolean defaultValue) { checkNotNull(params);//from w w w . ja v a 2 s .co m checkNotNull(paramName); final Optional<String> paramValue = Optional.fromNullable(params.get(paramName)); return paramValue.isPresent() ? Boolean.parseBoolean(paramValue.get()) : defaultValue; }
From source file:org.eclipse.buildship.core.workspace.internal.OutputLocationUpdater.java
public static void update(IJavaProject project, Optional<OmniEclipseOutputLocation> outputLocation, IProgressMonitor monitor) throws CoreException { if (outputLocation.isPresent()) { IPath projectPath = project.getProject().getFullPath(); String outputPath = outputLocation.get().getPath(); project.setOutputLocation(projectPath.append(outputPath), monitor); }//from w ww. ja va2 s . com }
From source file:gobblin.data.management.copy.watermark.CopyableFileWatermarkHelper.java
/** * Return Optional {@link WatermarkInterval} for {@link CopyableFile} using {@link CopyableFileWatermarkGenerator}. *//*from w ww .j a v a2s . co m*/ public static Optional<WatermarkInterval> getCopyableFileWatermark(CopyableFile copyableFile, Optional<CopyableFileWatermarkGenerator> watermarkGenerator) throws IOException { if (!watermarkGenerator.isPresent()) { return Optional.absent(); } return watermarkGenerator.get().generateWatermarkIntervalForCopyableFile(copyableFile); }
From source file:com.jivesoftware.sdk.utils.DateTimeUtils.java
public static String dateToIso(Optional<Date> date) { if (!date.isPresent()) { return null; }/* ww w . j ava2s.c om*/ try { return fullISODate.format(date.get()); } catch (Exception e) { log.info("Failed converting date to ISO date string: " + date, e); return null; } }
From source file:org.opendaylight.unimgr.mef.nrp.common.MountPointHelper.java
/** * Find a node's NETCONF mount point and then retrieve its DataBroker. * e.g.//from w w w.j a v a 2 s .c om * http://localhost:8080/restconf/config/network-topology:network-topology/ * topology/topology-netconf/node/{nodeName}/yang-ext:mount/ */ public static Optional<DataBroker> getDataBroker(MountPointService mountService, String nodeName) { NodeId nodeId = new NodeId(nodeName); InstanceIdentifier<Node> nodeInstanceId = InstanceIdentifier.builder(NetworkTopology.class) .child(Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName()))) .child(Node.class, new NodeKey(nodeId)).build(); final Optional<MountPoint> nodeOptional = mountService.getMountPoint(nodeInstanceId); if (!nodeOptional.isPresent()) { return Optional.absent(); } MountPoint nodeMountPoint = nodeOptional.get(); return Optional.of(nodeMountPoint.getService(DataBroker.class).get()); }
From source file:ch.epfl.eagle.daemon.util.ConfigUtil.java
/** * Parses the list of backends from a {@link Configuration}. * * Returns a map of address of backends to a {@link TResourceVector} describing the * total resource capacity for that backend. *///from w ww .j ava 2 s . co m public static Set<InetSocketAddress> parseBackends(Configuration conf) { if (!conf.containsKey(EagleConf.STATIC_NODE_MONITORS)) { throw new RuntimeException("Missing configuration node monitor list"); } Set<InetSocketAddress> backends = new HashSet<InetSocketAddress>(); for (String node : conf.getStringArray(EagleConf.STATIC_NODE_MONITORS)) { Optional<InetSocketAddress> addr = Serialization.strToSocket(node); if (!addr.isPresent()) { LOG.warn("Bad backend address: " + node); continue; } backends.add(addr.get()); } return backends; }
From source file:ec.nbdemetra.jdbc.OpenJndiJdbcDataSource.java
static void preFillBean(JdbcBean bean, Node node) { Optional<DatabaseConnection> dbConn = findConnection(node); if (dbConn.isPresent()) { bean.setDbName(dbConn.get().getDisplayName()); }/*from ww w .ja v a2 s.c o m*/ if (isTableOrView(node)) { bean.setTableName(node.getName()); } }
From source file:org.jclouds.aliyun.ecs.domain.ResourceType.java
public static ResourceType fromValue(String value) { Optional<ResourceType> resourceType = Enums.getIfPresent(ResourceType.class, value.toUpperCase()); checkArgument(resourceType.isPresent(), "Expected one of %s but was %s", Joiner.on(',').join(ResourceType.values()), value); return resourceType.get(); }