+ return version == null;
+ }
+
+ /**
+ * Check if we are more recent than the given {@link Version}.
+ * <p>
+ * Note that a tagged version is considered newer than a non-tagged version,
+ * but two tagged versions with different tags are not comparable.
+ * <p>
+ * Also, an empty version is always considered older.
+ *
+ * @param o
+ * the other {@link Version}
+ * @return TRUE if this {@link Version} is more recent than the given one
+ */
+ public boolean isNewerThan(Version o) {
+ if (isEmpty()) {
+ return false;
+ } else if (o.isEmpty()) {
+ return true;
+ }
+
+ if (major > o.major) {
+ return true;
+ }
+
+ if (major == o.major && minor > o.minor) {
+ return true;
+ }
+
+ if (major == o.major && minor == o.minor && patch > o.patch) {
+ return true;
+ }
+
+ // a tagged version is considered newer than a non-tagged one
+ if (major == o.major && minor == o.minor && patch == o.patch
+ && tag != null && o.tag == null) {
+ return true;
+ }
+
+ // 2 <> tagged versions are not comparable
+ boolean sameTag = (tag == null && o.tag == null)
+ || (tag != null && tag.equals(o.tag));
+ if (major == o.major && minor == o.minor && patch == o.patch && sameTag
+ && tagVersion > o.tagVersion) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Check if we are older than the given {@link Version}.
+ * <p>
+ * Note that a tagged version is considered newer than a non-tagged version,
+ * but two tagged versions with different tags are not comparable.
+ * <p>
+ * Also, an empty version is always considered older.
+ *
+ * @param o
+ * the other {@link Version}
+ * @return TRUE if this {@link Version} is older than the given one
+ */
+ public boolean isOlderThan(Version o) {
+ if (o.isEmpty()) {
+ return false;
+ } else if (isEmpty()) {
+ return true;
+ }
+
+ // 2 <> tagged versions are not comparable
+ boolean sameTag = (tag == null && o.tag == null)
+ || (tag != null && tag.equals(o.tag));
+ if (major == o.major && minor == o.minor && patch == o.patch
+ && !sameTag) {
+ return false;
+ }
+
+ return !equals(o) && !isNewerThan(o);