/** * Merge another Frequency object's counts into this instance. * This Frequency's counts will be incremented (or set when not already set) * by the counts represented by other. * * @param other the other {@link Frequency} object to be merged * @throws NullArgumentException if {@code other} is null * @since 3.1 */ public void merge(final Frequency other) throws NullArgumentException { MathUtils.checkNotNull(other, LocalizedFormats.NULL_NOT_ALLOWED); final Iterator<Map.Entry<Comparable<?>, Long>> iter = other.entrySetIterator(); while (iter.hasNext()) { final Map.Entry<Comparable<?>, Long> entry = iter.next(); incrementValue(entry.getKey(), entry.getValue().longValue()); } }
public static String getMostLikelyFailedConstraintName(Frequency failedConstraintNamesFrequency) { if (failedConstraintNamesFrequency == null || failedConstraintNamesFrequency.getUniqueCount() == 0) return NO_REASON; Iterator<Map.Entry<Comparable<?>, Long>> entryIterator = failedConstraintNamesFrequency.entrySetIterator(); long maxCount = 0; String mostLikely = null; while (entryIterator.hasNext()) { Map.Entry<Comparable<?>, Long> entry = entryIterator.next(); if (entry.getValue() > maxCount) { Comparable<?> key = entry.getKey(); maxCount = entry.getValue(); mostLikely = key.toString(); } } return mostLikely; }
private String getMostLikely(Frequency reasons) { if (reasons == null) return "no reason found"; Iterator<Map.Entry<Comparable<?>, Long>> entryIterator = reasons.entrySetIterator(); int maxCount = 0; String mostLikely = null; while (entryIterator.hasNext()) { Map.Entry<Comparable<?>, Long> entry = entryIterator.next(); if (entry.getValue() > maxCount) { Comparable<?> key = entry.getKey(); mostLikely = key.toString(); } } return mostLikely; }
/** * Merge another Frequency object's counts into this instance. * This Frequency's counts will be incremented (or set when not already set) * by the counts represented by other. * * @param other the other {@link Frequency} object to be merged * @throws NullArgumentException if {@code other} is null * @since 3.1 */ public void merge(final Frequency other) throws NullArgumentException { MathUtils.checkNotNull(other, LocalizedFormats.NULL_NOT_ALLOWED); final Iterator<Map.Entry<Comparable<?>, Long>> iter = other.entrySetIterator(); while (iter.hasNext()) { final Map.Entry<Comparable<?>, Long> entry = iter.next(); incrementValue(entry.getKey(), entry.getValue().longValue()); } }
/** * Merge another Frequency object's counts into this instance. * This Frequency's counts will be incremented (or set when not already set) * by the counts represented by other. * * @param other the other {@link Frequency} object to be merged * @throws NullArgumentException if {@code other} is null * @since 3.1 */ public void merge(final Frequency other) throws NullArgumentException { MathUtils.checkNotNull(other, LocalizedFormats.NULL_NOT_ALLOWED); final Iterator<Map.Entry<Comparable<?>, Long>> iter = other.entrySetIterator(); while (iter.hasNext()) { final Map.Entry<Comparable<?>, Long> entry = iter.next(); incrementValue(entry.getKey(), entry.getValue().longValue()); } }