List of usage examples for com.google.common.base Optional of
public static <T> Optional<T> of(T reference)
From source file:org.opendaylight.controller.cluster.schema.provider.impl.YangTextSchemaSourceSerializationProxy.java
public YangTextSchemaSource getRepresentation() { return YangTextSchemaSource.delegateForByteSource( RevisionSourceIdentifier.create(name, Optional.of(revision)), ByteSource.wrap(schemaSource)); }
From source file:fi.vm.sade.osoitepalvelu.kooste.common.util.CriteriaHelper.java
public static Optional<Criteria> inParentOids(Criteria c, String key, Collection<String> parentOids) { if (parentOids == null || parentOids.isEmpty()) { return Optional.absent(); }//w w w . j a v a 2s . co m Criteria[] criteria = new Criteria[parentOids.size()]; int i = 0; for (String oid : parentOids) { criteria[i++] = Criteria.where(key).regex(Pattern.compile("\\|" + oid + "\\|")); } return Optional.of(c.orOperator(criteria)); }
From source file:org.search.niem.uml.papyrus.editors.readonly.ReferenceSubsetElementHandler.java
@Override public Optional<Boolean> isReadOnly(final EObject eObject) { if (Activator.getPlugin().getPreferenceStore().getBoolean( PreferenceConstants.P_RESTRICT_NIEM_SUBSET_CONTENT) && isInReferenceLibrarySubset(eObject)) { return Optional.of(true); }//from w w w. jav a 2 s .c om return Optional.<Boolean>absent(); }
From source file:qa.qcri.nadeef.core.datamodel.NadeefConfiguration.java
private static void initialize() throws Exception { dbConfig = new DBConfig.Builder().url(properties.getProperty("database.url")) .username(properties.getProperty("database.username")) .password(properties.getProperty("database.password")) .dialect(SQLDialectTools.getSQLDialect(properties.getProperty("database.type", "database.derby"))) .build();/*from w w w. jav a2 s . c om*/ if (properties.containsKey("general.fixdecisionmaker")) { String className = properties.getProperty("general.fixdecisionmaker"); Class customizedClass = CommonTools.loadClass(className); decisionMakerClass = Optional.of(customizedClass); } else decisionMakerClass = Optional.absent(); if (properties.containsKey("general.outputPath")) { String outputPathString = properties.getProperty("general.outputPath"); File tmpPath = new File(outputPathString); if (tmpPath.exists() && tmpPath.isDirectory()) outputPath = tmpPath.toPath(); else { String userDir = System.getProperty("user.dir"); tracer.info(String.format("Cannot find directory %s, we use %s as default.", outputPathString, userDir)); outputPath = new File(outputPathString).toPath(); } } Enumeration<?> enumeration = properties.propertyNames(); while (enumeration.hasMoreElements()) { String property = (String) enumeration.nextElement(); if (property.startsWith("ruleext.")) { String key = property.substring("ruleext.".length()); String builderClassName = properties.getProperty(property); Class builderClass = CommonTools.loadClass(builderClassName); @SuppressWarnings("unchecked") RuleBuilder writer = (RuleBuilder) (builderClass.getConstructor().newInstance()); ruleExtension.put(key, writer); } } }
From source file:org.eclipse.mylyn.internal.wikitext.commonmark.inlines.PotentialEmphasisSpan.java
@Override public Optional<? extends Inline> createInline(Cursor cursor) { char c = cursor.getChar(); if ((c == '_' || c == '*') && !currentPositionIsEscaped(cursor)) { int length = lengthMatching(cursor, c); boolean leftFlanking = isLeftFlanking(cursor, length); boolean rightFlanking = isRightFlanking(cursor, length); boolean canOpen = leftFlanking; boolean canClose = rightFlanking; if (c == '_') { canOpen = leftFlanking && (!rightFlanking || isPunctuation(charBefore(cursor))); canClose = rightFlanking && (!leftFlanking || isPunctuation(charAfter(cursor, length))); }//ww w . j a v a 2 s. co m return Optional.of(new PotentialEmphasisDelimiter(cursor.getLineAtOffset(), cursor.getOffset(), length, cursor.getTextAtOffset(length), canOpen, canClose)); } return Optional.absent(); }
From source file:com.google.gerrit.server.git.RepoRefCache.java
@Override public Optional<ObjectId> get(String refName) throws IOException { Optional<ObjectId> id = ids.get(refName); if (id != null) { return id; }/*from w w w .j a va2 s .c o m*/ Ref ref = refdb.exactRef(refName); id = ref != null ? Optional.of(ref.getObjectId()) : Optional.<ObjectId>absent(); ids.put(refName, id); return id; }
From source file:com.facebook.buck.java.JavaLibraryBuilder.java
public JavaLibraryBuilder addAllAnnotationProcessors(List<String> processorNames) { arg.annotationProcessors = Optional.of(ImmutableSet.copyOf(processorNames)); return this; }
From source file:org.cebolla.repositories.AbstractFakeRepositoryWithSimpleLookup.java
/** * Find an entity with the given key in the repository * /* w w w . java 2 s .c o m*/ * @return an @see com.google.common.base.Optional of the entity, if found. Otherwise Optional.absent() */ public Optional<EntityType> lookup(Key key) { keysLookedUp.add(key); for (EntityType entity : filter(new KeyMatchPredicate(key))) { return Optional.of(entity); } return Optional.absent(); }
From source file:org.anhonesteffort.flock.registration.model.FlockCardInformation.java
public static Optional<FlockCardInformation> build(Bundle bundledCardInformation) { if (bundledCardInformation == null || bundledCardInformation.getString(KEY_ACCOUNT_ID) == null) return Optional.absent(); return Optional.of(new FlockCardInformation(bundledCardInformation.getString(KEY_ACCOUNT_ID), bundledCardInformation.getString(KEY_LAST_FOUR), bundledCardInformation.getString(KEY_EXPIRATION))); }
From source file:org.splevo.jamopp.refactoring.java.caslicensehandler.cheatsheet.actions.JaMoPPRoutines.java
/** * Returns the concrete classifier (JaMoPP) for the given type (JavaCore). * // ww w . ja va 2 s . co m * @param type * represents the type. * @return the matched classifier. */ public static Optional<ConcreteClassifier> getConcreteClassifierOf(IType type) { ResourceSet resourceSet = ((JaMoPPJavaSoftwareElement) CASLicenseHandlerConfiguration.getInstance() .getVariationPoint().getLocation()).getJamoppElement().eResource().getResourceSet(); final String typeName = type.getElementName(); URI resourceURI = URI.createPlatformResourceURI(type.getResource().getFullPath().toString(), true); Resource r = resourceSet.getResource(resourceURI, true); for (CompilationUnit cu : Iterables.filter(r.getContents(), CompilationUnit.class)) { LinkedList<ConcreteClassifier> queue = Lists.newLinkedList(cu.getClassifiers()); while (!queue.isEmpty()) { ConcreteClassifier classifier = queue.pop(); if (typeName.equals(classifier.getName())) { return Optional.of(classifier); } } } return Optional.absent(); }