mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 02:39:44 +02:00
GP-3529 - Make DataTypePath comparable
This commit is contained in:
parent
bc0bcbe985
commit
5125814a3e
1 changed files with 14 additions and 3 deletions
|
@ -15,11 +15,13 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.program.model.data;
|
package ghidra.program.model.data;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object to hold a category path and a datatype name. They are held separately so that
|
* Object to hold a category path and a datatype name. They are held separately so that
|
||||||
* the datatype name can contain a categoryPath delimiter ("/") character.
|
* the datatype name can contain a categoryPath delimiter ("/") character.
|
||||||
*/
|
*/
|
||||||
public class DataTypePath {
|
public class DataTypePath implements Comparable<DataTypePath> {
|
||||||
private final CategoryPath categoryPath;
|
private final CategoryPath categoryPath;
|
||||||
private final String dataTypeName;
|
private final String dataTypeName;
|
||||||
|
|
||||||
|
@ -43,8 +45,8 @@ public class DataTypePath {
|
||||||
if (dataTypeName == null || categoryPath == null) {
|
if (dataTypeName == null || categoryPath == null) {
|
||||||
throw new IllegalArgumentException("null not allowed for categoryPath or datatypeName");
|
throw new IllegalArgumentException("null not allowed for categoryPath or datatypeName");
|
||||||
}
|
}
|
||||||
this.categoryPath = categoryPath;
|
this.categoryPath = Objects.requireNonNull(categoryPath, "Category path cannot be null");
|
||||||
this.dataTypeName = dataTypeName;
|
this.dataTypeName = Objects.requireNonNull(dataTypeName, "Data type name cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -125,6 +127,15 @@ public class DataTypePath {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(DataTypePath other) {
|
||||||
|
int result = categoryPath.compareTo(other.categoryPath);
|
||||||
|
if (result == 0) {
|
||||||
|
result = dataTypeName.compareTo(other.dataTypeName);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getPath();
|
return getPath();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue