Ignore:
Timestamp:
11/28/19 14:40:48 (5 years ago)
Author:
bart
Message:

Release 1.1.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • profile/src/main/java/geniusweb/profile/utilityspace/DiscreteValueSetUtilities.java

    r1 r9  
    88import com.fasterxml.jackson.annotation.JsonAutoDetect;
    99import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
     10import com.fasterxml.jackson.annotation.JsonTypeName;
    1011
    1112import geniusweb.issuevalue.DiscreteValue;
     
    1314import geniusweb.issuevalue.Value;
    1415import geniusweb.issuevalue.ValueSet;
    15 
    16 import com.fasterxml.jackson.annotation.JsonTypeName;
    1716
    1817/**
     
    3736         * create new object based on the given mapping from values to utilities.
    3837         *
    39          * @param valueUtils map with key {@link DiscreteValue}s and value a Double in
    40          *                   the range [0,1].
     38         * @param valueUtils map with key {@link DiscreteValue}s and value a Double
     39         *                   in the range [0,1].
    4140         * @throws NullPointerException     if one of the args is null
    4241         * @throws IllegalArgumentException if values are not in range [0,1].
    4342         */
    44         public DiscreteValueSetUtilities(Map<DiscreteValue, BigDecimal> valueUtils) {
     43        public DiscreteValueSetUtilities(
     44                        Map<DiscreteValue, BigDecimal> valueUtils) {
    4545                if (valueUtils == null) {
    4646                        throw new NullPointerException("valueUtils==null");
    4747                }
    4848                if (valueUtils.keySet().contains(null)) {
    49                         throw new NullPointerException("one of the keys in valueUtils is null");
     49                        throw new NullPointerException(
     50                                        "one of the keys in valueUtils is null");
    5051                }
    5152                if (valueUtils.values().stream()
    52                                 .anyMatch(v -> v == null || v.compareTo(BigDecimal.ZERO) < 0 || v.compareTo(BigDecimal.ONE) > 0)) {
    53                         throw new IllegalArgumentException("Weights in valueUtils must all be in [0,1]");
     53                                .anyMatch(v -> v == null || v.compareTo(BigDecimal.ZERO) < 0
     54                                                || v.compareTo(BigDecimal.ONE) > 0)) {
     55                        throw new IllegalArgumentException(
     56                                        "Weights in valueUtils must all be in [0,1]");
    5457                }
    5558                this.valueUtilities.putAll(valueUtils);
     
    6871        public String isFitting(ValueSet valueset) {
    6972                if (!(valueset instanceof DiscreteValueSet)) {
    70                         return "The utilities are for a discrete valueset but the given values are " + valueset;
     73                        return "The utilities are for a discrete valueset but the given values are "
     74                                        + valueset;
    7175                }
    7276                DiscreteValueSet discvalueset = (DiscreteValueSet) valueset;
    73                 if (!valueUtilities.keySet().equals(new HashSet<>(discvalueset.getValues())))
    74                         return "The values in the set " + valueset + " do not match the values mapped to utilities "
     77                if (!valueUtilities.keySet()
     78                                .equals(new HashSet<>(discvalueset.getValues())))
     79                        return "The values in the set " + valueset
     80                                        + " do not match the values mapped to utilities "
    7581                                        + valueUtilities.keySet();
    7682                return null;
     
    7985        @Override
    8086        public String toString() {
    81                 return "ValueSetUtilities" + valueUtilities;
     87                return "DiscreteValueSetUtilities" + valueUtilities;
    8288        }
    8389
     
    8692                final int prime = 31;
    8793                int result = 1;
    88                 result = prime * result + ((valueUtilities == null) ? 0 : valueUtilities.hashCode());
     94                result = prime * result
     95                                + ((valueUtilities == null) ? 0 : valueUtilities.hashCode());
    8996                return result;
    9097        }
Note: See TracChangeset for help on using the changeset viewer.