From f6a57807a561ae9bc55dfc00e745e1595dc48d65 Mon Sep 17 00:00:00 2001 From: Sascha Peukert Date: Wed, 12 Jul 2017 15:06:49 +0200 Subject: [PATCH] Moved equals into children of ArrayValue I did not particularly like this change, but there seems to be no good way that would make the checkstyle rule 'EqualsHashCode' happy ("all classes that overwrite one of those methods, must also overwrite the other" -> but there is no good way to overwrite hashCode in ArrayValue because inheritance) --- .../org/neo4j/values/storable/ArrayValue.java | 15 --------------- .../org/neo4j/values/storable/BooleanArray.java | 16 ++++++++++++++++ .../org/neo4j/values/storable/ByteArray.java | 16 ++++++++++++++++ .../org/neo4j/values/storable/CharArray.java | 16 ++++++++++++++++ .../org/neo4j/values/storable/DoubleArray.java | 16 ++++++++++++++++ .../org/neo4j/values/storable/FloatArray.java | 16 ++++++++++++++++ .../java/org/neo4j/values/storable/IntArray.java | 16 ++++++++++++++++ .../org/neo4j/values/storable/LongArray.java | 16 ++++++++++++++++ .../org/neo4j/values/storable/ShortArray.java | 16 ++++++++++++++++ .../org/neo4j/values/storable/StringArray.java | 16 ++++++++++++++++ 10 files changed, 144 insertions(+), 15 deletions(-) diff --git a/community/values/src/main/java/org/neo4j/values/storable/ArrayValue.java b/community/values/src/main/java/org/neo4j/values/storable/ArrayValue.java index 8bd69aecb54ff..6f2ea03501e73 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/ArrayValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/ArrayValue.java @@ -49,19 +49,4 @@ public boolean isSequenceValue() { return true; } - - @Override - public final boolean equals( Object other ) - { - if ( other == null ) - { - return false; - } - - if ( other instanceof SequenceValue ) - { - return this.equals( (SequenceValue) other ); - } - return other instanceof Value && equals( (Value) other ); - } } diff --git a/community/values/src/main/java/org/neo4j/values/storable/BooleanArray.java b/community/values/src/main/java/org/neo4j/values/storable/BooleanArray.java index b958ee73f4fac..63b86b2df2cdd 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/BooleanArray.java +++ b/community/values/src/main/java/org/neo4j/values/storable/BooleanArray.java @@ -22,6 +22,7 @@ import java.util.Arrays; import org.neo4j.values.AnyValue; +import org.neo4j.values.SequenceValue; import static java.lang.String.format; @@ -148,6 +149,21 @@ public String prettyPrint() return Arrays.toString( value() ); } + @Override + public final boolean equals( Object other ) + { + if ( other == null ) + { + return false; + } + + if ( other instanceof SequenceValue ) + { + return this.equals( (SequenceValue) other ); + } + return other instanceof Value && equals( (Value) other ); + } + @Override public AnyValue value( int position ) { diff --git a/community/values/src/main/java/org/neo4j/values/storable/ByteArray.java b/community/values/src/main/java/org/neo4j/values/storable/ByteArray.java index 0258deb2553ca..e8d6f23689bf3 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/ByteArray.java +++ b/community/values/src/main/java/org/neo4j/values/storable/ByteArray.java @@ -22,6 +22,7 @@ import java.util.Arrays; import org.neo4j.values.AnyValue; +import org.neo4j.values.SequenceValue; import static java.lang.String.format; @@ -89,6 +90,21 @@ public boolean equals( double[] x ) return PrimitiveArrayValues.equals( value(), x ); } + @Override + public final boolean equals( Object other ) + { + if ( other == null ) + { + return false; + } + + if ( other instanceof SequenceValue ) + { + return this.equals( (SequenceValue) other ); + } + return other instanceof Value && equals( (Value) other ); + } + @Override public void writeTo( ValueWriter writer ) throws E { diff --git a/community/values/src/main/java/org/neo4j/values/storable/CharArray.java b/community/values/src/main/java/org/neo4j/values/storable/CharArray.java index d3637616000f3..928fa78ad088c 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/CharArray.java +++ b/community/values/src/main/java/org/neo4j/values/storable/CharArray.java @@ -22,6 +22,7 @@ import java.util.Arrays; import org.neo4j.values.AnyValue; +import org.neo4j.values.SequenceValue; import static java.lang.String.format; @@ -54,6 +55,21 @@ public boolean equals( String[] x ) return PrimitiveArrayValues.equals( value(), x ); } + @Override + public final boolean equals( Object other ) + { + if ( other == null ) + { + return false; + } + + if ( other instanceof SequenceValue ) + { + return this.equals( (SequenceValue) other ); + } + return other instanceof Value && equals( (Value) other ); + } + @Override public int hashCode() { diff --git a/community/values/src/main/java/org/neo4j/values/storable/DoubleArray.java b/community/values/src/main/java/org/neo4j/values/storable/DoubleArray.java index 16489b6ed2673..071298d5a4ca5 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/DoubleArray.java +++ b/community/values/src/main/java/org/neo4j/values/storable/DoubleArray.java @@ -22,6 +22,7 @@ import java.util.Arrays; import org.neo4j.values.AnyValue; +import org.neo4j.values.SequenceValue; import static java.lang.String.format; @@ -89,6 +90,21 @@ public boolean equals( double[] x ) return Arrays.equals( x, value() ); } + @Override + public final boolean equals( Object other ) + { + if ( other == null ) + { + return false; + } + + if ( other instanceof SequenceValue ) + { + return this.equals( (SequenceValue) other ); + } + return other instanceof Value && equals( (Value) other ); + } + @Override public void writeTo( ValueWriter writer ) throws E { diff --git a/community/values/src/main/java/org/neo4j/values/storable/FloatArray.java b/community/values/src/main/java/org/neo4j/values/storable/FloatArray.java index 617f181bfc668..9a9c7f1b5e247 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/FloatArray.java +++ b/community/values/src/main/java/org/neo4j/values/storable/FloatArray.java @@ -22,6 +22,7 @@ import java.util.Arrays; import org.neo4j.values.AnyValue; +import org.neo4j.values.SequenceValue; import static java.lang.String.format; @@ -89,6 +90,21 @@ public boolean equals( double[] x ) return PrimitiveArrayValues.equals( value(), x ); } + @Override + public final boolean equals( Object other ) + { + if ( other == null ) + { + return false; + } + + if ( other instanceof SequenceValue ) + { + return this.equals( (SequenceValue) other ); + } + return other instanceof Value && equals( (Value) other ); + } + @Override public void writeTo( ValueWriter writer ) throws E { diff --git a/community/values/src/main/java/org/neo4j/values/storable/IntArray.java b/community/values/src/main/java/org/neo4j/values/storable/IntArray.java index cb0eacbe37634..f21702ff80dfc 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/IntArray.java +++ b/community/values/src/main/java/org/neo4j/values/storable/IntArray.java @@ -22,6 +22,7 @@ import java.util.Arrays; import org.neo4j.values.AnyValue; +import org.neo4j.values.SequenceValue; import static java.lang.String.format; @@ -89,6 +90,21 @@ public boolean equals( double[] x ) return PrimitiveArrayValues.equals( value(), x ); } + @Override + public final boolean equals( Object other ) + { + if ( other == null ) + { + return false; + } + + if ( other instanceof SequenceValue ) + { + return this.equals( (SequenceValue) other ); + } + return other instanceof Value && equals( (Value) other ); + } + @Override public void writeTo( ValueWriter writer ) throws E { diff --git a/community/values/src/main/java/org/neo4j/values/storable/LongArray.java b/community/values/src/main/java/org/neo4j/values/storable/LongArray.java index dc01ce0437a4d..b7f4b88dc96e4 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/LongArray.java +++ b/community/values/src/main/java/org/neo4j/values/storable/LongArray.java @@ -22,6 +22,7 @@ import java.util.Arrays; import org.neo4j.values.AnyValue; +import org.neo4j.values.SequenceValue; import static java.lang.String.format; @@ -89,6 +90,21 @@ public boolean equals( double[] x ) return PrimitiveArrayValues.equals( value(), x ); } + @Override + public final boolean equals( Object other ) + { + if ( other == null ) + { + return false; + } + + if ( other instanceof SequenceValue ) + { + return this.equals( (SequenceValue) other ); + } + return other instanceof Value && equals( (Value) other ); + } + @Override public void writeTo( ValueWriter writer ) throws E { diff --git a/community/values/src/main/java/org/neo4j/values/storable/ShortArray.java b/community/values/src/main/java/org/neo4j/values/storable/ShortArray.java index f77274f8a6e11..dca565431ec64 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/ShortArray.java +++ b/community/values/src/main/java/org/neo4j/values/storable/ShortArray.java @@ -22,6 +22,7 @@ import java.util.Arrays; import org.neo4j.values.AnyValue; +import org.neo4j.values.SequenceValue; import static java.lang.String.format; @@ -89,6 +90,21 @@ public boolean equals( double[] x ) return PrimitiveArrayValues.equals( value(), x ); } + @Override + public final boolean equals( Object other ) + { + if ( other == null ) + { + return false; + } + + if ( other instanceof SequenceValue ) + { + return this.equals( (SequenceValue) other ); + } + return other instanceof Value && equals( (Value) other ); + } + @Override public void writeTo( ValueWriter writer ) throws E { diff --git a/community/values/src/main/java/org/neo4j/values/storable/StringArray.java b/community/values/src/main/java/org/neo4j/values/storable/StringArray.java index da1087680f0f9..c30b685a2a5e3 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/StringArray.java +++ b/community/values/src/main/java/org/neo4j/values/storable/StringArray.java @@ -22,6 +22,7 @@ import java.util.Arrays; import org.neo4j.values.AnyValue; +import org.neo4j.values.SequenceValue; import static java.lang.String.format; @@ -59,6 +60,21 @@ public boolean equals( String[] x ) return Arrays.equals( value(), x ); } + @Override + public final boolean equals( Object other ) + { + if ( other == null ) + { + return false; + } + + if ( other instanceof SequenceValue ) + { + return this.equals( (SequenceValue) other ); + } + return other instanceof Value && equals( (Value) other ); + } + @Override public int hashCode() {