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,7 +1,6 @@
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2018 Dennis Sheirer
* *****************************************************************************
* Copyright (C) 2014-2021 Dennis Sheirer
*
* 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
@@ -15,7 +14,7 @@
*
* 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.tait.identifier;
@@ -25,11 +24,12 @@ import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.string.StringIdentifier;
import io.github.dsheirer.protocol.Protocol;
import org.apache.commons.lang3.StringUtils;
/**
* 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
@@ -60,4 +60,10 @@ public class TaitIdentifier extends StringIdentifier
{
return new TaitIdentifier(value, Role.TO);
}
@Override
public int compareTo(TaitIdentifier other)
{
return StringUtils.compare(getValue(), other != null ? other.getValue() : null);
}
}