本文整理了Java中org.opencastproject.util.data.Option.map()
方法的一些代码示例,展示了Option.map()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.map()
方法的具体详情如下:
包路径:org.opencastproject.util.data.Option
类名称:Option
方法名:map
暂无
代码示例来源:origin: opencast/opencast
@Override
public Option<C> apply(A a) {
return f.apply(a).map(g);
}
};
代码示例来源:origin: opencast/opencast
/**
* Get an optional JSON object.
*
* @deprecated
*/
public Option<JsonObj> optObj(String key) {
return opt(Map.class, key).map(jsonObj);
}
}
代码示例来源:origin: opencast/opencast
/**
* Find a single object.
*
* @param params
* the query parameters
* @param toA
* map to the desired result object
* @deprecated
*/
@Deprecated
public static <A, B> Option<A> find(EntityManager em, final Function<B, A> toA, final String queryName,
final Tuple<String, ?>... params) {
return PersistenceUtil.<B> runSingleResultQuery(em, queryName, params).map(toA);
}
代码示例来源:origin: opencast/opencast
/**
* Returns an expression to search for any date that lies in between <code>startDate</code> and <code>endDate</code>.
*
* @param startDate
* the start date or none for an infinite left endpoint, "*" in solr query syntax
* @param endDate
* the end date or none for an infinite right endpoint, "*" in solr query syntax
* @return the serialized search expression
*/
public static String serializeDateRange(Option<Date> startDate, Option<Date> endDate) {
final Function<Date, String> f = format(newSolrDateFormat());
return new StringBuilder("[")
.append(startDate.map(f).getOrElse("*"))
.append(" TO ")
.append(endDate.map(f).getOrElse("*"))
.append("]")
.toString();
}
代码示例来源:origin: opencast/opencast
@Override
public Option<String> apply(MediaPackageElement mediaPackageElement) {
return option(mediaPackageElement.getReference()).map(getReferenceId);
}
};
代码示例来源:origin: opencast/opencast
/** Evaluate the xpath expression against the contained document. The expression must return a list of strings (text). */
// todo replace return type with Valid once it is implemented
public List<String> strings(String expr) {
final List<String> list = new ArrayList<String>();
return nodeSet(expr).map(new Function<NodeList, List<String>>() {
@Override
public List<String> apply(NodeList nodes) {
for (int i = 0; i < nodes.getLength(); i++) {
list.add(nodes.item(i).getNodeValue());
}
return list;
}
}).getOrElse(list);
}
}
代码示例来源:origin: opencast/opencast
/**
* OSGI activate method.
*
* @param cc
* OSGI component context
**/
public void activate(ComponentContext cc) {
acceptJobLoadsExeedingMaxLoad = getOptContextProperty(cc, ACCEPT_JOB_LOADS_EXCEEDING_PROPERTY).map(Strings.toBool)
.getOrElse(DEFAULT_ACCEPT_JOB_LOADS_EXCEEDING);
}
代码示例来源:origin: opencast/opencast
/**
* Get an optional boolean from a dictionary.
*/
public static Option<Boolean> getOptCfgAsBoolean(Dictionary d, String key) {
return option(d.get(key)).bind(Strings.asString()).map(Strings.toBool);
}
代码示例来源:origin: opencast/opencast
acceptJobLoadsExeedingMaxLoad = getOptContextProperty(cc, ACCEPT_JOB_LOADS_EXCEEDING_PROPERTY).map(Strings.toBool)
.getOrElse(DEFAULT_ACCEPT_JOB_LOADS_EXCEEDING);
代码示例来源:origin: opencast/opencast
@Override
public Jsons.Obj apply(BundleVersion version) {
return obj(p("version", version.getBundleVersion()), p("buildNumber", version.getBuildNumber().map(stringVal)));
}
};
代码示例来源:origin: opencast/opencast
case Analyze:
audioTrack = (TrackImpl) MediaPackageElementParser.getFromXml(arguments.get(0));
serialized = analyze(job, audioTrack).map(MediaPackageElementParser.<Track> getAsXml()).getOrElse("");
break;
case Normalize:
audioTrack = (TrackImpl) MediaPackageElementParser.getFromXml(arguments.get(0));
Float targetRmsLevDb = new Float(arguments.get(1));
serialized = normalize(job, audioTrack, targetRmsLevDb).map(MediaPackageElementParser.<Track> getAsXml())
.getOrElse("");
break;
代码示例来源:origin: opencast/opencast
/**
* {@inheritDoc}
*
* @see org.opencastproject.metadata.api.MetadataService#getMetadata(org.opencastproject.mediapackage.MediaPackage)
*/
@Override
public StaticMetadata getMetadata(final MediaPackage mp) {
return mlist(list(mp.getCatalogs(DublinCoreCatalog.ANY_DUBLINCORE)))
.find(flavorPredicate(MediaPackageElements.EPISODE))
.flatMap(loader)
.map(new Function<DublinCoreCatalog, StaticMetadata>() {
@Override
public StaticMetadata apply(DublinCoreCatalog episode) {
return newStaticMetadataFromEpisode(episode);
}
})
.getOrElse((StaticMetadata) null);
}
代码示例来源:origin: opencast/opencast
@Override
public IncidentL10n getLocalization(long id, Locale locale) throws IncidentServiceException, NotFoundException {
final Incident incident = getIncident(id);
final List<String> loc = localeToList(locale);
// check if cache map is empty
// fill cache from
final String title = findText(loc, incident.getCode(), FIELD_TITLE).getOrElse(NO_TITLE);
final String description = findText(loc, incident.getCode(), FIELD_DESCRIPTION).map(
replaceVarsF(incident.getDescriptionParameters())).getOrElse(NO_DESCRIPTION);
return new IncidentL10n() {
@Override
public String getTitle() {
return title;
}
@Override
public String getDescription() {
return description;
}
};
}
代码示例来源:origin: opencast/opencast
private static StaticMetadata newStaticMetadataFromEpisode(DublinCoreCatalog episode) {
final Option<Date> created = option(episode.getFirst(PROPERTY_CREATED)).map(new Function<String, Date>() {
@Override
public Date apply(String a) {
final Option temporalOpt = option(episode.getFirstVal(PROPERTY_TEMPORAL)).map(dc2temporalValueOption());
final Option<Date> start;
if (episode.getFirst(PROPERTY_TEMPORAL) != null) {
final Option<Long> extent = head(episode.get(PROPERTY_EXTENT)).map(new Function<DublinCoreValue, Long>() {
@Override
public Long apply(DublinCoreValue a) {
内容来源于网络,如有侵权,请联系作者删除!