diff --git a/code/src/java/pcgen/cdom/enumeration/DisplayLocation.java b/code/src/java/pcgen/cdom/enumeration/DisplayLocation.java index eebd4d886d3..ea15ed10e19 100644 --- a/code/src/java/pcgen/cdom/enumeration/DisplayLocation.java +++ b/code/src/java/pcgen/cdom/enumeration/DisplayLocation.java @@ -21,6 +21,7 @@ import java.util.Collections; import java.util.Objects; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import pcgen.base.enumeration.TypeSafeConstant; import pcgen.base.util.CaseInsensitiveMap; @@ -161,15 +162,11 @@ public static void clearConstants() } @Override + @SuppressFBWarnings(value = "EQ_COMPARETO_USE_OBJECT_EQUALS", + justification = "Singleton-by-construction via getConstant intern map; " + + "no .equals() callers, not used as a collection key. Identity equality is correct here.") public int compareTo(DisplayLocation type) { - /* - * Note: Some tools will report a problem here because Type implements - * compareTo, but does not implement custom implementations of hashCode - * or equals(). Because this is intended as a TypeSafeConstant, and Type - * has a private constructor, it is unnecessary to implement a custom - * hashCode or equals. - */ return fieldName.compareTo(type.fieldName); } diff --git a/code/src/java/pcgen/cdom/enumeration/Region.java b/code/src/java/pcgen/cdom/enumeration/Region.java index 8995713ea64..9385b60eb9c 100644 --- a/code/src/java/pcgen/cdom/enumeration/Region.java +++ b/code/src/java/pcgen/cdom/enumeration/Region.java @@ -20,6 +20,7 @@ import java.lang.reflect.Field; import java.util.Collection; import java.util.Collections; +import java.util.Locale; import java.util.Objects; import pcgen.base.enumeration.TypeSafeConstant; @@ -28,13 +29,23 @@ import pcgen.cdom.base.Constants; /** - * * This Class is a Type Safe Constant. It is designed to hold Regions in a * type-safe fashion, so that they can be quickly compared and use less memory * when identical Regions exist in two CDOMObjects. + * + *
{@code equals} and {@code hashCode} are case-insensitive on
+ * {@code fieldName} to match {@link #compareTo} (Comparable contract) and to
+ * support use as a {@code HashMap} key — see {@code BioSet}'s
+ * {@code DoubleKeyMap
{@code equals} and {@code hashCode} are value-based on {@code fieldName} + * (case-sensitive, matching {@link #compareTo}). Type is used as a + * {@code HashSet}/{@code HashMap} key across the codebase (DataSet, GameMode, + * BodyStructure, spell/skill lists, …); the value-equals contract holds even + * when an instance is constructed outside the {@link #getConstant} intern map.
*/ public final class Type implements TypeSafeConstant, Comparable