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)
| 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. |
no outgoing calls
no test coverage detected