List of usage examples for com.google.common.base Optional of
public static <T> Optional<T> of(T reference)
From source file:com.google.errorprone.bugpatterns.CheckReturnValue.java
private static Optional<Boolean> shouldCheckReturnValue(Symbol sym, VisitorState state) { if (hasAnnotation(sym, CanIgnoreReturnValue.class, state)) { return Optional.of(false); }// w w w . j a v a2 s . co m if (hasDirectAnnotationWithSimpleName(sym, CHECK_RETURN_VALUE)) { return Optional.of(true); } return Optional.absent(); }
From source file:edu.buaa.satla.analysis.cfa.model.AStatementEdge.java
@Override public Optional<? extends IAStatement> getRawAST() { return Optional.of(statement); }
From source file:net.revelc.code.blazon.types.numeric.IntegerRangeType.java
@Override protected Optional<Integer> checkPostconditions(final Integer value) { if (!range.contains(value)) { throw new IllegalArgumentException(value + " is not in the range " + range.toString()); }/*w w w .j a v a2s . c o m*/ return Optional.of(value); }
From source file:org.sosy_lab.cpachecker.cfa.model.c.CDeclarationEdge.java
@Override public Optional<CDeclaration> getRawAST() { return Optional.of((CDeclaration) declaration); }
From source file:controllers.ApiController.java
public Result getCatchAllOther(Context ctx) { Result result = Results.json(); Optional<Result> optResult = Optional.of(result); return result.render(new Error(msg.get("error.catchAll", ctx, optResult).get())); }
From source file:com.github.javarch.jsf.mbeans.AbstractUpdateManagedBean.java
/** * Carrega o uma entidade "Entidade" baseada id. Utilizado inicialmente no <f:event> aps * capturar o id no f:viewParam//from w ww .j av a 2 s . co m * @return */ @SuppressWarnings("all") public String loadAfterSetViewParamId() { LOG.debug("calling loadAfterSetViewParamId on object {}", entity); if (!entity.isNew()) { T entityLoaded = (T) repository.findOne(getGenericType(), entity.getId()); if (!Optional.of(entityLoaded).isPresent()) { LOG.debug("Entity with {} not found in database. Invoking handleEntityNotFound()", entity); handleEntityNotFound(); } LOG.debug("Entity {} found. Validating entity with isValidUseEntity()", entityLoaded); if (!isValidUseEntity(entityLoaded)) { handleInvalidEntity(entityLoaded); } setEntity(entityLoaded); } return ""; }
From source file:org.sosy_lab.cpachecker.cfa.model.java.JDeclarationEdge.java
@Override public Optional<JDeclaration> getRawAST() { return Optional.of((JDeclaration) declaration); }
From source file:se.sics.ktoolbox.util.proxy.SystemHookSetup.java
public synchronized <HR extends Hook.Required> Optional<String> missingHook(HR[] requiredHooks) { for (HR requiredHook : requiredHooks) { if (!hooks.containsKey(requiredHook.toString())) { return Optional.of(requiredHook.toString()); }/* w w w .j av a 2 s.co m*/ } return Optional.absent(); }
From source file:com.forerunnergames.tools.common.Result.java
public static <V, R extends Result<V>> Optional<R> firstFailedFrom(final Iterable<R> results) { Arguments.checkIsNotNull(results, "results"); Arguments.checkHasNoNullElements(results, "results"); for (final R result : results) { if (result.failed()) return Optional.of(result); }/*from w ww . j a v a 2s . com*/ return Optional.absent(); }
From source file:org.mayocat.addons.StringAddonTransformer.java
public Optional<AddonFieldValueWebObject> toWebView(EntityData<?> entityData, AddonFieldDefinition addonField, Object fieldValue) {//from www . j a va2 s .c om if (isListWithKeyAndDisplayValues(addonField)) { List<Map<String, Object>> listValues = getListValues(addonField); Object displayValue = null; for (Map<String, Object> entry : listValues) { if (entry.containsKey("key") && fieldValue != null && entry.get("key").equals(fieldValue.toString())) { displayValue = entry.get("name"); break; } } return Optional.of(new AddonFieldValueWebObject(fieldValue, displayValue == null ? emptyToNull(fieldValue) : displayValue)); } else { return Optional.of(new AddonFieldValueWebObject(emptyToNull(fieldValue), emptyToNull(fieldValue))); } }