diff --git a/src/main/java/io/github/dsheirer/identifier/radio/FullyQualifiedRadioIdentifier.java b/src/main/java/io/github/dsheirer/identifier/radio/FullyQualifiedRadioIdentifier.java index 0d1d3547c..9ebab4ae6 100644 --- a/src/main/java/io/github/dsheirer/identifier/radio/FullyQualifiedRadioIdentifier.java +++ b/src/main/java/io/github/dsheirer/identifier/radio/FullyQualifiedRadioIdentifier.java @@ -41,7 +41,7 @@ public abstract class FullyQualifiedRadioIdentifier extends RadioIdentifier */ public FullyQualifiedRadioIdentifier(int localAddress, int wacn, int system, int id, Role role) { - super(localAddress > 0 ? localAddress : id, role); + super(localAddress, role); mWacn = wacn; mSystem = system; mRadio = id; @@ -92,4 +92,23 @@ public String toString() return getFullyQualifiedRadioAddress(); } } + + @Override + public boolean equals(Object o) + { + //Attempt to match as a fully qualified radio match first + if(o instanceof FullyQualifiedRadioIdentifier fqri) + { + return getWacn() == fqri.getWacn() && + getSystem() == fqri.getSystem() && + getRadio() == fqri.getRadio(); + } + //Attempt to match the local address against a simple radio version + else if(o instanceof RadioIdentifier ri) + { + return getValue() != 0 && ri.getValue() != 0 && getValue().equals(ri.getValue()); + } + + return super.equals(o); + } } diff --git a/src/main/java/io/github/dsheirer/identifier/talkgroup/FullyQualifiedTalkgroupIdentifier.java b/src/main/java/io/github/dsheirer/identifier/talkgroup/FullyQualifiedTalkgroupIdentifier.java index fe5a69a31..cdcfc8de6 100644 --- a/src/main/java/io/github/dsheirer/identifier/talkgroup/FullyQualifiedTalkgroupIdentifier.java +++ b/src/main/java/io/github/dsheirer/identifier/talkgroup/FullyQualifiedTalkgroupIdentifier.java @@ -40,7 +40,7 @@ public abstract class FullyQualifiedTalkgroupIdentifier extends TalkgroupIdentif */ public FullyQualifiedTalkgroupIdentifier(int localAddress, int wacn, int system, int id, Role role) { - super(localAddress > 0 ? localAddress : id, role); + super(localAddress, role); mWacn = wacn; mSystem = system; mTalkgroup = id; @@ -91,4 +91,23 @@ public String toString() return getFullyQualifiedTalkgroupAddress(); } } + + @Override + public boolean equals(Object o) + { + //Attempt to match as a fully qualified talkgroup match first + if(o instanceof FullyQualifiedTalkgroupIdentifier fqti) + { + return getWacn() == fqti.getWacn() && + getSystem() == fqti.getSystem() && + getTalkgroup() == fqti.getTalkgroup(); + } + //Attempt to match the local address against a simple talkgroup version + else if(o instanceof TalkgroupIdentifier ti) + { + return getValue() != 0 && ti.getValue() != 0 && getValue().equals(ti.getValue()); + } + + return super.equals(o); + } }