Skip to content

Commit

Permalink
More intuitive naming and javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
craigtaverner authored and fickludd committed Jan 23, 2017
1 parent 8ef4abe commit 73b780d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
Expand Up @@ -33,7 +33,7 @@ public DuplicateEntitySchemaRuleException( EntityPropertyDescriptor descriptor )


public DuplicateEntitySchemaRuleException( EntityPropertyDescriptor descriptor, boolean unique ) public DuplicateEntitySchemaRuleException( EntityPropertyDescriptor descriptor, boolean unique )
{ {
super( "Multiple %s found for " + descriptor.entityType().getTypeDescriptor() + " '%s' and property '%s'.", super( "Multiple %s found for " + descriptor.entityType().getLabelingType() + " '%s' and property '%s'.",
descriptor, unique ? UNIQUE_CONSTRAINT_PREFIX : CONSTRAINT_PREFIX ); descriptor, unique ? UNIQUE_CONSTRAINT_PREFIX : CONSTRAINT_PREFIX );
} }


Expand Down
Expand Up @@ -31,7 +31,7 @@ public EntitySchemaRuleNotFoundException( EntityPropertyDescriptor descriptor )


public EntitySchemaRuleNotFoundException( EntityPropertyDescriptor descriptor, boolean unique ) public EntitySchemaRuleNotFoundException( EntityPropertyDescriptor descriptor, boolean unique )
{ {
super( "%s for " + descriptor.entityType().getTypeDescriptor() + " '%s' and property '%s' not found.", super( "%s for " + descriptor.entityType().getLabelingType() + " '%s' and property '%s' not found.",
descriptor, descriptor,
unique ? UNIQUE_CONSTRAINT_PREFIX : CONSTRAINT_PREFIX ); unique ? UNIQUE_CONSTRAINT_PREFIX : CONSTRAINT_PREFIX );
} }
Expand Down
Expand Up @@ -93,7 +93,7 @@ public int[] getPropertyKeyIds()
@Override @Override
public String toString() public String toString()
{ {
return format( ":%s[%d](property[%d])", entityType().getTypeDescriptor(), entityId, propertyKeyId ); return format( ":%s[%d](property[%d])", entityType().getLabelingType(), entityId, propertyKeyId );
} }


public String propertyIdText() public String propertyIdText()
Expand Down
Expand Up @@ -20,23 +20,28 @@
package org.neo4j.storageengine.api; package org.neo4j.storageengine.api;


/** /**
* Type of graph entity. * Type of graph entity. The three types, Nodes, Relationships and Graphs, represent objects that can have properties
* associated with them, as well as labeled with additional type information. Nodes have labels, and relationships
* have relationship types. Graphs can have properties, but are not labeled.
*/ */
public enum EntityType public enum EntityType
{ {
NODE( "label" ), NODE( "label" ),
RELATIONSHIP( "relationship type" ), RELATIONSHIP( "relationship type" ),
GRAPH( "graph" ); GRAPH( "" );


private final String typeDescriptor; private final String labelingType;


EntityType( String typeDescriptor ) EntityType( String labelingType )
{ {
this.typeDescriptor = typeDescriptor; this.labelingType = labelingType;
} }


public String getTypeDescriptor() /**
* @return the name of the labeling type for this entity type
*/
public String getLabelingType()
{ {
return typeDescriptor; return labelingType;
} }
} }
Expand Up @@ -1114,16 +1114,16 @@ private class BatchSchemaActions implements InternalSchemaActions
{ {
private int[] getOrCreatePropertyKeyIds( Iterable<String> properties ) private int[] getOrCreatePropertyKeyIds( Iterable<String> properties )
{ {
ArrayList<Integer> propertyKeyIds = new ArrayList<>(); return Iterables.stream( properties )
properties.forEach( index -> propertyKeyIds.add( getOrCreatePropertyKeyId( index ) ) ); .mapToInt( BatchInserterImpl.this::getOrCreatePropertyKeyId )
return propertyKeyIds.stream().mapToInt( i -> i ).toArray(); .toArray();

} }


private int[] getOrCreatePropertyKeyIds( String[] propertyKeys ) private int[] getOrCreatePropertyKeyIds( String[] properties )
{ {
return getOrCreatePropertyKeyIds( Arrays.asList( propertyKeys ) ); return Arrays.stream( properties )

.mapToInt( BatchInserterImpl.this::getOrCreatePropertyKeyId )
.toArray();
} }


@Override @Override
Expand Down

0 comments on commit 73b780d

Please sign in to comment.