List of usage examples for com.google.common.base Optional of
public static <T> Optional<T> of(T reference)
From source file:org.deephacks.confit.spi.CacheManager.java
/** * Lookup the most suitable CacheManager available. * * @return CacheManager./* ww w .jav a 2 s . co m*/ */ public static Optional<CacheManager> lookup() { CacheManager manager = lookup.lookup(CacheManager.class); if (manager != null) { return Optional.of(manager); } else { return Optional.absent(); } }
From source file:com.kegare.friendlymobs.util.Version.java
private static void initialize() { CURRENT = Optional.of(Strings.nullToEmpty(FriendlyMobs.metadata.version)); LATEST = Optional.fromNullable(CURRENT.orNull()); File file = FriendlyUtils.getModContainer().getSource(); if (file != null && file.exists()) { if (file.isFile()) { if (StringUtils.endsWithIgnoreCase(FilenameUtils.getBaseName(file.getName()), "dev")) { DEV_DEBUG = true;/*from w ww . ja v a2s . c om*/ } } else { DEV_DEBUG = true; } } else if (!FMLForgePlugin.RUNTIME_DEOBF) { DEV_DEBUG = true; } if (StringUtils.endsWithIgnoreCase(getCurrent(), "dev")) { DEV_DEBUG = true; } else if (DEV_DEBUG) { FriendlyMobs.metadata.version += "-dev"; } }
From source file:li.klass.fhem.domain.MAXMode.java
public static Optional<MAXMode> modeFor(String value) { if (NumberUtil.isDecimalNumber(value)) { int mode = ValueExtractUtil.extractLeadingInt(value); switch (mode) { case 0://from w ww . j av a2 s . co m return Optional.of(MAXMode.AUTO); case 1: return Optional.of(MAXMode.MANUAL); case 2: return Optional.of(MAXMode.TEMPORARY); case 3: return Optional.of(MAXMode.BOOST); default: throw new IllegalArgumentException("don't know how to handle heating mode " + mode); } } else { try { return Optional.of(MAXMode.valueOf(value.toUpperCase(Locale.getDefault()))); } catch (Exception e) { Log.e(MAXMode.class.getName(), "cannot set heating mode from value " + value, e); return Optional.absent(); } } }
From source file:it.kytech.bowwarfare.utils.LogHelper.java
public static Optional<LogHelper> getInstance() { return (instance == null) ? Optional.<LogHelper>absent() : Optional.of(instance); }
From source file:org.geogit.api.hooks.Hookables.java
/** * Returns the filename to be used for a script corresponding to the hook for a given GeoGit * operation. Returns {@link Optional.absent} if the specified operation does not allows hooks * /* w ww . jav a 2 s . c o m*/ * @param class the operation * @return the string to be used as filename for storing the script files for the corresponding * hook */ public static Optional<String> getFilename(Class<? extends AbstractGeoGitOp> clazz) { Hookable annotation = clazz.getAnnotation(Hookable.class); if (annotation != null) { return Optional.of(annotation.name()); } else { return Optional.absent(); } }
From source file:org.eclipse.buildship.ui.view.task.FaultyProjectNode.java
public FaultyProjectNode(IProject project) { super(Optional.of(project)); }
From source file:com.kegare.caveworld.util.Version.java
private static void initialize() { CURRENT = Optional.of(Strings.nullToEmpty(Caveworld.metadata.version)); LATEST = Optional.fromNullable(CURRENT.orNull()); ModContainer mod = CaveUtils.getModContainer(); File file = mod == null ? null : mod.getSource(); if (file != null && file.exists()) { if (file.isFile()) { String name = FilenameUtils.getBaseName(file.getName()); if (StringUtils.endsWithIgnoreCase(name, "dev")) { DEV_DEBUG = true;/*from w w w. ja va 2 s. com*/ } } else if (file.isDirectory()) { DEV_DEBUG = true; } } else if (!FMLForgePlugin.RUNTIME_DEOBF) { DEV_DEBUG = true; } if (Caveworld.metadata.version.endsWith("dev")) { DEV_DEBUG = true; } else if (DEV_DEBUG) { Caveworld.metadata.version += "-dev"; } }
From source file:org.apache.james.mailbox.model.MailboxAnnotation.java
public static MailboxAnnotation newInstance(MailboxAnnotationKey key, String value) { return new MailboxAnnotation(key, Optional.of(value)); }
From source file:ca.loganspeck.cortex.ViewingRule.java
public static Optional<ViewingRule> fromString(String name) { ViewingRule viewingRule = null;//from ww w .ja v a 2 s.c o m for (ViewingRule rstr : values()) { if (rstr.toString().equalsIgnoreCase(name)) { viewingRule = rstr; break; } } return Optional.of(viewingRule); }
From source file:eu.europa.ec.grow.espd.domain.enums.criteria.CriteriaList.java
public static Optional<CcvCriterion> findById(String uuid) { if (CRITERIA.get(uuid) != null) { return Optional.of(CRITERIA.get(uuid)); }// w w w . ja va 2s. co m return Optional.absent(); }