List of usage examples for com.google.common.base Optional fromNullable
public static <T> Optional<T> fromNullable(@Nullable T nullableReference)
From source file:com.dangdang.ddframe.rdb.sharding.parser.result.router.Table.java
public Table(final String name, final String alias) { this(name, Optional.fromNullable(alias)); }
From source file:net.awairo.mcmod.spawnchecker.client.common.Refrection.java
/** * ??????????./*from w w w.j ava 2 s. c om*/ * * @return ??. */ public static Optional<InetSocketAddress> getServerAddress() { checkState(GAME.theWorld != null, "world is not started"); checkState(GAME.getIntegratedServer() == null, "current mode is the single player."); final NetHandlerPlayClient sendQueue = getFieldValue(WorldClient.class, GAME.theWorld, "sendQueue", ConstantsConfig.instance().sendQueueSrgName); if (sendQueue == null) return Optional.absent(); final NetworkManager netManager = sendQueue.getNetworkManager(); if (netManager.getSocketAddress() instanceof InetSocketAddress) return Optional.fromNullable((InetSocketAddress) netManager.getSocketAddress()); if (LOGGER.isDebugEnabled() && netManager.getSocketAddress() != null) LOGGER.debug(netManager.getSocketAddress().getClass().getName()); LOGGER.warn("not found InetSocketAddress"); return Optional.absent(); }
From source file:ph.devcon.android.speaker.fragment.AllSpeakerFragment.java
@Override public void onResume() { super.onResume(); FetchedAllSpeakerListEvent event = eventBus.getStickyEvent(FetchedAllSpeakerListEvent.class); Optional<FetchedAllSpeakerListEvent> eventOptional = Optional.fromNullable(event); if (eventOptional.isPresent()) { setSpeakerList(eventOptional.get().speakers); }/*www . j a va 2 s . co m*/ }
From source file:gobblin.converter.http.RestEntry.java
public RestEntry(String resourcePath, T restEntryVal) { this.resourcePath = Optional.fromNullable(resourcePath); this.restEntryVal = restEntryVal; }
From source file:ninja.utils.NinjaModeHelper.java
/** * returns an empty Optional<NinjaMode> if no mode is set. Or the valid mode * set via a System Property called "ninja.mode". * // w w w . ja va2 s .c o m * E.g. under mvn you can use mvn ... -Dninja.mode=prod or so. Valid values * for ninja.mode are "prod", "dev", "test". * * @return The valid mode set via a System Property called "ninja.mode" * or Optional absent if we cannot get one. */ public static Optional<NinjaMode> determineModeFromSystemProperties() { NinjaMode ninjaMode = null; // Get mode possibly set via a system property String modeFromGetSystemProperty = System.getProperty(NinjaConstant.MODE_KEY_NAME); // If the user specified a mode we set the mode accordingly: if (modeFromGetSystemProperty != null) { if (modeFromGetSystemProperty.equals(NinjaConstant.MODE_TEST)) { ninjaMode = NinjaMode.test; } else if (modeFromGetSystemProperty.equals(NinjaConstant.MODE_DEV)) { ninjaMode = NinjaMode.dev; } else if (modeFromGetSystemProperty.equals(NinjaConstant.MODE_PROD)) { ninjaMode = NinjaMode.prod; } } return Optional.fromNullable(ninjaMode); }
From source file:org.onos.yangtools.yang.data.api.schema.tree.spi.MaterializedContainerNode.java
@Override public Optional<TreeNode> getChild(final PathArgument key) { return Optional.fromNullable(children.get(key)); }
From source file:com.github.nethad.clustermeister.api.impl.ExecutorServiceMode.java
/** * Bundles Callables/Runnables and executes them after the given timeout. * @param timeout in milliseconds/*from w w w. ja v a 2 s . com*/ * @return */ public static ExecutorServiceMode timeConstraint(long timeout) { return new GenericExecutorServiceMode(Optional.fromNullable(timeout), Optional.<Integer>absent()); }
From source file:org.asoem.greyfish.utils.base.Memoizer.java
@Override public final T get() { if (!isValid(value)) { synchronized (this) { if (!isValid(value)) { T t = delegate().get();/*w w w . j a v a 2 s . c o m*/ value = Optional.fromNullable(t); loaded(t); return t; } } } return value.orNull(); }
From source file:org.locationtech.geogig.plumbing.diff.DiffSummary.java
public Optional<M> getMergedResult() { return Optional.fromNullable(merged); }
From source file:google.registry.keyring.api.KeyModule.java
@Provides @Key("marksdbLordnPassword") static Optional<String> provideMarksdbLordnPassword(Keyring keyring) { return Optional.fromNullable(emptyToNull(keyring.getMarksdbLordnPassword())); }