Adds Comparable to identifiers that are used in TreeSets. (#1103)

Co-authored-by: Dennis Sheirer <dsheirer@github.com>
This commit is contained in:
Denny Sheirer
2021-11-15 04:20:08 -05:00
committed by GitHub
parent cb83a8e870
commit 8b487d79e4
2 changed files with 31 additions and 22 deletions

View File

@@ -1,23 +1,20 @@
/* /*
* *****************************************************************************
* Copyright (C) 2014-2021 Dennis Sheirer
* *
* * ****************************************************************************** * This program is free software: you can redistribute it and/or modify
* * Copyright (C) 2014-2019 Dennis Sheirer * it under the terms of the GNU General Public License as published by
* * * the Free Software Foundation, either version 3 of the License, or
* * This program is free software: you can redistribute it and/or modify * (at your option) any later version.
* * it under the terms of the GNU General Public License as published by
* * the Free Software Foundation, either version 3 of the License, or
* * (at your option) any later version.
* *
* * This program is distributed in the hope that it will be useful,
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
* *
* * You should have received a copy of the GNU General Public License
* * along with this program. If not, see <http://www.gnu.org/licenses/>
* * *****************************************************************************
* *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/ */
package io.github.dsheirer.module.decode.mdc1200.identifier; package io.github.dsheirer.module.decode.mdc1200.identifier;
@@ -29,7 +26,7 @@ import io.github.dsheirer.protocol.Protocol;
/** /**
* Identifier for an MDC1200 radio identity * Identifier for an MDC1200 radio identity
*/ */
public class MDC1200Identifier extends TalkgroupIdentifier public class MDC1200Identifier extends TalkgroupIdentifier implements Comparable<MDC1200Identifier>
{ {
/** /**
@@ -61,4 +58,10 @@ public class MDC1200Identifier extends TalkgroupIdentifier
{ {
return new MDC1200Identifier(value, Role.FROM); return new MDC1200Identifier(value, Role.FROM);
} }
@Override
public int compareTo(MDC1200Identifier other)
{
return Integer.compare(getValue(), other != null ? other.getValue() : 0);
}
} }

View File

@@ -1,7 +1,6 @@
/* /*
* ****************************************************************************** * *****************************************************************************
* sdrtrunk * Copyright (C) 2014-2021 Dennis Sheirer
* Copyright (C) 2014-2018 Dennis Sheirer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@@ -15,7 +14,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* ***************************************************************************** * ****************************************************************************
*/ */
package io.github.dsheirer.module.decode.tait.identifier; package io.github.dsheirer.module.decode.tait.identifier;
@@ -25,11 +24,12 @@ import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role; import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.string.StringIdentifier; import io.github.dsheirer.identifier.string.StringIdentifier;
import io.github.dsheirer.protocol.Protocol; import io.github.dsheirer.protocol.Protocol;
import org.apache.commons.lang3.StringUtils;
/** /**
* Tait-1200 String (ASCII) Identifier * Tait-1200 String (ASCII) Identifier
*/ */
public class TaitIdentifier extends StringIdentifier public class TaitIdentifier extends StringIdentifier implements Comparable<TaitIdentifier>
{ {
/** /**
* Constructs an identifier with the specified role * Constructs an identifier with the specified role
@@ -60,4 +60,10 @@ public class TaitIdentifier extends StringIdentifier
{ {
return new TaitIdentifier(value, Role.TO); return new TaitIdentifier(value, Role.TO);
} }
@Override
public int compareTo(TaitIdentifier other)
{
return StringUtils.compare(getValue(), other != null ? other.getValue() : null);
}
} }