diff options
Diffstat (limited to 'usage_examples')
-rw-r--r-- | usage_examples/DataExample_post.jpage | 40 | ||||
-rw-r--r-- | usage_examples/EqualsAndHashCodeExample_post.jpage | 24 | ||||
-rw-r--r-- | usage_examples/EqualsAndHashCodeExample_pre.jpage | 4 | ||||
-rw-r--r-- | usage_examples/ToStringExample_post.jpage | 8 | ||||
-rw-r--r-- | usage_examples/ToStringExample_pre.jpage | 4 |
5 files changed, 48 insertions, 32 deletions
diff --git a/usage_examples/DataExample_post.jpage b/usage_examples/DataExample_post.jpage index 838c9cf7..a1fa038e 100644 --- a/usage_examples/DataExample_post.jpage +++ b/usage_examples/DataExample_post.jpage @@ -11,7 +11,7 @@ public class DataExample { } public String getName() { - return name; + return this.name; } void setAge(int age) { @@ -19,7 +19,7 @@ public class DataExample { } public int getAge() { - return age; + return this.age; } public void setScore(double score) { @@ -27,11 +27,11 @@ public class DataExample { } public double getScore() { - return score; + return this.score; } public String[] getTags() { - return tags; + return this.tags; } public void setTags(String[] tags) { @@ -39,7 +39,7 @@ public class DataExample { } @Override public String toString() { - return "DataExample(" + name + ", " + age + ", " + score + ", " + Arrays.deepToString(tags) + ")"; + return "DataExample(" + this.getName() + ", " + this.getAge() + ", " + this.getScore() + ", " + Arrays.deepToString(this.getTags()) + ")"; } @Override public boolean equals(Object o) { @@ -47,21 +47,21 @@ public class DataExample { if (o == null) return false; if (o.getClass() != this.getClass()) return false; DataExample other = (DataExample) o; - if (name == null ? other.name != null : !name.equals(other.name)) return false; - if (age != other.age) return false; - if (Double.compare(score, other.score) != 0) return false; - if (!Arrays.deepEquals(tags, other.tags)) return false; + if (this.getName() == null ? other.getName() != null : !this.getName().equals(other.getName())) return false; + if (this.getAge() != other.getAge()) return false; + if (Double.compare(this.getScore(), other.getScore()) != 0) return false; + if (!Arrays.deepEquals(this.getTags(), other.getTags())) return false; return true; } @Override public int hashCode() { final int PRIME = 31; int result = 1; - final long temp1 = Double.doubleToLongBits(score); - result = (result*PRIME) + (name == null ? 0 : name.hashCode()); - result = (result*PRIME) + age; + final long temp1 = Double.doubleToLongBits(this.getScore()); + result = (result*PRIME) + (this.getName() == null ? 0 : this.getName().hashCode()); + result = (result*PRIME) + this.getAge(); result = (result*PRIME) + (int)(temp1 ^ (temp1 >>> 32)); - result = (result*PRIME) + Arrays.deepHashCode(tags); + result = (result*PRIME) + Arrays.deepHashCode(this.getTags()); return result; } @@ -79,15 +79,15 @@ public class DataExample { } public String getName() { - return name; + return this.name; } public T getValue() { - return value; + return this.value; } @Override public String toString() { - return "Exercise(name=" + name + ", value=" + value + ")"; + return "Exercise(name=" + this.getName() + ", value=" + this.getValue() + ")"; } @Override public boolean equals(Object o) { @@ -95,16 +95,16 @@ public class DataExample { if (o == null) return false; if (o.getClass() != this.getClass()) return false; Exercise<?> other = (Exercise<?>) o; - if (name == null ? other.name != null : !name.equals(other.name)) return false; - if (value == null ? other.value != null : !value.equals(other.value)) return false; + if (this.getName() == null ? other.getValue() != null : !this.getName().equals(other.getName())) return false; + if (this.getValue() == null ? other.getValue() != null : !this.getValue().equals(other.getValue())) return false; return true; } @Override public int hashCode() { final int PRIME = 31; int result = 1; - result = (result*PRIME) + (name == null ? 0 : name.hashCode()); - result = (result*PRIME) + (value == null ? 0 : value.hashCode()); + result = (result*PRIME) + (this.getName() == null ? 0 : this.getName().hashCode()); + result = (result*PRIME) + (this.getValue() == null ? 0 : this.getValue().hashCode()); return result; } } diff --git a/usage_examples/EqualsAndHashCodeExample_post.jpage b/usage_examples/EqualsAndHashCodeExample_post.jpage index b3f6e035..312bb92f 100644 --- a/usage_examples/EqualsAndHashCodeExample_post.jpage +++ b/usage_examples/EqualsAndHashCodeExample_post.jpage @@ -8,24 +8,28 @@ public class EqualsAndHashCodeExample { private String[] tags; private int id; + public String getName() { + return this.name; + } + @Override public boolean equals(Object o) { if (o == this) return true; if (o == null) return false; if (o.getClass() != this.getClass()) return false; EqualsAndHashCodeExample other = (EqualsAndHashCodeExample) o; - if (name == null ? other.name != null : !name.equals(other.name)) return false; - if (Double.compare(score, other.score) != 0) return false; - if (!Arrays.deepEquals(tags, other.tags)) return false; + if (this.getName() == null ? other.getName() != null : !this.getName().equals(other.getName())) return false; + if (Double.compare(this.score, other.score) != 0) return false; + if (!Arrays.deepEquals(this.tags, other.tags)) return false; return true; } @Override public int hashCode() { final int PRIME = 31; int result = 1; - final long temp1 = Double.doubleToLongBits(score); - result = (result*PRIME) + (name == null ? 0 : name.hashCode()); + final long temp1 = Double.doubleToLongBits(this.score); + result = (result*PRIME) + (this.name == null ? 0 : this.name.hashCode()); result = (result*PRIME) + (int)(temp1 ^ (temp1 >>> 32)); - result = (result*PRIME) + Arrays.deepHashCode(tags); + result = (result*PRIME) + Arrays.deepHashCode(this.tags); return result; } @@ -43,8 +47,8 @@ public class EqualsAndHashCodeExample { if (o.getClass() != this.getClass()) return false; if (!super.equals(o)) return false; Square other = (Square) o; - if (width != o.width) return false; - if (height != o.height) return false; + if (this.width != other.width) return false; + if (this.height != other.height) return false; return true; } @@ -52,8 +56,8 @@ public class EqualsAndHashCodeExample { final int PRIME = 31; int result = 1; result = (result*PRIME) + super.hashCode(); - result = (result*PRIME) + width; - result = (result*PRIME) + height; + result = (result*PRIME) + this.width; + result = (result*PRIME) + this.height; return result; } } diff --git a/usage_examples/EqualsAndHashCodeExample_pre.jpage b/usage_examples/EqualsAndHashCodeExample_pre.jpage index b146f29a..64faf59f 100644 --- a/usage_examples/EqualsAndHashCodeExample_pre.jpage +++ b/usage_examples/EqualsAndHashCodeExample_pre.jpage @@ -9,6 +9,10 @@ public class EqualsAndHashCodeExample { private String[] tags; private int id; + public String getName() { + return this.name; + } + @EqualsAndHashCode(callSuper=true) public static class Square extends Shape { private final int width, height; diff --git a/usage_examples/ToStringExample_post.jpage b/usage_examples/ToStringExample_post.jpage index f348e0dc..67e78f20 100644 --- a/usage_examples/ToStringExample_post.jpage +++ b/usage_examples/ToStringExample_post.jpage @@ -7,6 +7,10 @@ public class ToStringExample { private String[] tags; private int id; + public String getName() { + return this.getName(); + } + public static class Square extends Shape { private final int width, height; @@ -16,11 +20,11 @@ public class ToStringExample { } @Override public String toString() { - return "Square(super=" + super.toString() + ", width=" + width + ", height=" + height + ")"; + return "Square(super=" + super.toString() + ", width=" + this.width + ", height=" + this.height + ")"; } } @Override public String toString() { - return "ToStringExample(" + name + ", " + shape + ", " + Arrays.deepToString(tags) + ")"; + return "ToStringExample(" + this.getName() + ", " + this.shape + ", " + Arrays.deepToString(this.tags) + ")"; } } diff --git a/usage_examples/ToStringExample_pre.jpage b/usage_examples/ToStringExample_pre.jpage index 26b0cfe8..71b23b9d 100644 --- a/usage_examples/ToStringExample_pre.jpage +++ b/usage_examples/ToStringExample_pre.jpage @@ -8,6 +8,10 @@ public class ToStringExample { private String[] tags; private int id; + public String getName() { + return this.getName(); + } + @ToString(callSuper=true, includeFieldNames=true) public static class Square extends Shape { private final int width, height; |