List of usage examples for com.google.common.base Optional fromNullable
public static <T> Optional<T> fromNullable(@Nullable T nullableReference)
From source file:springfox.bean.validators.plugins.BeanValidators.java
public static <T extends Annotation> Optional<T> validatorFromField(ModelPropertyContext context, Class<T> annotationType) { Optional<AnnotatedElement> annotatedElement = context.getAnnotatedElement(); Optional<T> notNull = Optional.absent(); if (annotatedElement.isPresent()) { notNull = Optional.fromNullable(annotatedElement.get().getAnnotation(annotationType)); }//from ww w. j a va 2 s .c o m return notNull; }
From source file:ph.devcon.android.speaker.fragment.PanelOnlyFragment.java
@Override public void onResume() { super.onResume(); FetchedPanelSpeakerListEvent event = eventBus.getStickyEvent(FetchedPanelSpeakerListEvent.class); Optional<FetchedPanelSpeakerListEvent> eventOptional = Optional.fromNullable(event); if (eventOptional.isPresent()) { setSpeakerList(eventOptional.get().speakers); }/* ww w . ja v a 2 s.co m*/ }
From source file:ratpack.exec.internal.DefaultExecController.java
public static Optional<ExecController> getThreadBoundController() { return Optional.fromNullable(THREAD_BINDING.get()); }
From source file:com.vino.repositories.DomainRepository.java
public Optional<WineDomain> getDomainByKey(String key) { return Optional .fromNullable(collections.from(EntityType.DOMAIN).findOne(new ObjectId(key)).as(WineDomain.class)); }
From source file:org.sonar.server.computation.qualityprofile.ActiveRulesHolderRule.java
@Override public Optional<ActiveRule> get(RuleKey ruleKey) { return Optional.fromNullable(activeRulesByKey.get(ruleKey)); }
From source file:com.addthis.hydra.job.web.jersey.OptionalExtractor.java
@Override public Object extract(MultivaluedMap<String, String> parameters) { return Optional.fromNullable(extractor.extract(parameters)); }
From source file:com.facebook.swift.parser.model.Service.java
public Service(String name, String parent, List<ThriftMethod> methods) { this.name = checkNotNull(name, "name"); this.parent = Optional.fromNullable(parent); this.methods = ImmutableList.copyOf(checkNotNull(methods, "methods")); }
From source file:org.sonar.server.computation.task.projectanalysis.qualitygate.QualityGateHolderRule.java
public void setQualityGate(@Nullable QualityGate qualityGate) { this.qualityGate = Optional.fromNullable(qualityGate); }
From source file:org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeSnapshotDao.java
public Optional<FlowCapableNode> loadByNodeId(@Nonnull NodeId nodeId) { final FlowCapableNode node = cache.get(nodeId.getValue()); return Optional.fromNullable(node); }
From source file:net.revelc.code.blazon.types.AbstractTrimmedType.java
@Override protected Optional<String> checkPreconditions(final Optional<String> raw) { String result = null;/* w w w . j a v a2s .c o m*/ if (raw.isPresent()) { result = raw.get().trim(); } return Optional.fromNullable((result == null || result.isEmpty()) ? null : result); }