package com.drumonii.loltrollbuild.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;
import org.apache.commons.lang3.builder.CompareToBuilder;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * League of Legend Version (patch).
 *
 * @see <a href="http://leagueoflegends.wikia.com/wiki/Patch">Patch</a>
 */
@Entity
@Table(name = "VERSION")
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(of = { "patch" })
@ToString
public class Version implements Serializable, Comparable<Version> {

	public Version(String patch) {
		String[] versioning = patch.split("\\.");
		this.patch = patch;
		this.major = Integer.parseInt(versioning[0]);
		this.minor = Integer.parseInt(versioning[1]);
		this.revision = Integer.parseInt(versioning[2]);
	}

	@Id
	@Column(name = "PATCH", nullable = false)
	@JsonProperty("patch")
	@Getter @Setter private String patch;

	@Column(name = "MAJOR", nullable = false)
	@JsonProperty("major")
	@Getter @Setter private int major;

	@Column(name = "MINOR", nullable = false)
	@JsonProperty("minor")
	@Getter @Setter private int minor;

	@Column(name = "REVISION", nullable = false)
	@JsonProperty("revision")
	@Getter @Setter private int revision;

	@Override
	public int compareTo(Version o) {
		return new CompareToBuilder()
				.append(major, o.getMajor())
				.append(minor, o.getMinor())
				.append(revision, o.getRevision())
				.toComparison();
	}

}

@@ -110,66 +110,8 @@
 k.*;
-%0Aimport org.apache.commons.lang3.builder.CompareToBuilder;
 %0A%0Aim
@@ -263,16 +263,45 @@
 lizable;
+%0Aimport java.util.Comparator;
 %0A%0A/**%0A *
@@ -1325,17 +1325,23 @@
 Version 
-o
+version
 ) %7B%0A%09%09re
@@ -1349,60 +1349,46 @@
 urn 
-new 
 Compar
-eToBuilder()%0A%09%09%09%09.append(major, o.
+ator.comparing(Version::
 getMajor
 ())%0A
@@ -1387,41 +1387,46 @@
 ajor
-()
 )%0A%09%09%09%09.
-append(minor, o.
+thenComparing(Version::
 getMinor
 ())%0A
@@ -1425,36 +1425,41 @@
 inor
-()
 )%0A%09%09%09%09.
-append(revision, o.
+thenComparingInt(Version::
 getR
@@ -1469,30 +1469,36 @@
 sion
-()
 )%0A%09%09%09%09.
-toC
+c
 ompar
+e(this, vers
 i
-s
 on
-(
 );%0A%09

Use Comparator.comparing over CompareToBuilder