List of usage examples for org.apache.commons.math3.exception.util LocalizedFormats INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES
LocalizedFormats INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES
To view the source code for org.apache.commons.math3.exception.util LocalizedFormats INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES.
Click Source Link
From source file:com.github.gerbsen.math.Frequency.java
/** * Adds 1 to the frequency count for v.// w ww . ja v a 2s. c om * <p> * If other objects have already been added to this Frequency, v must * be comparable to those that have already been added. * </p> * * @param v the value to add. * @throws IllegalArgumentException if <code>v</code> is not comparable with previous entries */ public void addValue(Comparable<?> v) { Comparable<?> obj = v; if (v instanceof Integer) { obj = Long.valueOf(((Integer) v).longValue()); } try { Long count = freqTable.get(obj); if (count == null) { freqTable.put(obj, Long.valueOf(1)); } else { freqTable.put(obj, Long.valueOf(count.longValue() + 1)); } } catch (ClassCastException ex) { //TreeMap will throw ClassCastException if v is not comparable throw new MathIllegalArgumentException(LocalizedFormats.INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES, v.getClass().getName()); } }
From source file:com.juliazozulia.wordusage.Utils.Frequency.java
/** * Increments the frequency count for v. * <p>// w w w .j av a 2 s. c o m * If other objects have already been added to this Frequency, v must * be comparable to those that have already been added. * </p> * * @param v the value to add. * @param increment the amount by which the value should be incremented * @throws MathIllegalArgumentException if <code>v</code> is not comparable with previous entries * @since 3.1 */ public void incrementValue(String v, Integer increment) throws MathIllegalArgumentException { String obj = v; try { Integer count = freqTable.get(obj); if (count == null) { freqTable.put(obj, Integer.valueOf(increment)); } else { freqTable.put(obj, Integer.valueOf(count + increment)); } } catch (ClassCastException ex) { //TreeMap will throw ClassCastException if v is not comparable throw new MathIllegalArgumentException(LocalizedFormats.INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES, v.getClass().getName()); } }