Skip to content

Commit

Permalink
Change Value to Object methods
Browse files Browse the repository at this point in the history
 * asPublic -> asObjectCopy
 * asLegacyObject -> asObject
  • Loading branch information
fickludd committed Jun 15, 2017
1 parent 29abf0d commit 0e149c2
Show file tree
Hide file tree
Showing 49 changed files with 204 additions and 209 deletions.
Expand Up @@ -145,7 +145,7 @@ private void verifyNodeCorrectlyIndexedUniquely( long nodeId, Value[] propertyVa
}
else
{
engine.report().uniqueIndexNotUnique( indexRule, Values.asPublic( propertyValues ), indexedNodeId );
engine.report().uniqueIndexNotUnique( indexRule, Values.asObjects( propertyValues ), indexedNodeId );
}
}

Expand All @@ -157,11 +157,11 @@ private void reportIncorrectIndexCount( Value[] propertyValues,
{
if ( count == 0 )
{
engine.report().notIndexed( indexRule, Values.asPublic( propertyValues ) );
engine.report().notIndexed( indexRule, Values.asObjects( propertyValues ) );
}
else if ( count != 1 )
{
engine.report().indexedMultipleTimes( indexRule, Values.asPublic( propertyValues ), count );
engine.report().indexedMultipleTimes( indexRule, Values.asObjects( propertyValues ), count );
}
}

Expand Down
Expand Up @@ -308,7 +308,7 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper)
}

def getProperty(id: Long, propertyKeyId: Int): Any = try {
tc.statement.readOperations().nodeGetProperty(id, propertyKeyId).asLegacyObject()
tc.statement.readOperations().nodeGetProperty(id, propertyKeyId).asObject()
} catch {
case _: org.neo4j.kernel.api.exceptions.EntityNotFoundException => null.asInstanceOf[Int]
}
Expand Down Expand Up @@ -378,7 +378,7 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper)
}

override def getProperty(id: Long, propertyKeyId: Int): Any = try {
tc.statement.readOperations().relationshipGetProperty(id, propertyKeyId).asLegacyObject()
tc.statement.readOperations().relationshipGetProperty(id, propertyKeyId).asObject()
} catch {
case _: exceptions.EntityNotFoundException => null
}
Expand Down
Expand Up @@ -304,7 +304,7 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper)
}

override def getProperty(id: Long, propertyKeyId: Int): Any = try {
txContext.statement.readOperations().nodeGetProperty(id, propertyKeyId).asLegacyObject()
txContext.statement.readOperations().nodeGetProperty(id, propertyKeyId).asObject()
} catch {
case e: org.neo4j.kernel.api.exceptions.EntityNotFoundException =>
if (isDeletedInThisTx(id))
Expand Down Expand Up @@ -379,7 +379,7 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper)
}

override def getProperty(id: Long, propertyKeyId: Int): Any = try {
txContext.statement.readOperations().relationshipGetProperty(id, propertyKeyId).asLegacyObject()
txContext.statement.readOperations().relationshipGetProperty(id, propertyKeyId).asObject()
} catch {
case e: org.neo4j.kernel.api.exceptions.EntityNotFoundException =>
if (isDeletedInThisTx(id))
Expand Down
Expand Up @@ -311,7 +311,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
}

override def getProperty(id: Long, propertyKeyId: Int): Any = try {
transactionalContext.statement.readOperations().nodeGetProperty(id, propertyKeyId).asLegacyObject()
transactionalContext.statement.readOperations().nodeGetProperty(id, propertyKeyId).asObject()
} catch {
case e: org.neo4j.kernel.api.exceptions.EntityNotFoundException =>
if (isDeletedInThisTx(id))
Expand Down Expand Up @@ -386,7 +386,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
}

override def getProperty(id: Long, propertyKeyId: Int): Any = try {
transactionalContext.statement.readOperations().relationshipGetProperty(id, propertyKeyId).asLegacyObject()
transactionalContext.statement.readOperations().relationshipGetProperty(id, propertyKeyId).asObject()
} catch {
case e: org.neo4j.kernel.api.exceptions.EntityNotFoundException =>
if (isDeletedInThisTx(id))
Expand Down
Expand Up @@ -311,7 +311,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
}

override def getProperty(id: Long, propertyKeyId: Int): Any = try {
transactionalContext.statement.readOperations().nodeGetProperty(id, propertyKeyId).asLegacyObject()
transactionalContext.statement.readOperations().nodeGetProperty(id, propertyKeyId).asObject()
} catch {
case e: org.neo4j.kernel.api.exceptions.EntityNotFoundException =>
if (isDeletedInThisTx(id))
Expand Down Expand Up @@ -385,7 +385,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
}

override def getProperty(id: Long, propertyKeyId: Int): Any = try {
transactionalContext.statement.readOperations().relationshipGetProperty(id, propertyKeyId).asLegacyObject()
transactionalContext.statement.readOperations().relationshipGetProperty(id, propertyKeyId).asObject()
} catch {
case e: org.neo4j.kernel.api.exceptions.EntityNotFoundException =>
if (isDeletedInThisTx(id))
Expand Down
Expand Up @@ -30,7 +30,6 @@
import org.neo4j.kernel.api.schema.index.IndexDescriptor;
import org.neo4j.values.TextValue;
import org.neo4j.values.Value;
import org.neo4j.values.ValueGroup;
import org.neo4j.values.ValueTuple;
import org.neo4j.values.Values;

Expand Down Expand Up @@ -295,12 +294,12 @@ public boolean test( Value value )

public Number from()
{
return (Number)from.asPublic();
return (Number)from.asObject();
}

public Number to()
{
return (Number)to.asPublic();
return (Number)to.asObject();
}

public boolean fromInclusive()
Expand Down Expand Up @@ -368,7 +367,7 @@ public boolean test( Value value )

public String from()
{
return (String)from.asPublic();
return (String)from.asObject();
}

public boolean fromInclusive()
Expand All @@ -378,7 +377,7 @@ public boolean fromInclusive()

public String to()
{
return (String)to.asPublic();
return (String)to.asObject();
}

public boolean toInclusive()
Expand Down Expand Up @@ -435,7 +434,7 @@ public IndexQueryType type()
@Override
public boolean test( Value value )
{
return value != null && Values.isTextValue( value ) && ((String)value.asPublic()).contains( contains );
return value != null && Values.isTextValue( value ) && ((String)value.asObject()).contains( contains );
}

public String contains()
Expand Down Expand Up @@ -463,7 +462,7 @@ public IndexQueryType type()
@Override
public boolean test( Value value )
{
return value != null && Values.isTextValue( value ) && ((String)value.asPublic()).endsWith( suffix );
return value != null && Values.isTextValue( value ) && ((String)value.asObject()).endsWith( suffix );
}

public String suffix()
Expand Down
Expand Up @@ -160,7 +160,7 @@ public void propertyAdded( DataWriteOperations ops, long entityId, int propertyK
if ( propertyKeysToInclude.get().contains( name ) )
{
ensureIndexExists( ops );
type.add( ops, entityId, name, value.asLegacyObject() );
type.add( ops, entityId, name, value.asObject() );
}
}
catch ( LegacyIndexNotFoundKernelException | EntityNotFoundException e )
Expand Down Expand Up @@ -189,8 +189,8 @@ public void propertyChanged( DataWriteOperations ops, long entityId, int propert
if ( propertyKeysToInclude.get().contains( name ) )
{
ensureIndexExists( ops );
type.remove( ops, entityId, name, oldValue.asLegacyObject() );
type.add( ops, entityId, name, newValue.asLegacyObject() );
type.remove( ops, entityId, name, oldValue.asObject() );
type.add( ops, entityId, name, newValue.asObject() );
}
}
catch ( LegacyIndexNotFoundKernelException | EntityNotFoundException e )
Expand Down
Expand Up @@ -106,7 +106,7 @@ public Object getProperty( String key )
throw new PropertyNotFoundException( propertyKeyId, EntityType.GRAPH, -1 );
}

return value.asPublic();
return value.asObjectCopy();
}
catch ( PropertyNotFoundException e )
{
Expand All @@ -128,7 +128,7 @@ public Object getProperty( String key, Object defaultValue )
{
int propertyKeyId = statement.readOperations().propertyKeyGetForName( key );
Value value = statement.readOperations().graphGetProperty( propertyKeyId );
return value == Values.NO_VALUE ? defaultValue : value.asPublic();
return value == Values.NO_VALUE ? defaultValue : value.asObjectCopy();
}
}

Expand Down Expand Up @@ -165,7 +165,7 @@ public Object removeProperty( String key )
try ( Statement statement = actions.statement() )
{
int propertyKeyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName( key );
return statement.dataWriteOperations().graphRemoveProperty( propertyKeyId ).asPublic();
return statement.dataWriteOperations().graphRemoveProperty( propertyKeyId ).asObjectCopy();
}
catch ( IllegalTokenNameException e )
{
Expand Down Expand Up @@ -228,7 +228,7 @@ public Map<String, Object> getAllProperties()
{
int propertyKeyId = propertyKeys.next();
properties.put( readOperations.propertyKeyGetName( propertyKeyId ),
readOperations.graphGetProperty( propertyKeyId ).asPublic() );
readOperations.graphGetProperty( propertyKeyId ).asObjectCopy() );
}
return properties;
}
Expand Down
Expand Up @@ -314,7 +314,7 @@ public Object removeProperty( String key ) throws NotFoundException
try ( Statement statement = actions.statement() )
{
int propertyKeyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName( key );
return statement.dataWriteOperations().nodeRemoveProperty( nodeId, propertyKeyId ).asPublic();
return statement.dataWriteOperations().nodeRemoveProperty( nodeId, propertyKeyId ).asObjectCopy();
}
catch ( EntityNotFoundException e )
{
Expand Down Expand Up @@ -347,7 +347,7 @@ public Object getProperty( String key, Object defaultValue )
{
int propertyKeyId = statement.readOperations().propertyKeyGetForName( key );
Value value = statement.readOperations().nodeGetProperty( nodeId, propertyKeyId );
return value == Values.NO_VALUE ? defaultValue : value.asPublic();
return value == Values.NO_VALUE ? defaultValue : value.asObjectCopy();
}
catch ( EntityNotFoundException e )
{
Expand Down Expand Up @@ -420,7 +420,7 @@ public Map<String, Object> getAllProperties()
{
String name = statement.readOperations().propertyKeyGetName(
propertyCursor.get().propertyKeyId() );
properties.put( name, propertyCursor.get().value().asPublic() );
properties.put( name, propertyCursor.get().value().asObjectCopy() );
}

return properties;
Expand Down Expand Up @@ -462,7 +462,7 @@ public Object getProperty( String key ) throws NotFoundException
throw new PropertyNotFoundException( propertyKeyId, EntityType.NODE, nodeId );
}

return value.asPublic();
return value.asObjectCopy();

}
catch ( EntityNotFoundException | PropertyNotFoundException e )
Expand Down
Expand Up @@ -52,7 +52,7 @@ static Map<String, Object> getProperties( Statement statement, Cursor<PropertyIt
{
if ( propertyKeys[i] == propertyKeyId )
{
properties.put( keys[i], propertyItem.value().asPublic() );
properties.put( keys[i], propertyItem.value().asObjectCopy() );
propertiesToFind--;
break;
}
Expand Down
Expand Up @@ -302,7 +302,7 @@ public Map<String, Object> getAllProperties()
{
String name =
statement.readOperations().propertyKeyGetName( propertyCursor.get().propertyKeyId() );
properties.put( name, propertyCursor.get().value().asPublic() );
properties.put( name, propertyCursor.get().value().asObjectCopy() );
}

return properties;
Expand Down Expand Up @@ -344,7 +344,7 @@ public Object getProperty( String key )
throw new PropertyNotFoundException( propertyId, EntityType.RELATIONSHIP, getId() );
}

return value.asPublic();
return value.asObjectCopy();
}
catch ( EntityNotFoundException | PropertyNotFoundException e )
{
Expand All @@ -366,7 +366,7 @@ public Object getProperty( String key, Object defaultValue )
{
int propertyId = statement.readOperations().propertyKeyGetForName( key );
Value value = statement.readOperations().relationshipGetProperty( getId(), propertyId );
return value == Values.NO_VALUE ? defaultValue : value.asPublic();
return value == Values.NO_VALUE ? defaultValue : value.asObjectCopy();
}
catch ( EntityNotFoundException e )
{
Expand Down Expand Up @@ -435,7 +435,7 @@ public Object removeProperty( String key )
try ( Statement statement = actions.statement() )
{
int propertyId = statement.tokenWriteOperations().propertyKeyGetOrCreateForName( key );
return statement.dataWriteOperations().relationshipRemoveProperty( getId(), propertyId ).asPublic();
return statement.dataWriteOperations().relationshipRemoveProperty( getId(), propertyId ).asObjectCopy();
}
catch ( EntityNotFoundException e )
{
Expand Down
Expand Up @@ -443,7 +443,7 @@ public String key()
@Override
public Object previouslyCommitedValue()
{
return oldValue.asPublic();
return oldValue.asObjectCopy();
}

@Override
Expand All @@ -453,7 +453,7 @@ public Object value()
{
throw new IllegalStateException( "This property has been removed, it has no value anymore." );
}
return newValue.asPublic();
return newValue.asObjectCopy();
}

@Override
Expand Down Expand Up @@ -498,7 +498,7 @@ public String key()
@Override
public Object previouslyCommitedValue()
{
return oldValue.asPublic();
return oldValue.asObjectCopy();
}

@Override
Expand All @@ -508,7 +508,7 @@ public Object value()
{
throw new IllegalStateException( "This property has been removed, it has no value anymore." );
}
return newValue.asPublic();
return newValue.asObjectCopy();
}

@Override
Expand Down
Expand Up @@ -109,9 +109,9 @@ private static long indexEntryResourceId( long labelId, long propertyKeyId, Stri

private static String stringOf( Value value )
{
if ( null != Values.NO_VALUE )
if ( value != null && value != Values.NO_VALUE )
{
return Strings.prettyPrint( value.asLegacyObject() );
return Strings.prettyPrint( value.asObject() );
}
return "";
}
Expand Down
Expand Up @@ -227,7 +227,7 @@ public static void encodeValue( PropertyBlock block, int keyId, Value value,
DynamicRecordAllocator stringAllocator, DynamicRecordAllocator arrayAllocator )
{
// TODO: use ValueWriter
Object asObject = value.asLegacyObject();
Object asObject = value.asObject();
if ( asObject instanceof String )
{ // Try short string first, i.e. inlined in the property block
String string = (String) asObject;
Expand Down
Expand Up @@ -179,7 +179,7 @@ public String toString()
result.append( ",firstDynamic=" ).append( getSingleValueLong() );
break;
default:
Object value = type.value( this, null ).asLegacyObject();
Object value = type.value( this, null ).asObject();
if ( value != null && value.getClass().isArray() )
{
int length = Array.getLength( value );
Expand Down
Expand Up @@ -629,7 +629,7 @@ private <ENTITY extends InputEntity, RECORD extends PrimitiveRecord> BiConsumer<
while ( cursor.next() )
{
scratch.add( cursor.propertyKeyId() ); // add key as int here as to have the importer use the token id
scratch.add( cursor.value().asLegacyObject() );
scratch.add( cursor.value().asObject() );
}
entity.setProperties( scratch.isEmpty() ? InputEntity.NO_PROPERTIES : scratch.toArray() );
cursor.close();
Expand Down

0 comments on commit 0e149c2

Please sign in to comment.