WebEx Pair Programming Feature

In a Webex meeting both Keyboard and Mouse can be shared.

Anyone can directly control what is on the screen in realtime.
I just tried it with a current customer and it is a tremendous feature:

Top Bar -> Assign+ -> “Pass Keyboard and Mouse Control”

Java equals and hash code Contract

If two objects are equal, the hash code must be the same.

But the same hash code does not guarantee that two objects are equal.

Code example for a proper implementation:

 @Override
    public final boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof MyClassOrInterface)) {
            //some do prefer #getClass but I don't
            return false;
        }
        MyClassOrInterface that = (MyClassOrInterface) o;
        return Objects.equals(this.hashCode(), that.hashCode()) &&
                Objects.equals(name, that.name) &&
                Objects.equals(sessionId, that.sessionId);
    }

    @Override
    public final int hashCode() {
        return Objects.hash(name, sessionId);
    }

Java – How to verify EQUALS and HASH code contracts

Use this:

<!-- Maven -->
<dependency>
    <groupId>nl.jqno.equalsverifier</groupId>
    <artifactId>equalsverifier</artifactId>
    <version>3.0.3</version>
    <scope>test</scope>
</dependency>

Write your test:

@Test
public void onEqualsTrueTheHashCodeHasToBeTheSame() {
    EqualsVerifier.forClass(Foo.class).verify();
}

How to solve Java List add – throwing java.lang.UnsupportedOperationException

Symptom:

You try to add an object to a list. But you get an Exception:

java.lang.UnsupportedOperationException
	at java.base/java.util.AbstractList.add(AbstractList.java:153)

Cause:

List<SomeEvent> eventList = Arrays.asList(event);
//not working, because the list size is fixed

Solution:

List<SomeEvent> eventList = new ArrayList<>(Arrays.asList(event));
//working, because the list size is NOT fixed

Of course, reading the Javadock of public static <T> List<T> asList(…) would have revealed it in advance:

/**
 * Returns a fixed-size list backed by the specified array.

;-D