com.merkle.oss.magnolia.powernode.predicate.HasPropertyValue Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of magnolia-powernode Show documentation
Show all versions of magnolia-powernode Show documentation
compiles and bundles generated and base classes
package com.merkle.oss.magnolia.powernode.predicate;
import com.merkle.oss.magnolia.powernode.AbstractPowerNode;
import com.merkle.oss.magnolia.powernode.PropertyService;
import java.util.Locale;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Predicate;
public class HasPropertyValue, T> implements Predicate {
private final Function> provider;
private final T value;
public HasPropertyValue(final String propertyName, final PropertyService.PropertyProvider provider, final T value) {
this.value = value;
this.provider = n -> n.getProperty(propertyName, provider);
}
public HasPropertyValue(final String propertyName, final Locale locale, final PropertyService.PropertyProvider provider, final T value) {
this.value = value;
this.provider = n -> n.getProperty(propertyName, locale, provider);
}
@Override
public boolean test(final N n) {
return provider.apply(n).map(value::equals).orElse(false);
}
}