MCPcopy Create free account
hub / github.com/w3c/epubcheck / tryFind

Method tryFind

src/main/java/com/adobe/epubcheck/opf/MetadataSet.java:260–276  ·  view source on GitHub ↗

Search all the given expressions and return the first one that matches the given property and value (if present). If value is Optional#absent() , only the property is used in the lookup. @param metas A list of metadata expressions to search @param property

(List<Metadata> metas, final Property property,
      final Optional<String> value)

Source from the content-addressed store, hash-verified

258 * {@link Optional#absent()} if none is found.
259 */
260 public static Optional<Metadata> tryFind(List<Metadata> metas, final Property property,
261 final Optional<String> value)
262 {
263 Preconditions.checkNotNull(metas);
264 Preconditions.checkNotNull(property);
265 Preconditions.checkNotNull(value);
266 return Iterables.tryFind(metas, new Predicate<Metadata>()
267 {
268
269 @Override
270 public boolean apply(Metadata meta)
271 {
272 return property.equals(meta.getProperty())
273 && (!value.isPresent() || value.get().equals(meta.getValue()));
274 }
275 });
276 }
277
278 /**
279 * Represents a metadata expression.

Callers 5

applyMethod · 0.95
reportMetadataMethod · 0.95
tryFindInRefinesMethod · 0.80
checkMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected