List of usage examples for com.google.common.base Optional of
public static <T> Optional<T> of(T reference)
From source file:com.querydsl.sql.namemapping.PreConfiguredNameMapping.java
public Optional<SchemaAndTable> getOverride(SchemaAndTable key) { if (!schemaTables.isEmpty() && key.getSchema() != null) { if (schemaTables.containsKey(key)) { return Optional.of(schemaTables.get(key)); }/*from ww w .ja v a 2 s . co m*/ } if (tables.containsKey(key.getTable())) { String table = tables.get(key.getTable()); return Optional.of(new SchemaAndTable(key.getSchema(), table)); } return Optional.absent(); }
From source file:org.jboss.aerogear.controller.router.rest.pagination.Links.java
public Links(final RequestPathParser requestPathParser, final PaginationProperties paging) { first = requestPathParser.replace(0, paging.limit()); next = requestPathParser.replace(paging.nextOffset(), paging.limit()); previous = requestPathParser.replace(paging.previousOffset(), paging.limit()); last = paging.total().isPresent()//w ww. j av a2 s.co m ? Optional.of(requestPathParser.replace(paging.total().get() - paging.limit(), paging.limit())) : Optional.<String>absent(); }
From source file:gobblin.runtime.scheduler.DefaultJobSpecSchedulerListenerImpl.java
public DefaultJobSpecSchedulerListenerImpl(Logger log) { this(Optional.of(log)); }
From source file:org.apache.aurora.scheduler.quota.QuotaCheckResult.java
static QuotaCheckResult greaterOrEqual(ResourceBag a, ResourceBag b) { StringBuilder details = new StringBuilder(); ResourceBag difference = a.subtract(b); difference.filter(IS_NEGATIVE).streamResourceVectors() .forEach(entry -> addMessage(entry.getKey(), Math.abs(entry.getValue()), details)); return new QuotaCheckResult(details.length() > 0 ? Result.INSUFFICIENT_QUOTA : Result.SUFFICIENT_QUOTA, Optional.of(details.toString())); }
From source file:com.facebook.buck.android.ApkGenruleBuilder.java
public ApkGenruleBuilder setCmdExe(String cmdExe) { arg.cmdExe = Optional.of(cmdExe); return this; }
From source file:se.sics.ktoolbox.netmngr.ipsolver.IpSolver.java
/** * @param prefferedIp/*from w w w. ja va 2 s .c o m*/ * @param netInterfaces - order of types is important as it will check for ips in order of preferrence * @return * @throws SocketException */ public static Optional<InetAddress> getIp(Optional<String> prefferedIp, List<IpSolve.NetworkInterfacesMask> netInterfaces) throws SocketException { Pair<Integer, InetAddress> result = Pair.with(netInterfaces.size(), null); Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces(); while (nis.hasMoreElements()) { NetworkInterface ni = nis.nextElement(); if (ni.isVirtual()) { continue; } for (InterfaceAddress ifaceAddr : ni.getInterfaceAddresses()) { InetAddress addr = ifaceAddr.getAddress(); if (addr instanceof Inet6Address) { continue; // ignore ipv6 addresses } if (prefferedIp.isPresent() && addr.getHostAddress().equals(prefferedIp.get())) { return Optional.of(addr); } for (int i = 0; i < result.getValue0(); i++) { if (IpHelper.isType(addr, netInterfaces.get(i))) { result = Pair.with(i, addr); break; } } } } return Optional.fromNullable(result.getValue1()); }
From source file:gobblin.data.management.policy.SelectAfterTimeBasedPolicy.java
public SelectAfterTimeBasedPolicy(Config conf) { super(Optional.<Period>absent(), Optional.of(getMaxLookbackTime(conf))); }
From source file:org.opendaylight.controller.config.facade.xml.mapping.config.ModuleConfig.java
public Element toXml(ObjectName instanceON, Document document, String namespace, final EnumResolver enumResolver) { final Optional<String> configNs = Optional .of(XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG); Element root = XmlUtil.createElement(document, XmlMappingConstants.MODULE_KEY, configNs); // type belongs to config.yang namespace, but needs to be <type prefix:moduleNS>prefix:moduleName</type> Element typeElement = XmlUtil.createTextElementWithNamespacedContent(document, XmlMappingConstants.TYPE_KEY, XmlMappingConstants.PREFIX, namespace, moduleName, configNs); root.appendChild(typeElement);/*from w w w .jav a2 s . c om*/ // name belongs to config.yang namespace String instanceName = ObjectNameUtil.getInstanceName(instanceON); Element nameElement = XmlUtil.createTextElement(document, XmlMappingConstants.NAME_KEY, instanceName, configNs); root.appendChild(nameElement); root = instanceConfig.toXml(instanceON, namespace, document, root, enumResolver); return root; }
From source file:org.mayocat.shop.payment.AbstractGatewayFactory.java
/** * @return this gateway global (server-level) configuration file * * @param fileName the name of the file to retrieve *//* www . j a v a 2 s . co m*/ protected Optional<File> getTenantConfigurationFile(String fileName) { if (this.context.getTenant() == null) { return Optional.absent(); } return Optional.of(filesSettings.getPermanentDirectory().resolve(TENANTS_DIRECTORY) .resolve(this.context.getTenant().getSlug()).resolve(PAYMENTS_DIRECTORY).resolve(this.getId()) .resolve(fileName).toFile()); }
From source file:net.revelc.code.blazon.types.strings.StringType.java
@Override protected Optional<String> convert(final String normalized) { return Optional.of(normalized); }