/** * Get a (typed) parameter value only if parameter is present, has a not <code>null</code> value, and its value * satisfies given <code>condition</code>. This method uses a {@link ConfigProperty} to represent parameter name and * type. * @param <T> Parameter value type * @param property ConfigProperty to get (not null) * @param condition Condition to check (not null) * @return Parameter value, or an empty Optional if parameter is not present, or has not a value or its value does * not satisfy given <code>condition</code> */ default <T> Optional<T> getParameterIf(ConfigProperty<T> property, Predicate<T> condition) { ObjectUtils.argumentNotNull(property, "ConfigProperty must be not null"); return getParameterIf(property.getKey(), property.getType(), condition); }
return stringValue.map(v -> presentationParameters.getParameterIf(MAX_LENGTH, ml -> ml > 0) .map(ml -> FormatUtils.limit(v, ml, true)).orElse(v)).orElse(null);
parameters.getParameterIf(DISABLE_GROUPING, v -> v) .ifPresent(v -> features.add(NumberFormatFeature.DISABLE_GROUPING)); parameters.getParameterIf(HIDE_DECIMALS_WHEN_ALL_ZERO, v -> v) .ifPresent(v -> features.add(NumberFormatFeature.HIDE_DECIMALS_WHEN_ALL_ZERO)); parameters.getParameterIf(PERCENT_STYLE, v -> v) .ifPresent(v -> features.add(NumberFormatFeature.PERCENT_STYLE));