summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/components/DescribedComponent.java
blob: dcbaf59cf5e0d350bed187f2641cf66e00264787 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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;
	}
}