Skip to content

Commit

Permalink
#286 Adds prefab value for PropetyChangeSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Mar 12, 2020
1 parent cddcc69 commit 83df3ee
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static nl.jqno.equalsverifier.internal.reflection.Util.objects;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.beans.PropertyChangeSupport;
import java.io.File;
import java.lang.reflect.*;
import java.math.BigDecimal;
Expand Down Expand Up @@ -498,6 +499,13 @@ private void addAncientJavaApiClasses() {
addLazyFactory("java.awt.color.ICC_Profile", AWT_FACTORY);
addLazyFactory("java.awt.Font", AWT_FACTORY);

addFactory(
PropertyChangeSupport.class,
values(
new PropertyChangeSupport("this"),
new PropertyChangeSupport("that"),
new PropertyChangeSupport("this")));

addLazyFactory("java.rmi.dgc.VMID", RMI_FACTORY);
addLazyFactory("java.rmi.server.UID", RMI_FACTORY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static nl.jqno.equalsverifier.testhelpers.Util.defaultEquals;
import static nl.jqno.equalsverifier.testhelpers.Util.defaultHashCode;

import java.beans.PropertyChangeSupport;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -100,6 +101,13 @@ public void succeed_whenClassContainsStringBuilderThatCallsToStringInEquals() {
.verify();
}

@Test
public void succeed_whenClassContainsClassesButDoesntUseThemInEquals() {
EqualsVerifier.forClass(UnusedInEqualsButPresentInClassContainer.class)
.suppress(Warning.INHERITED_DIRECTLY_FROM_OBJECT, Warning.ALL_FIELDS_SHOULD_BE_USED)
.verify();
}

abstract static class CollectionContainer {

protected abstract void callAbstractMethodsOnInterface();
Expand Down Expand Up @@ -716,4 +724,12 @@ public int hashCode() {
return defaultHashCode(this);
}
}

static final class UnusedInEqualsButPresentInClassContainer {
private final PropertyChangeSupport pcs;

public UnusedInEqualsButPresentInClassContainer(PropertyChangeSupport pcs) {
this.pcs = pcs;
}
}
}

0 comments on commit 83df3ee

Please sign in to comment.