Skip to content

Commit

Permalink
Changed to more specific types
Browse files Browse the repository at this point in the history
Instead of returning `Value`, methods now return `ArrayValue` where possible.
  • Loading branch information
pontusmelke committed Aug 23, 2017
1 parent a89f8ee commit 649e675
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 35 deletions.
Expand Up @@ -31,6 +31,7 @@
import org.neo4j.kernel.impl.store.record.Record;
import org.neo4j.kernel.impl.util.Bits;
import org.neo4j.string.UTF8;
import org.neo4j.values.storable.ArrayValue;
import org.neo4j.values.storable.BooleanValue;
import org.neo4j.values.storable.ByteValue;
import org.neo4j.values.storable.CharValue;
Expand Down Expand Up @@ -317,7 +318,7 @@ private ByteBuffer newBiggerBuffer( int requiredCapacity )
return ByteBuffer.allocate( newCapacity ).order( ByteOrder.LITTLE_ENDIAN );
}

private static Value readArrayFromBuffer( ByteBuffer buffer )
private static ArrayValue readArrayFromBuffer( ByteBuffer buffer )
{
if ( buffer.limit() <= 0 )
{
Expand Down
Expand Up @@ -26,6 +26,7 @@

import org.neo4j.kernel.impl.store.record.PropertyBlock;
import org.neo4j.kernel.impl.util.Bits;
import org.neo4j.values.storable.ArrayValue;
import org.neo4j.values.storable.Value;
import org.neo4j.values.storable.Values;

Expand Down Expand Up @@ -60,8 +61,7 @@ void writeAll( Object array, int length, int requiredBits, Bits result )
}

@Override
public
Value createArray( int length, Bits bits, int requiredBits )
public ArrayValue createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
Expand All @@ -76,7 +76,7 @@ Value createArray( int length, Bits bits, int requiredBits )
}

@Override
public Value createEmptyArray()
public ArrayValue createEmptyArray()
{
return Values.EMPTY_BOOLEAN_ARRAY;
}
Expand Down Expand Up @@ -138,8 +138,7 @@ void writeAll( Object array, int length, int requiredBits, Bits result )
}

@Override
public
Value createArray( int length, Bits bits, int requiredBits )
public ArrayValue createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
Expand All @@ -154,7 +153,7 @@ Value createArray( int length, Bits bits, int requiredBits )
}

@Override
public Value createEmptyArray()
public ArrayValue createEmptyArray()
{
return Values.EMPTY_BYTE_ARRAY;
}
Expand Down Expand Up @@ -217,8 +216,7 @@ void writeAll( Object array, int length, int requiredBits, Bits result )
}

@Override
public
Value createArray( int length, Bits bits, int requiredBits )
public ArrayValue createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
Expand All @@ -233,7 +231,7 @@ Value createArray( int length, Bits bits, int requiredBits )
}

@Override
public Value createEmptyArray()
public ArrayValue createEmptyArray()
{
return Values.EMPTY_SHORT_ARRAY;
}
Expand Down Expand Up @@ -295,8 +293,7 @@ void writeAll( Object array, int length, int requiredBits, Bits result )
}

@Override
public
Value createArray( int length, Bits bits, int requiredBits )
public ArrayValue createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
Expand All @@ -311,7 +308,7 @@ Value createArray( int length, Bits bits, int requiredBits )
}

@Override
public Value createEmptyArray()
public ArrayValue createEmptyArray()
{
return Values.EMPTY_CHAR_ARRAY;
}
Expand Down Expand Up @@ -373,8 +370,7 @@ void writeAll( Object array, int length, int requiredBits, Bits result )
}

@Override
public
Value createArray( int length, Bits bits, int requiredBits )
public ArrayValue createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
Expand All @@ -389,7 +385,7 @@ Value createArray( int length, Bits bits, int requiredBits )
}

@Override
public Value createEmptyArray()
public ArrayValue createEmptyArray()
{
return Values.EMPTY_INT_ARRAY;
}
Expand Down Expand Up @@ -452,8 +448,7 @@ void writeAll( Object array, int length, int requiredBits, Bits result )
}

@Override
public
Value createArray( int length, Bits bits, int requiredBits )
public ArrayValue createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
Expand All @@ -468,7 +463,7 @@ Value createArray( int length, Bits bits, int requiredBits )
}

@Override
public Value createEmptyArray()
public ArrayValue createEmptyArray()
{
return Values.EMPTY_LONG_ARRAY;
}
Expand Down Expand Up @@ -531,8 +526,7 @@ void writeAll( Object array, int length, int requiredBits, Bits result )
}

@Override
public
Value createArray( int length, Bits bits, int requiredBits )
public ArrayValue createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
Expand All @@ -547,7 +541,7 @@ Value createArray( int length, Bits bits, int requiredBits )
}

@Override
public Value createEmptyArray()
public ArrayValue createEmptyArray()
{
return Values.EMPTY_FLOAT_ARRAY;
}
Expand Down Expand Up @@ -610,8 +604,7 @@ void writeAll( Object array, int length, int requiredBits, Bits result )
}

@Override
public
Value createArray( int length, Bits bits, int requiredBits )
public ArrayValue createArray( int length, Bits bits, int requiredBits )
{
if ( length == 0 )
{
Expand All @@ -626,7 +619,7 @@ Value createArray( int length, Bits bits, int requiredBits )
}

@Override
public Value createEmptyArray()
public ArrayValue createEmptyArray()
{
return Values.EMPTY_DOUBLE_ARRAY;
}
Expand Down Expand Up @@ -668,7 +661,7 @@ public int intValue()
return type.intValue();
}

public abstract Value createArray( int length, Bits bits, int requiredBits );
public abstract ArrayValue createArray( int length, Bits bits, int requiredBits );

public static boolean encode( int keyId, Object array,
PropertyBlock target, int payloadSizeInBytes )
Expand Down Expand Up @@ -818,5 +811,5 @@ public static int calculateNumberOfBlocksUsed( int arrayLength, int requiredBits

public abstract void writeAll( Object array, int length, int requiredBits, Bits result );

public abstract Value createEmptyArray();
public abstract ArrayValue createEmptyArray();
}
Expand Up @@ -51,14 +51,14 @@ public final class Values
public static final TextValue EMPTY_STRING = Values.stringValue( "" );
public static final DoubleValue E = Values.doubleValue( Math.E );
public static final DoubleValue PI = Values.doubleValue( Math.PI );
public static final Value EMPTY_SHORT_ARRAY = Values.shortArray( new short[0] );
public static final Value EMPTY_BOOLEAN_ARRAY = Values.booleanArray( new boolean[0] );
public static final Value EMPTY_BYTE_ARRAY = Values.byteArray( new byte[0] );
public static final Value EMPTY_CHAR_ARRAY = Values.charArray( new char[0] );
public static final Value EMPTY_INT_ARRAY = Values.intArray( new int[0] );
public static final Value EMPTY_LONG_ARRAY = Values.longArray( new long[0] );
public static final Value EMPTY_FLOAT_ARRAY = Values.floatArray( new float[0] );
public static final Value EMPTY_DOUBLE_ARRAY = Values.doubleArray( new double[0] );
public static final ArrayValue EMPTY_SHORT_ARRAY = Values.shortArray( new short[0] );
public static final ArrayValue EMPTY_BOOLEAN_ARRAY = Values.booleanArray( new boolean[0] );
public static final ArrayValue EMPTY_BYTE_ARRAY = Values.byteArray( new byte[0] );
public static final ArrayValue EMPTY_CHAR_ARRAY = Values.charArray( new char[0] );
public static final ArrayValue EMPTY_INT_ARRAY = Values.intArray( new int[0] );
public static final ArrayValue EMPTY_LONG_ARRAY = Values.longArray( new long[0] );
public static final ArrayValue EMPTY_FLOAT_ARRAY = Values.floatArray( new float[0] );
public static final ArrayValue EMPTY_DOUBLE_ARRAY = Values.doubleArray( new double[0] );

private Values()
{
Expand Down

0 comments on commit 649e675

Please sign in to comment.