List of usage examples for com.google.common.base Optional of
public static <T> Optional<T> of(T reference)
From source file:com.epam.ta.reportportal.core.widget.content.GadgetTypes.java
public static Optional<GadgetTypes> findByName(@Nullable String name) { if (null == name) { return Optional.absent(); }//from ww w . j av a2s .com for (GadgetTypes gadgetType : GadgetTypes.values()) { if (gadgetType.getType().equals(name)) { return Optional.of(gadgetType); } } return Optional.absent(); }
From source file:org.automagic.deps.doctor.DependenciesDoctor.java
@SuppressWarnings("unchecked") public Optional<List<TransitiveDependency>> getAntidote() { List<TransitiveDepsGroup> transitiveDepsGroups = pomSpy.getTransitiveDepsGroups(); List<TransitiveDepsGroup> conflictingDepsGroups = getConflictingDepsGroups(transitiveDepsGroups); if (conflictingDepsGroups.isEmpty()) { return Optional.absent(); }/*from w w w . j a v a 2 s. c om*/ List<TransitiveDependency> list = new ArrayList<>(); Optional<List<TransitiveDependency>> antidote = Optional.of(list); for (TransitiveDepsGroup group : conflictingDepsGroups) { // search the dependency with the highest version in the group TransitiveDependency antidoteDep = group.getDependencies().get(0); for (TransitiveDependency dependency : group.getDependencies()) { if (dependency.getVersion().compareTo(antidoteDep.getVersion()) > 0) { antidoteDep = dependency; } } list.add(antidoteDep); } return antidote; }
From source file:se.sics.sweep.webservice.toolbox.Result.java
public static Result badRequest(String reason) { return new Result(Status.BAD_REQUEST, Optional.of(reason), Optional.absent()); }
From source file:com.android.camera.one.v2.Camera2OneCameraManagerImpl.java
/** * Create a new camera2 api hardware manager. *//* w w w. ja v a2 s . c om*/ public static Optional<Camera2OneCameraManagerImpl> create() { if (!ApiHelper.HAS_CAMERA_2_API) { return Optional.absent(); } CameraManager cameraManager; try { cameraManager = AndroidServices.instance().provideCameraManager(); } catch (IllegalStateException ex) { Log.e(TAG, "camera2.CameraManager is not available."); return Optional.absent(); } Camera2OneCameraManagerImpl hardwareManager = new Camera2OneCameraManagerImpl(cameraManager); return Optional.of(hardwareManager); }
From source file:at.ac.univie.isc.asio.d2rq.D2rqTools.java
/** * Find a single resource with given rdf:type in the model if one is present. * * @param model model to search in/*from ww w . j av a 2s.c om*/ * @param type type of required resource * @return the resource if present * @throws IllegalArgumentException if multiple resources with matching type are found */ static Optional<Resource> findSingleOfType(final Model model, final Resource type) { final ResIterator it = model.listResourcesWithProperty(RDF.type, type); final Optional<Resource> found = it.hasNext() ? Optional.of(it.nextResource()) : Optional.<Resource>absent(); if (found.isPresent() && it.hasNext()) { throw new IllegalArgumentException("found multiple <" + type + "> resources"); } return found; }
From source file:de.flapdoodle.logparser.io.StringListReaderAdapter.java
@Override public synchronized Optional<String> nextLine() throws IOException { if (_idx < _lines.size()) { String line = _lines.get(_idx); _idx++;/* www .j a v a 2 s .com*/ return Optional.of(line); } return Optional.absent(); }
From source file:org.opendaylight.restconf.jersey.providers.AbstractIdentifierAwareJaxRsProvider.java
protected InstanceIdentifierContext<?> getInstanceIdentifierContext() { return ParserIdentifier.toInstanceIdentifier(getIdentifier(), ControllerContext.getInstance().getGlobalSchema(), Optional.of(RestConnectorProvider.getMountPointService())); }
From source file:org.opendaylight.yangtools.yang.data.impl.schema.tree.OrderedMapModificationStrategy.java
OrderedMapModificationStrategy(final ListSchemaNode schema, final DataTreeConfiguration treeConfig) { super(OrderedMapNode.class, treeConfig); entryStrategy = Optional.of(new ListEntryModificationStrategy(schema, treeConfig)); }
From source file:org.locationtech.geogig.plumbing.CommitFromDateOp.java
@Override protected Optional<RevCommit> _call() { Preconditions.checkState(date != null); long time = date.getTime(); Iterator<RevCommit> iter = command(LogOp.class).setFirstParentOnly(true).call(); while (iter.hasNext()) { RevCommit commit = iter.next();//from w ww . j a v a 2 s .c o m if (commit.getCommitter().getTimestamp() < time) { return Optional.of(commit); } } return Optional.absent(); }
From source file:dattln.auth.LdapAuthenticator.java
public Optional<User> authenticate(BasicCredentials basicCredentials) throws AuthenticationException { if (delegatingAuthenticator.authenticate(basicCredentials)) { return Optional.of(new User(basicCredentials.getUsername())); }// www . ja v a 2s. c o m return Optional.absent(); }