Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Frequency.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Increments the frequency count for v.
 * <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.
 * @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(Comparable<?> v, long increment) throws MathIllegalArgumentException {
    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(increment));
        } else {
            freqTable.put(obj, Long.valueOf(count.longValue() + 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());
    }
}
 
Example 2
Source File: Frequency.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds 1 to the frequency count for v.
 * <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 MathIllegalArgumentException if <code>v</code> is not comparable with previous entries
 */
public void addValue(Comparable<?> v) throws MathIllegalArgumentException {
    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());
    }
}
 
Example 3
Source File: Frequency.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds 1 to the frequency count for v.
 * <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());
    }
}
 
Example 4
Source File: Frequency.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Increments the frequency count for v.
 * <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.
 * @param increment the amount by which the value should be incremented
 * @throws IllegalArgumentException if <code>v</code> is not comparable with previous entries
 * @since 3.1
 */
public void incrementValue(Comparable<?> v, long increment){
    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(increment));
        } else {
            freqTable.put(obj, Long.valueOf(count.longValue() + 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());
    }
}
 
Example 5
Source File: Frequency.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds 1 to the frequency count for v.
 * <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());
    }
}
 
Example 6
Source File: Frequency.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Increments the frequency count for v.
 * <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.
 * @param increment the amount by which the value should be incremented
 * @throws IllegalArgumentException if <code>v</code> is not comparable with previous entries
 * @since 3.1
 */
public void incrementValue(Comparable<?> v, long increment){
    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(increment));
        } else {
            freqTable.put(obj, Long.valueOf(count.longValue() + 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());
    }
}
 
Example 7
Source File: Frequency.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Increments the frequency count for v.
 * <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.
 * @param increment the amount by which the value should be incremented
 * @throws IllegalArgumentException if <code>v</code> is not comparable with previous entries
 * @since 3.1
 */
public void incrementValue(Comparable<?> v, long increment){
    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(increment));
        } else {
            freqTable.put(obj, Long.valueOf(count.longValue() + 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());
    }
}
 
Example 8
Source File: Frequency.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Increments the frequency count for v.
 * <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.
 * @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(Comparable<?> v, long increment) throws MathIllegalArgumentException {
    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(increment));
        } else {
            freqTable.put(obj, Long.valueOf(count.longValue() + 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());
    }
}