/** * RangeDistributionBuilder for a defined range * Each entry is initialized at zero * * @param bottomLimits the bottom limits of ranges to be used */ public RangeDistributionBuilder(Number[] bottomLimits) { init(bottomLimits); }
/** * Adds an existing Distribution to the current one. * It will create the entries if they don't exist. * Can be used to add the values of children resources for example * <br> * The returned distribution will be invalidated in case the given value does not use the same bottom limits * * @param data the data to add to the current one */ public RangeDistributionBuilder add(String data) { Map<Double, Double> map = KeyValueFormat.parse(data, KeyValueFormat.newDoubleConverter(), KeyValueFormat.newDoubleConverter()); if (bottomLimits == null) { Number[] limits = map.keySet().toArray(new Number[map.size()]); init(limits); } else if (!areSameLimits(bottomLimits, map.keySet())) { isValid = false; } if (isValid) { for (Map.Entry<Double, Double> entry : map.entrySet()) { addLimitCount(entry.getKey(), entry.getValue().intValue()); } } return this; }
/** * RangeDistributionBuilder for a defined range * Each entry is initialized at zero * * @param bottomLimits the bottom limits of ranges to be used */ public RangeDistributionBuilder(Number[] bottomLimits) { init(bottomLimits); }
/** * Adds an existing Distribution to the current one. * It will create the entries if they don't exist. * Can be used to add the values of children resources for example * <br> * The returned distribution will be invalidated in case the given value does not use the same bottom limits * * @param data the data to add to the current one */ public RangeDistributionBuilder add(String data) { Map<Double, Double> map = KeyValueFormat.parse(data, KeyValueFormat.newDoubleConverter(), KeyValueFormat.newDoubleConverter()); if (bottomLimits == null) { Number[] limits = map.keySet().toArray(new Number[map.size()]); init(limits); } else if (!areSameLimits(bottomLimits, map.keySet())) { isValid = false; } if (isValid) { for (Map.Entry<Double, Double> entry : map.entrySet()) { addLimitCount(entry.getKey(), entry.getValue().intValue()); } } return this; }