[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] brooklyn-server pull request #982: Improve coercions esp with generics

Github user aledsage commented on a diff in the pull request:

    --- Diff: core/src/main/java/org/apache/brooklyn/core/config/ConfigConstraints.java ---
    @@ -149,19 +153,28 @@ public ConfigConstraints(T brooklynObject) {
             return violating;
    -    @SuppressWarnings("unchecked")
         <V> boolean isValueValid(ConfigKey<V> configKey, V value) {
    +        return !checkValueValid(configKey, value).hasError();
    +    }
    +    /** returns reference to null without error if valid; otherwise returns reference to predicate and a good error message */
    +    @SuppressWarnings("unchecked")
    +    <V> ReferenceWithError<Predicate<?>> checkValueValid(ConfigKey<V> configKey, V value) {
    --- End diff --
    Naming convention in guava is that `checkXyz` methods will throw an exception if the check fails (e.g. https://google.github.io/guava/releases/19.0/api/docs/com/google/common/base/Preconditions.html). I'd prefer the name `validateValue(...)`.