Skip to content

Commit

Permalink
Add transaction checks to the new IndexDefinition methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvest committed Aug 9, 2018
1 parent 4004cc2 commit a222a17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,21 @@

import org.neo4j.graphdb.schema.IndexDefinition;

import static org.neo4j.graphdb.FacadeMethod.consume;

public enum IndexDefinitionFacadeMethods implements Consumer<IndexDefinition>
{
GET_LABEL( new FacadeMethod<>( "Label getLabel()", IndexDefinition::getLabel ) ),
GET_LABELS( new FacadeMethod<>( "Iterable<Label> getLabels()", self -> consume( self.getLabels() ) ) ),
GET_RELATIONSHIP_TYPE( new FacadeMethod<>( "RelationshipType getRelationshipType()", IndexDefinition::getRelationshipType ) ),
GET_RELATIONSHIP_TYPES( new FacadeMethod<>( "Iterable<RelationshipType> getRelationshipTypes()", self -> consume( self.getRelationshipTypes() ) ) ),
GET_PROPERTY_KEYS( new FacadeMethod<>( "Iterable<String> getPropertyKeys()", IndexDefinition::getPropertyKeys ) ),
DROP( new FacadeMethod<>( "void drop()", IndexDefinition::drop ) ),
IS_CONSTRAINT_INDEX( new FacadeMethod<>( "boolean isConstraintIndex()", IndexDefinition::isConstraintIndex ) );
IS_CONSTRAINT_INDEX( new FacadeMethod<>( "boolean isConstraintIndex()", IndexDefinition::isConstraintIndex ) ),
IS_NODE_INDEX( new FacadeMethod<>( "boolean isNodeIndex()", IndexDefinition::isNodeIndex ) ),
IS_RELATIONSHIP_INDEX( new FacadeMethod<>( "boolean isRelationshipIndex()", IndexDefinition::isRelationshipIndex ) ),
IS_MULTI_TOKEN_INDEX( new FacadeMethod<>( "boolean isMultiTokenIndex()", IndexDefinition::isMultiTokenIndex ) ),
IS_COMPOSITE_INDEX( new FacadeMethod<>( "boolean isCompositeIndex()", IndexDefinition::isCompositeIndex ) );

private final FacadeMethod<IndexDefinition> facadeMethod;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,28 @@ public boolean isConstraintIndex()
@Override
public boolean isNodeIndex()
{
assertInUnterminatedTransaction();
return labels != null;
}

@Override
public boolean isRelationshipIndex()
{
assertInUnterminatedTransaction();
return relTypes != null;
}

@Override
public boolean isMultiTokenIndex()
{
assertInUnterminatedTransaction();
return labels != null ? labels.length > 1 : relTypes.length > 1;
}

@Override
public boolean isCompositeIndex()
{
assertInUnterminatedTransaction();
return propertyKeys.length > 1;
}

Expand Down

0 comments on commit a222a17

Please sign in to comment.