/** * Check if a parameter is present using given {@link ConfigProperty} property key. <code>null</code> parameter * values are allowed, so if a parameter is present it doesn't means that it has a value. * @param <T> Parameter value type * @param property ConfigProperty to check (not null) * @return <code>true</code> if parameter is present, <code>false</code> otherwise */ default <T> boolean hasParameter(ConfigProperty<T> property) { ObjectUtils.argumentNotNull(property, "ConfigProperty must be not null"); return hasParameter(property.getKey()); }
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[] }
/** * Get the {@link PropertyBoxSerializationMode} to use. Check {@link PropertyBox} configuration attributes using * {@link JsonConfigProperties#PROPERTYBOX_SERIALIZATION_MODE}. If not available, the construction time value is * used. * @param propertyBox The PropertBox to serialize * @return The {@link PropertyBoxSerializationMode} to use */ private PropertyBoxSerializationMode getPropertyBoxSerializationMode(PropertyBox propertyBox) { // check config parameter if (propertyBox.getConfiguration().hasParameter(JsonConfigProperties.PROPERTYBOX_SERIALIZATION_MODE)) { return propertyBox.getConfiguration().getParameter(JsonConfigProperties.PROPERTYBOX_SERIALIZATION_MODE, PropertyBoxSerializationMode.getDefault()); } return propertyBoxSerializationMode; }