MetricDescriptor extends AbstractRegisteredItem { @Override public boolean equals(Object other) { if (!super.equals(other)) return false; if (!(other instanceof MetricDescriptor)) return false; MetricDescriptor md = MetricDescriptor.class.cast(other); return Objects.deepEquals(label, md.label) && Objects.deepEquals(function, md.function) && Objects.deepEquals(unitLabel, md.unitLabel); } MetricDescriptor(String theId, String theLabel, Function<? extends Object, ? extends Object> theFunction, String aUnitLabel, String theDescription); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); final String label; final Function<? extends Object, ? extends Object> function; final String unitLabel; }
@Test public void equals() { MetricDescriptor md1 = new MetricDescriptor("beatFrequency", "Beat frequency", null, "Hz", "The interference resulting from the union of two signals"); MetricDescriptor md2 = new MetricDescriptor("beatFrequency", "Beat frequency", null, "Hz", "The interference resulting from the union of two signals"); assertEquals(md1, md2); md2 = new MetricDescriptor("beatFrequency", "Beat Frequency", null, "Hz", "The interference resulting from the union of two signals"); assertNotSame(md1, md2); }