Skip to content

Commit

Permalink
Moved equals into children of ArrayValue
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
SaschaPeukert committed Jul 12, 2017
1 parent 228336c commit f6a5780
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 15 deletions.
Expand Up @@ -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 );
}
}
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;

import org.neo4j.values.AnyValue;
import org.neo4j.values.SequenceValue;

import static java.lang.String.format;

Expand Down Expand Up @@ -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 )
{
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;

import org.neo4j.values.AnyValue;
import org.neo4j.values.SequenceValue;

import static java.lang.String.format;

Expand Down Expand Up @@ -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 <E extends Exception> void writeTo( ValueWriter<E> writer ) throws E
{
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;

import org.neo4j.values.AnyValue;
import org.neo4j.values.SequenceValue;

import static java.lang.String.format;

Expand Down Expand Up @@ -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()
{
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;

import org.neo4j.values.AnyValue;
import org.neo4j.values.SequenceValue;

import static java.lang.String.format;

Expand Down Expand Up @@ -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 <E extends Exception> void writeTo( ValueWriter<E> writer ) throws E
{
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;

import org.neo4j.values.AnyValue;
import org.neo4j.values.SequenceValue;

import static java.lang.String.format;

Expand Down Expand Up @@ -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 <E extends Exception> void writeTo( ValueWriter<E> writer ) throws E
{
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;

import org.neo4j.values.AnyValue;
import org.neo4j.values.SequenceValue;

import static java.lang.String.format;

Expand Down Expand Up @@ -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 <E extends Exception> void writeTo( ValueWriter<E> writer ) throws E
{
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;

import org.neo4j.values.AnyValue;
import org.neo4j.values.SequenceValue;

import static java.lang.String.format;

Expand Down Expand Up @@ -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 <E extends Exception> void writeTo( ValueWriter<E> writer ) throws E
{
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;

import org.neo4j.values.AnyValue;
import org.neo4j.values.SequenceValue;

import static java.lang.String.format;

Expand Down Expand Up @@ -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 <E extends Exception> void writeTo( ValueWriter<E> writer ) throws E
{
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.Arrays;

import org.neo4j.values.AnyValue;
import org.neo4j.values.SequenceValue;

import static java.lang.String.format;

Expand Down Expand Up @@ -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()
{
Expand Down

0 comments on commit f6a5780

Please sign in to comment.