summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java b/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java
index 3cb16b4..a946cae 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescription.java
@@ -35,15 +35,37 @@ public class ComponentDescription implements IDescribedComponent {
* The description of the component
* @param version
* The version of the component
+ * @throws IllegalArgumentException
+ * thrown if name, author or description is null, or if
+ * version is less than 1
*/
public ComponentDescription(String name, String author,
String description, int version) {
+ sanityCheckArgs(name, author, description, version);
+
this.name = name;
this.author = author;
this.description = description;
this.version = version;
}
+ private static void sanityCheckArgs(String name, String author,
+ String description, int version) {
+ if (name == null) {
+ throw new IllegalArgumentException(
+ "Component name can't be null");
+ } else if (author == null) {
+ throw new IllegalArgumentException(
+ "Component author can't be null");
+ } else if (description == null) {
+ throw new IllegalArgumentException(
+ "Component description can't be null");
+ } else if (version < 0) {
+ throw new IllegalArgumentException(
+ "Component version must be greater than 0");
+ }
+ }
+
@Override
public String getAuthor() {
return author;
@@ -63,4 +85,9 @@ public class ComponentDescription implements IDescribedComponent {
public int getVersion() {
return version;
}
+
+ @Override
+ public String toString() {
+ return name + " component v" + version + ", written by " + author;
+ }
}