Skip to content

Commit

Permalink
Remove EqualsBuilder HashCodeBuilder usages
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Du <[email protected]>
  • Loading branch information
BobDu committed May 8, 2024
1 parent 9965b3a commit bd0068b
Show file tree
Hide file tree
Showing 25 changed files with 124 additions and 211 deletions.
14 changes: 5 additions & 9 deletions src/main/java/net/sf/ezmorph/array/BooleanArrayMorpher.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
package net.sf.ezmorph.array;

import java.lang.reflect.Array;
import java.util.Objects;
import net.sf.ezmorph.MorphException;
import net.sf.ezmorph.primitive.BooleanMorpher;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
* Morphs an array to a boolean[].
Expand Down Expand Up @@ -57,12 +56,10 @@ public boolean equals(Object obj) {
}

BooleanArrayMorpher other = (BooleanArrayMorpher) obj;
EqualsBuilder builder = new EqualsBuilder();
if (isUseDefault() && other.isUseDefault()) {
builder.append(getDefaultValue(), other.getDefaultValue());
return builder.isEquals();
return Objects.equals(getDefaultValue(), other.getDefaultValue());
} else if (!isUseDefault() && !other.isUseDefault()) {
return builder.isEquals();
return true;
} else {
return false;
}
Expand All @@ -74,11 +71,10 @@ public boolean getDefaultValue() {

@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
if (isUseDefault()) {
builder.append(getDefaultValue());
return Objects.hashCode(getDefaultValue());
}
return builder.toHashCode();
return 17;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
package net.sf.ezmorph.array;

import java.lang.reflect.Array;
import java.util.Objects;
import net.sf.ezmorph.MorphException;
import net.sf.ezmorph.primitive.BooleanMorpher;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
* Morphs an array to a Boolean[].
Expand Down Expand Up @@ -57,12 +56,10 @@ public boolean equals(Object obj) {
}

BooleanObjectArrayMorpher other = (BooleanObjectArrayMorpher) obj;
EqualsBuilder builder = new EqualsBuilder();
if (isUseDefault() && other.isUseDefault()) {
builder.append(getDefaultValue(), other.getDefaultValue());
return builder.isEquals();
return Objects.equals(getDefaultValue(), other.getDefaultValue());
} else if (!isUseDefault() && !other.isUseDefault()) {
return builder.isEquals();
return true;
} else {
return false;
}
Expand All @@ -74,11 +71,10 @@ public Boolean getDefaultValue() {

@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
if (isUseDefault()) {
builder.append(getDefaultValue());
return Objects.hashCode(getDefaultValue());
}
return builder.toHashCode();
return 17;
}

@Override
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/net/sf/ezmorph/array/ByteArrayMorpher.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
package net.sf.ezmorph.array;

import java.lang.reflect.Array;
import java.util.Objects;
import net.sf.ezmorph.MorphException;
import net.sf.ezmorph.primitive.ByteMorpher;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
* Morphs an array to a byte[].
Expand Down Expand Up @@ -57,12 +56,10 @@ public boolean equals(Object obj) {
}

ByteArrayMorpher other = (ByteArrayMorpher) obj;
EqualsBuilder builder = new EqualsBuilder();
if (isUseDefault() && other.isUseDefault()) {
builder.append(getDefaultValue(), other.getDefaultValue());
return builder.isEquals();
return Objects.equals(getDefaultValue(), other.getDefaultValue());
} else if (!isUseDefault() && !other.isUseDefault()) {
return builder.isEquals();
return true;
} else {
return false;
}
Expand All @@ -74,11 +71,10 @@ public byte getDefaultValue() {

@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
if (isUseDefault()) {
builder.append(getDefaultValue());
return Objects.hashCode(getDefaultValue());
}
return builder.toHashCode();
return 17;
}

@Override
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/net/sf/ezmorph/array/CharArrayMorpher.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
package net.sf.ezmorph.array;

import java.lang.reflect.Array;
import java.util.Objects;
import net.sf.ezmorph.MorphException;
import net.sf.ezmorph.primitive.CharMorpher;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
* Morphs an array to a char[].
Expand Down Expand Up @@ -57,12 +56,10 @@ public boolean equals(Object obj) {
}

CharArrayMorpher other = (CharArrayMorpher) obj;
EqualsBuilder builder = new EqualsBuilder();
if (isUseDefault() && other.isUseDefault()) {
builder.append(getDefaultValue(), other.getDefaultValue());
return builder.isEquals();
return Objects.equals(getDefaultValue(), other.getDefaultValue());
} else if (!isUseDefault() && !other.isUseDefault()) {
return builder.isEquals();
return true;
} else {
return false;
}
Expand All @@ -77,11 +74,10 @@ public char getDefaultValue() {

@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
if (isUseDefault()) {
builder.append(getDefaultValue());
return Objects.hashCode(getDefaultValue());
}
return builder.toHashCode();
return 17;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
package net.sf.ezmorph.array;

import java.lang.reflect.Array;
import java.util.Objects;
import net.sf.ezmorph.MorphException;
import net.sf.ezmorph.primitive.CharMorpher;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
* Morphs an array to a Character[].
Expand Down Expand Up @@ -57,12 +56,10 @@ public boolean equals(Object obj) {
}

CharacterObjectArrayMorpher other = (CharacterObjectArrayMorpher) obj;
EqualsBuilder builder = new EqualsBuilder();
if (isUseDefault() && other.isUseDefault()) {
builder.append(getDefaultValue(), other.getDefaultValue());
return builder.isEquals();
return Objects.equals(getDefaultValue(), other.getDefaultValue());
} else if (!isUseDefault() && !other.isUseDefault()) {
return builder.isEquals();
return true;
} else {
return false;
}
Expand All @@ -74,11 +71,10 @@ public Character getDefaultValue() {

@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
if (isUseDefault()) {
builder.append(getDefaultValue());
return Objects.hashCode(getDefaultValue());
}
return builder.toHashCode();
return 17;
}

@Override
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/net/sf/ezmorph/array/DoubleArrayMorpher.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
package net.sf.ezmorph.array;

import java.lang.reflect.Array;
import java.util.Objects;
import net.sf.ezmorph.MorphException;
import net.sf.ezmorph.primitive.DoubleMorpher;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
* Morphs an array to a double[].
Expand Down Expand Up @@ -57,12 +56,10 @@ public boolean equals(Object obj) {
}

DoubleArrayMorpher other = (DoubleArrayMorpher) obj;
EqualsBuilder builder = new EqualsBuilder();
if (isUseDefault() && other.isUseDefault()) {
builder.append(getDefaultValue(), other.getDefaultValue());
return builder.isEquals();
return Objects.equals(getDefaultValue(), other.getDefaultValue());
} else if (!isUseDefault() && !other.isUseDefault()) {
return builder.isEquals();
return true;
} else {
return false;
}
Expand All @@ -77,11 +74,10 @@ public double getDefaultValue() {

@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
if (isUseDefault()) {
builder.append(getDefaultValue());
return Objects.hashCode(getDefaultValue());
}
return builder.toHashCode();
return 17;
}

@Override
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/net/sf/ezmorph/array/FloatArrayMorpher.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
package net.sf.ezmorph.array;

import java.lang.reflect.Array;
import java.util.Objects;
import net.sf.ezmorph.MorphException;
import net.sf.ezmorph.primitive.FloatMorpher;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
* Morphs an array to a float[].
Expand Down Expand Up @@ -57,12 +56,10 @@ public boolean equals(Object obj) {
}

FloatArrayMorpher other = (FloatArrayMorpher) obj;
EqualsBuilder builder = new EqualsBuilder();
if (isUseDefault() && other.isUseDefault()) {
builder.append(getDefaultValue(), other.getDefaultValue());
return builder.isEquals();
return Objects.equals(getDefaultValue(), other.getDefaultValue());
} else if (!isUseDefault() && !other.isUseDefault()) {
return builder.isEquals();
return true;
} else {
return false;
}
Expand All @@ -77,11 +74,10 @@ public float getDefaultValue() {

@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
if (isUseDefault()) {
builder.append(getDefaultValue());
return Objects.hashCode(getDefaultValue());
}
return builder.toHashCode();
return 17;
}

@Override
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/net/sf/ezmorph/array/IntArrayMorpher.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
package net.sf.ezmorph.array;

import java.lang.reflect.Array;
import java.util.Objects;
import net.sf.ezmorph.MorphException;
import net.sf.ezmorph.primitive.IntMorpher;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
* Morphs an array to a int[].
Expand Down Expand Up @@ -57,12 +56,10 @@ public boolean equals(Object obj) {
}

IntArrayMorpher other = (IntArrayMorpher) obj;
EqualsBuilder builder = new EqualsBuilder();
if (isUseDefault() && other.isUseDefault()) {
builder.append(getDefaultValue(), other.getDefaultValue());
return builder.isEquals();
return Objects.equals(getDefaultValue(), other.getDefaultValue());
} else if (!isUseDefault() && !other.isUseDefault()) {
return builder.isEquals();
return true;
} else {
return false;
}
Expand All @@ -77,11 +74,10 @@ public int getDefaultValue() {

@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
if (isUseDefault()) {
builder.append(getDefaultValue());
return Objects.hashCode(getDefaultValue());
}
return builder.toHashCode();
return 17;
}

@Override
Expand Down
14 changes: 5 additions & 9 deletions src/main/java/net/sf/ezmorph/array/LongArrayMorpher.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
package net.sf.ezmorph.array;

import java.lang.reflect.Array;
import java.util.Objects;
import net.sf.ezmorph.MorphException;
import net.sf.ezmorph.primitive.LongMorpher;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
* Morphs an array to a long[].
Expand Down Expand Up @@ -57,12 +56,10 @@ public boolean equals(Object obj) {
}

LongArrayMorpher other = (LongArrayMorpher) obj;
EqualsBuilder builder = new EqualsBuilder();
if (isUseDefault() && other.isUseDefault()) {
builder.append(getDefaultValue(), other.getDefaultValue());
return builder.isEquals();
return Objects.equals(getDefaultValue(), other.getDefaultValue());
} else if (!isUseDefault() && !other.isUseDefault()) {
return builder.isEquals();
return true;
} else {
return false;
}
Expand All @@ -77,11 +74,10 @@ public long getDefaultValue() {

@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
if (isUseDefault()) {
builder.append(getDefaultValue());
return Objects.hashCode(getDefaultValue());
}
return builder.toHashCode();
return 17;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/sf/ezmorph/array/ObjectArrayMorpher.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import java.lang.reflect.Array;
import java.lang.reflect.Method;
import java.util.Objects;
import net.sf.ezmorph.MorphException;
import net.sf.ezmorph.Morpher;
import org.apache.commons.lang.builder.HashCodeBuilder;

/**
* Morphs an array to another array using a Morpher.
Expand Down Expand Up @@ -65,7 +65,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return new HashCodeBuilder().append(morpher).toHashCode();
return Objects.hashCode(morpher);
}

@Override
Expand Down
Loading

0 comments on commit bd0068b

Please sign in to comment.