Fix some minor bugs (#745)

* Include other member variables in copy constructor

* Add break to switch cases

* Implement equals() in classes extending Comparable

If equals() is not overridden, the equals() implementation is not consistent
with the compareTo() implementation. If an object of such a class is added
to a collection such as java.util.SortedSet, this collection will violate
the contract of java.util.Set, which is defined in terms of equals().

Co-authored-by: Rob Ekl <xwq876@zebra.com>
This commit is contained in:
robekl
2020-04-25 05:52:14 -04:00
committed by GitHub
parent de9431f649
commit 649258bd2b
22 changed files with 94 additions and 0 deletions

View File

@@ -110,4 +110,10 @@ public class WildcardID implements Comparable<WildcardID>
{
return Integer.compare(this.weight(), otherWildcardID.weight());
}
@Override
public boolean equals(Object o) {
if (!(o instanceof WildcardID)) return false;
return compareTo((WildcardID) o) == 0;
}
}

View File

@@ -138,4 +138,10 @@ public class AudioRecording implements Comparable<AudioRecording>
{
return mPendingReplayCount.get() > 0;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof AudioRecording)) return false;
return compareTo((AudioRecording) o) == 0;
}
}

View File

@@ -538,6 +538,7 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Audio
{
return BroadcastState.INVALID_SETTINGS;
}
break;
case COLUMN_BROADCASTER_QUEUE_SIZE:
AudioBroadcaster audioBroadcasterB = mBroadcasterMap.get(configuration.getName());

View File

@@ -100,6 +100,8 @@ public class BinaryMessage extends BitSet
this(toCopyFrom.size());
this.or(toCopyFrom);
this.mPointer = toCopyFrom.pointer();
this.mCRC = toCopyFrom.mCRC;
this.mSize = toCopyFrom.mSize;
}
public BinaryMessage(BitSet bitset, int size)

View File

@@ -531,6 +531,7 @@ public class MultiChannelState extends AbstractChannelState implements IDecoderS
ChangeChannelTimeoutEvent timeout = (ChangeChannelTimeoutEvent)event;
mStateMachineMap.get(event.getTimeslot()).setFadeTimeoutBuffer(timeout.getCallTimeout());
}
break;
case CONTINUATION:
case DECODE:
case START:

View File

@@ -184,6 +184,7 @@ public class ChannelProcessingManager implements Listener<ChannelEvent>
break;
}
}
break;
case NOTIFICATION_DELETE:
if(channel.isProcessing())
{

View File

@@ -46,4 +46,10 @@ public class FilterElement<T> implements Comparable<FilterElement<T>>
{
return toString().compareTo( other.toString() );
}
@Override
public boolean equals(Object o) {
if (!(o instanceof FilterElement)) return false;
return compareTo((FilterElement) o) == 0;
}
}

View File

@@ -114,4 +114,10 @@ public class Icon implements Comparable<Icon>
{
return getName().compareTo(otherIcon.getName());
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Icon)) return false;
return compareTo((Icon) o) == 0;
}
}

View File

@@ -63,4 +63,10 @@ public class ESNIdentifier extends StringIdentifier implements Comparable<ESNIde
return getValue().compareTo(o.getValue());
}
}
@Override
public boolean equals(Object o) {
if (!(o instanceof ESNIdentifier)) return false;
return compareTo((ESNIdentifier) o) == 0;
}
}

View File

@@ -78,4 +78,10 @@ public class LTRTalkgroup extends TalkgroupIdentifier implements Comparable<LTRT
{
return getValue().compareTo(o.getValue());
}
@Override
public boolean equals(Object o) {
if (!(o instanceof LTRTalkgroup)) return false;
return compareTo((LTRTalkgroup) o) == 0;
}
}

View File

@@ -87,4 +87,10 @@ public class FleetsyncIdentifier extends TalkgroupIdentifier implements Comparab
{
return getValue().compareTo(o.getValue());
}
@Override
public boolean equals(Object o) {
if (!(o instanceof FleetsyncIdentifier)) return false;
return compareTo((FleetsyncIdentifier) o) == 0;
}
}

View File

@@ -108,4 +108,10 @@ public class LtrNetChannel implements IChannelDescriptor, Comparable<LtrNetChann
{
return Integer.compare(getChannel(), o.getChannel());
}
@Override
public boolean equals(Object o) {
if (!(o instanceof LtrNetChannel)) return false;
return compareTo((LtrNetChannel) o) == 0;
}
}

View File

@@ -63,4 +63,10 @@ public class LtrNetRadioIdentifier extends TalkgroupIdentifier implements Compar
{
return getValue().compareTo(o.getValue());
}
@Override
public boolean equals(Object o) {
if (!(o instanceof LtrNetRadioIdentifier)) return false;
return compareTo((LtrNetRadioIdentifier) o) == 0;
}
}

View File

@@ -102,4 +102,10 @@ public class LtrChannel implements IChannelDescriptor, Comparable<LtrChannel>
{
return Integer.compare(getChannel(), o.getChannel());
}
@Override
public boolean equals(Object o) {
if (!(o instanceof LtrChannel)) return false;
return compareTo((LtrChannel) o) == 0;
}
}

View File

@@ -706,6 +706,7 @@ public class MPT1327Message extends Message
sb.append(getPresselOnRequired());
sb.append(" IDENT1 VALUE:");
sb.append(getMaintMessageIDENT1Value());
break;
default:
break;
}

View File

@@ -86,4 +86,10 @@ public class P25ExplicitChannel extends P25Channel implements Comparable<P25Chan
return Integer.compare(getDownlinkBandIdentifier(), other.getDownlinkBandIdentifier());
}
}
@Override
public boolean equals(Object o) {
if (!(o instanceof P25ExplicitChannel)) return false;
return compareTo((P25ExplicitChannel) o) == 0;
}
}

View File

@@ -646,6 +646,7 @@ public class P25P1DecoderState extends DecoderState implements IChannelEventList
.details("ANSWER REQUEST")
.identifiers(icUUAnswerRequest)
.build());
break;
case OSP_CALL_ALERT:
MutableIdentifierCollection icCallAlert = new MutableIdentifierCollection(getIdentifierCollection().getIdentifiers());
icCallAlert.remove(IdentifierClass.USER);
@@ -2122,6 +2123,7 @@ public class P25P1DecoderState extends DecoderState implements IChannelEventList
.identifiers(ic)
.build());
}
break;
default:
// mLog.debug("Unrecognized TSBK Opcode: " + tsbk.getOpcode().name() + " VENDOR:" + tsbk.getVendor() +
// " OPCODE:" + tsbk.getOpcodeNumber());

View File

@@ -66,4 +66,10 @@ public class PassportTalkgroup extends TalkgroupIdentifier implements Comparable
{
return Integer.compare(getValue(), o.getValue());
}
@Override
public boolean equals(Object o) {
if (!(o instanceof PassportTalkgroup)) return false;
return compareTo((PassportTalkgroup) o) == 0;
}
}

View File

@@ -109,6 +109,7 @@ public class SourceManager
break;
case RECORDING:
retVal = mRecordingSourceManager.getSource(config, channelSpecification);
break;
case NONE:
default:
break;

View File

@@ -114,4 +114,10 @@ public class Recording implements Comparable<Recording>, ISourceEventProcessor
return getRecordingConfiguration().getAlias()
.compareTo( other.getRecordingConfiguration().getAlias() );
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Recording)) return false;
return compareTo((Recording) o) == 0;
}
}

View File

@@ -528,6 +528,7 @@ public class AirspyTunerEditor extends TunerConfigurationEditor
mMixerAGC.setEnabled(true);
mMixerGain.setEnabled(true);
}
break;
default:
break;
}

View File

@@ -88,4 +88,10 @@ public class TunerChannel implements Comparable<TunerChannel>
{
return Long.compare(getFrequency(), otherLock.getFrequency());
}
@Override
public boolean equals(Object o) {
if (!(o instanceof TunerChannel)) return false;
return compareTo((TunerChannel) o) == 0;
}
}