/** * Checks if a parameter named with given <code>property</code> key is present and its value is equal to given * <code>value</code>. * @param <T> Parameter value type * @param property Configuration property (not null) * @param value Parameter value to check (may be null) * @return <code>true</code> if the property is present and its value is equal to given <code>value</code>, * <code>false</code> if the property is not present or if its value it's not equal to the expected value */ default <T> boolean hasParameterValue(ConfigProperty<T> property, T value) { ObjectUtils.argumentNotNull(property, "ConfigProperty must be not null"); return hasParameterValue(property.getKey(), value); }
public void parameterSet() { // tag::params[] final ConfigProperty<String> property = ConfigProperty.create("test", String.class); ParameterSet set = ParameterSet.builder().withParameter("testParameter", 1L) // <1> .withParameter(property, "testValue") // <2> .build(); boolean present = set.hasParameter("testParameter"); // <3> present = set.hasNotNullParameter("testParameter"); // <4> Optional<String> value = set.getParameter("testParameter", String.class); // <5> String val = set.getParameter("testParameter", String.class, "default"); // <6> Optional<String> configPropertyValue = set.getParameter(property); // <7> String configPropertyVal = set.getParameter(property, "default"); // <8> boolean matches = set.hasParameterValue("testParameter", "myValue"); // <9> matches = set.hasParameterValue(property, "myValue"); // <10> // end::params[] }