Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove EqualsBuilder HashCodeBuilder usages #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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