summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/components/IDescribedComponent.java
diff options
context:
space:
mode:
authorbjculkin <bjculkin@mix.wvu.edu>2017-03-17 08:52:13 -0400
committerbjculkin <bjculkin@mix.wvu.edu>2017-03-17 08:52:13 -0400
commit7f59d0b9de4536705b3122cb5a85d9c9f85846a3 (patch)
tree8aeed52ab4a18385f63dae2f51c792b88da669bb /BJC-Utils2/src/main/java/bjc/utils/components/IDescribedComponent.java
parent9d89261fedf23c11b684eb66cefdd86a9378ad20 (diff)
Add toString/equals/hashCode/compareTo part 1
Adds utility methods to classes that need them. This covers the cli & component packages.
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/components/IDescribedComponent.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/components/IDescribedComponent.java22
1 files changed, 17 insertions, 5 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/components/IDescribedComponent.java b/BJC-Utils2/src/main/java/bjc/utils/components/IDescribedComponent.java
index a397bbc..f231924 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/components/IDescribedComponent.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/components/IDescribedComponent.java
@@ -7,7 +7,7 @@ package bjc.utils.components;
* @author ben
*
*/
-public interface IDescribedComponent {
+public interface IDescribedComponent extends Comparable<IDescribedComponent>{
/**
* Get the author of this component
*
@@ -15,7 +15,7 @@ public interface IDescribedComponent {
*
* @return The author of the component
*/
- public default String getAuthor() {
+ default String getAuthor() {
return "Anonymous";
}
@@ -27,7 +27,7 @@ public interface IDescribedComponent {
*
* @return The description of the component
*/
- public default String getDescription() {
+ default String getDescription() {
return "No description provided.";
}
@@ -38,7 +38,7 @@ public interface IDescribedComponent {
*
* @return The name of the component
*/
- public String getName();
+ String getName();
/**
* Get the version of this component
@@ -47,7 +47,19 @@ public interface IDescribedComponent {
*
* @return The version of this component
*/
- public default int getVersion() {
+ default int getVersion() {
return 1;
}
+
+
+ @Override
+ default int compareTo(IDescribedComponent o) {
+ int res = getName().compareTo(o.getName());
+
+ if(res == 0) {
+ res = getVersion() - o.getVersion();
+ }
+
+ return res;
+ }
} \ No newline at end of file