All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.merkle.oss.magnolia.powernode.predicate.HasPropertyValue Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
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);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy