summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/components/DescribedComponent.java
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2020-12-14 19:29:37 -0400
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2020-12-14 19:29:37 -0400
commit9351ea3e97bbe2d348aa17067ccc6267dc7c080f (patch)
treedd2269c26161c735d94d8dc83d56e6076c2a155d /base/src/main/java/bjc/utils/components/DescribedComponent.java
parent8933de7f646f0565edf700aa2f2fcab06d639855 (diff)
parent6dcadc360dafdd12142d53327f44579379a4c9dd (diff)
Merge branch 'master' of https://github.com/bculkin2442/bjc-utils2
Diffstat (limited to 'base/src/main/java/bjc/utils/components/DescribedComponent.java')
-rw-r--r--base/src/main/java/bjc/utils/components/DescribedComponent.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/base/src/main/java/bjc/utils/components/DescribedComponent.java b/base/src/main/java/bjc/utils/components/DescribedComponent.java
new file mode 100644
index 0000000..dcbaf59
--- /dev/null
+++ b/base/src/main/java/bjc/utils/components/DescribedComponent.java
@@ -0,0 +1,64 @@
+package bjc.utils.components;
+
+/**
+ * Represents a optional component that has status information associated with
+ * it.
+ *
+ * @author ben
+ *
+ */
+public interface DescribedComponent extends Comparable<DescribedComponent> {
+ /**
+ * Get the author of this component.
+ *
+ * Providing this is optional, with "Anonymous" as the default author.
+ *
+ * @return The author of the component.
+ */
+ default String getAuthor() {
+ return "Anonymous";
+ }
+
+ /**
+ * Get the description of this component.
+ *
+ * Providing this is optional, with the default being a note that no description
+ * was provided.
+ *
+ * @return The description of the component
+ */
+ default String getDescription() {
+ return "No description provided.";
+ }
+
+ /**
+ * Get the name of this component.
+ *
+ * This is the only thing required of all components.
+ *
+ * @return The name of the component.
+ */
+ String getName();
+
+ /**
+ * Get the version of this component.
+ *
+ * Providing this is optional, with "1" as the default version.
+ *
+ * @return The version of this component.
+ */
+ default int getVersion() {
+ return 1;
+ }
+
+ @Override
+ default int compareTo(final DescribedComponent o) {
+ int res = getName().compareTo(o.getName());
+
+ if (res == 0) {
+ res = getVersion() - o.getVersion();
+ }
+
+ return res;
+ }
+}