/** * Compares this mutable to another in ascending order. * * @param obj the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater */ public int compareTo(Object obj) { MutableFloat other = (MutableFloat) obj; float anotherVal = other.value; return NumberUtils.compare(value, anotherVal); }
/** * Compares this mutable to another in ascending order. * * @param obj the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater * @throws ClassCastException if the argument is not a MutableDouble */ public int compareTo(Object obj) { MutableDouble other = (MutableDouble) obj; double anotherVal = other.value; return NumberUtils.compare(value, anotherVal); }
/** * <p>Appends to the <code>builder</code> the comparison of * two <code>double</code>s.</p> * * <p>This handles NaNs, Infinities, and <code>-0.0</code>.</p> * * <p>It is compatible with the hash code generated by * <code>HashCodeBuilder</code>.</p> * * @param lhs left-hand value * @param rhs right-hand value * @return this - used to chain append calls */ public CompareToBuilder append(double lhs, double rhs) { if (comparison != 0) { return this; } comparison = NumberUtils.compare(lhs, rhs); return this; }
/** * <p>Appends to the <code>builder</code> the comparison of * two <code>float</code>s.</p> * * <p>This handles NaNs, Infinities, and <code>-0.0</code>.</p> * * <p>It is compatible with the hash code generated by * <code>HashCodeBuilder</code>.</p> * * @param lhs left-hand value * @param rhs right-hand value * @return this - used to chain append calls */ public CompareToBuilder append(float lhs, float rhs) { if (comparison != 0) { return this; } comparison = NumberUtils.compare(lhs, rhs); return this; }
/** * <p>Tests whether the specified <code>double</code> occurs within * this range using <code>double</code> comparison.</p> * * <p>This implementation uses the {@link #getMinimumDouble()} and * {@link #getMaximumDouble()} methods and should be good for most uses.</p> * * @param value the double to test * @return <code>true</code> if the specified number occurs within this * range by <code>double</code> comparison */ public boolean containsDouble(double value) { int compareMin = NumberUtils.compare(getMinimumDouble(), value); int compareMax = NumberUtils.compare(getMaximumDouble(), value); return compareMin <= 0 && compareMax >= 0; }
/** * <p>Tests whether the specified <code>float</code> occurs within * this range using <code>float</code> comparison.</p> * * <p>This implementation uses the {@link #getMinimumFloat()} and * {@link #getMaximumFloat()} methods and should be good for most uses.</p> * * @param value the float to test * @return <code>true</code> if the specified number occurs within this * range by <code>float</code> comparison */ public boolean containsFloat(float value) { int compareMin = NumberUtils.compare(getMinimumFloat(), value); int compareMax = NumberUtils.compare(getMaximumFloat(), value); return compareMin <= 0 && compareMax >= 0; }
@Override public int compare(SupervisorInfo o1, SupervisorInfo o2) { return -NumberUtils.compare( o1.getAvailableWorkerPorts().size(), o2.getAvailableWorkerPorts().size()); }
@Override public int compare(SupervisorInfo o1, SupervisorInfo o2) { return -NumberUtils.compare( o1.getAvailableWorkerPorts().size(), o2.getAvailableWorkerPorts().size()); }
@VisibleForTesting static Measure dtoToMeasure(CustomMeasureDto dto, Metric metric) { switch (metric.getType()) { case INT: case RATING: return Measure.newMeasureBuilder().create((int) dto.getValue()); case MILLISEC: case WORK_DUR: return Measure.newMeasureBuilder().create((long) dto.getValue()); case FLOAT: case PERCENT: return Measure.newMeasureBuilder().create(dto.getValue(), metric.getDecimalScale()); case BOOL: return Measure.newMeasureBuilder().create(NumberUtils.compare(dto.getValue(), 1.0) == 0); case LEVEL: return Measure.newMeasureBuilder().create(Measure.Level.valueOf(dto.getTextValue())); case STRING: case DISTRIB: case DATA: String textValue = dto.getTextValue(); if (textValue == null) { return Measure.newMeasureBuilder().createNoValue(); } return Measure.newMeasureBuilder().create(textValue); default: throw new IllegalArgumentException(String.format("Custom measures do not support the metric type [%s]", metric.getType())); } }
/** * Compares this mutable to another in ascending order. * * @param obj the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater * @throws ClassCastException if the argument is not a MutableDouble */ public int compareTo(Object obj) { MutableDouble other = (MutableDouble) obj; double anotherVal = other.value; return NumberUtils.compare(value, anotherVal); }
/** * Compares this mutable to another in ascending order. * * @param obj the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater */ public int compareTo(Object obj) { MutableFloat other = (MutableFloat) obj; float anotherVal = other.value; return NumberUtils.compare(value, anotherVal); }
/** * Compares this mutable to another in ascending order. * * @param obj the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater * @throws ClassCastException if the argument is not a MutableDouble */ public int compareTo(Object obj) { MutableDouble other = (MutableDouble) obj; double anotherVal = other.value; return NumberUtils.compare(value, anotherVal); }
private static boolean isZeroVariation(Double... variations) { for (Double variation : variations) { if (!((variation == null) || NumberUtils.compare(variation, 0.0) == 0)) { return false; } } return true; }
/** * {@inheritDoc} */ public int compareTo(final Entry other) { return NumberUtils.compare(lastAccess_, other.lastAccess_); }
/** * Compares this mutable to another in ascending order. * * @param obj the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater */ public int compareTo(Object obj) { MutableFloat other = (MutableFloat) obj; float anotherVal = other.value; return NumberUtils.compare(value, anotherVal); }
/** * Compares this mutable to another in ascending order. * * @param obj the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater * @throws ClassCastException if the argument is not a MutableDouble */ public int compareTo(Object obj) { MutableDouble other = (MutableDouble) obj; double anotherVal = other.value; return NumberUtils.compare(value, anotherVal); }
/** * Compares this mutable to another in ascending order. * * @param obj the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater * @throws ClassCastException if the argument is not a MutableDouble */ public int compareTo(Object obj) { MutableDouble other = (MutableDouble) obj; double anotherVal = other.value; return NumberUtils.compare(value, anotherVal); }
/** * Compares this mutable to another in ascending order. * * @param obj the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater * @throws ClassCastException if the argument is not a MutableDouble */ public int compareTo(Object obj) { MutableDouble other = (MutableDouble) obj; double anotherVal = other.value; return NumberUtils.compare(value, anotherVal); }
/** * @since 3.2 */ public boolean isBestValue() { Double bestValue = metric.getBestValue(); return metric.isOptimizedBestValue() == Boolean.TRUE && bestValue != null && (value == null || NumberUtils.compare(bestValue, value) == 0) && allNull(alertStatus, description, tendency, url, data) && isZeroVariation(variation1, variation2, variation3, variation4, variation5); }