@Override
    public int compareTo(Resource other) {
        checkArgument(other != null && getClass() == other.getClass() && name.equals(other.name));
        return value.compareTo(other.value);
    }
@Test
    void testCompareToFailDifferentName() {
        // initialized as different anonymous classes
        final Resource resource1 = new TestResource("name1", 0.0);
        final Resource resource2 = new TestResource("name2", 0.0);
        assertThatThrownBy(() -> resource1.compareTo(resource2))
                .isInstanceOf(IllegalArgumentException.class);
    }