List of usage examples for com.google.common.base Optional fromNullable
public static <T> Optional<T> fromNullable(@Nullable T nullableReference)
From source file:org.opentestsystem.delivery.logging.EventInfo.java
/** * @return Moment in time of the event, such as the entry, exit or error *///from ww w.j a v a 2 s . c om public Optional<String> checkpoint() { return Optional.fromNullable(checkpoint); }
From source file:com.facebook.buck.d.DBinaryBuilder.java
public DBinaryBuilder setDeps(ImmutableSortedSet<BuildTarget> deps) { arg.deps = Optional.fromNullable(deps); return this; }
From source file:com.qcadoo.mes.assignmentToShift.dataProviders.AssignmentToShiftCriteria.java
public AssignmentToShiftCriteria withCriteria(final SearchCriterion assignmentCriteria) { this.criteria = Optional.fromNullable(assignmentCriteria); return this; }
From source file:net.es.nsi.pce.pf.PfUtils.java
public static String getDestinationStpOrFail(P2PServiceBaseType p2ps) { Optional<String> destStp = Optional.fromNullable(Strings.emptyToNull(p2ps.getDestSTP())); if (destStp.isPresent()) { return destStp.get(); }//from w w w .j a va2s .c o m throw Exceptions.missingParameter(Point2PointTypes.getSourceStp().getNamespace(), Point2PointTypes.getDestStp().getType(), "null"); }
From source file:ch.acanda.eclipse.pmd.domain.WorkspaceModel.java
/** * Returns the project model for a project with the specified name. * * @param name The name of the project ({@code IProject.getName()}). * @return The project model if it was previously added otherwise {@code Optional#absent()}. *///from ww w . j a v a2 s .c om public Optional<ProjectModel> getProject(final String name) { return Optional.fromNullable(projects.get(name)); }
From source file:org.opendaylight.controller.filtervalve.cors.jaxb.Context.java
public synchronized void initialize(String fileName, Map<String, Filter> namesToTemplates) { checkState(initialized == false, "Already initialized"); Map<String, Filter> namesToFilters = new HashMap<>(); for (Filter filter : filters) { try {/*from w ww. j a va2s. c o m*/ filter.initialize(fileName, Optional.fromNullable(namesToTemplates.get(filter.getFilterName()))); } catch (Exception e) { throw new IllegalStateException( format("Error while processing filter %s of context %s, defined in %s", filter.getFilterName(), path, fileName), e); } namesToFilters.put(filter.getFilterName(), filter); } filters = Collections.unmodifiableList(new ArrayList<>(filters)); LinkedHashMap<String, Filter> patternMap = new LinkedHashMap<>(); for (FilterMapping filterMapping : filterMappings) { filterMapping.initialize(); Filter found = namesToFilters.get(filterMapping.getFilterName()); if (found != null) { patternMap.put(filterMapping.getUrlPattern(), found); } else { logger.error("Cannot find matching filter for filter-mapping {} of context {}, defined in {}", filterMapping.getFilterName(), path, fileName); throw new IllegalStateException( format("Cannot find filter for filter-mapping %s of context %s, defined in %s", filterMapping.getFilterName(), path, fileName)); } } filterMappings = Collections.unmodifiableList(new ArrayList<>(filterMappings)); urlMatcher = new UrlMatcher<>(patternMap); initialized = true; }
From source file:org.eclipse.epp.internal.logging.aeri.ui.notifications.Notification.java
public Optional<NotificationPopup> getPopup() { return Optional.fromNullable(popup); }
From source file:com.dangdang.ddframe.rdb.sharding.parser.result.router.ConditionContext.java
/** * ?./*from w w w . ja va2s . co m*/ * * @param table ?? * @param column ?? * @return ? */ public Optional<Condition> find(final String table, final String column) { return Optional.fromNullable(conditions.get(new Column(column, table))); }
From source file:im.dadoo.teak.biz.bo.impl.DefaultArchiveBO.java
@Override public Optional<ArchivePO> insert(String title, String author, String html, String thumbnailPath, long categoryId) { long publishDatetime = System.currentTimeMillis(); int click = 0; String text = Jsoup.parse(html).text(); ArchivePO archivePO = new ArchivePO(); archivePO.setTitle(title);//from w w w . j ava2 s . co m archivePO.setAuthor(author); archivePO.setHtml(html); archivePO.setText(text); archivePO.setPublishDatetime(publishDatetime); archivePO.setClick(click); archivePO.setThumbnailPath(thumbnailPath); archivePO.setCategoryId(categoryId); return Optional.fromNullable(this.archiveDAO.insert(archivePO)); }
From source file:org.apache.rya.indexing.pcj.fluo.app.query.StatementPatternIdManager.java
/** * Add specified Set of ids to the Fluo table with Column {@link FluoQueryColumns#STATEMENT_PATTERN_IDS}. Also * updates the hash of the updated nodeId Set and writes that to the Column * {@link FluoQueryColumns#STATEMENT_PATTERN_IDS_HASH} * * @param tx - Fluo Transaction object for performing atomic operations on Fluo table. * @param ids - ids to add to the StatementPattern nodeId Set */// w w w . j a v a 2 s . c o m public static void addStatementPatternIds(TransactionBase tx, Set<String> ids) { checkNotNull(tx); checkNotNull(ids); Optional<Bytes> val = Optional.fromNullable(tx.get(Bytes.of(STATEMENT_PATTERN_ID), STATEMENT_PATTERN_IDS)); StringBuilder builder = new StringBuilder(); if (val.isPresent()) { builder.append(val.get().toString()); builder.append(VAR_DELIM); } String idString = builder.append(Joiner.on(VAR_DELIM).join(ids)).toString(); tx.set(Bytes.of(STATEMENT_PATTERN_ID), STATEMENT_PATTERN_IDS, Bytes.of(idString)); tx.set(Bytes.of(STATEMENT_PATTERN_ID), STATEMENT_PATTERN_IDS_HASH, Bytes.of(Hashing.sha256().hashString(idString).toString())); }