Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ConstraintDescriptor subclasses for increased type safety
- Pushed final boundary in ConstrainSemantics - Fixed some trailing TODOs
- Loading branch information
Showing
23 changed files
with
300 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...in/java/org/neo4j/kernel/api/schema_new/constaints/NodeExistenceConstraintDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,51 @@ | |||
/* | |||
* Copyright (c) 2002-2017 "Neo Technology," | |||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | |||
* | |||
* This file is part of Neo4j. | |||
* | |||
* Neo4j is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
package org.neo4j.kernel.api.schema_new.constaints; | |||
|
|||
import org.neo4j.kernel.api.TokenNameLookup; | |||
import org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor; | |||
|
|||
public class NodeExistenceConstraintDescriptor extends ConstraintDescriptor | |||
{ | |||
private LabelSchemaDescriptor schema; | |||
|
|||
NodeExistenceConstraintDescriptor( LabelSchemaDescriptor schema ) | |||
{ | |||
super( Type.EXISTS ); | |||
this.schema = schema; | |||
} | |||
|
|||
@Override | |||
public LabelSchemaDescriptor schema() | |||
{ | |||
return schema; | |||
} | |||
|
|||
@Override | |||
public String prettyPrint( TokenNameLookup tokenNameLookup ) | |||
{ | |||
String labelName = escapeLabelOrRelTyp( tokenNameLookup.labelGetName( schema.getLabelId() ) ); | |||
String nodeName = labelName.toLowerCase(); | |||
String propertyName = tokenNameLookup.propertyKeyGetName( schema.getPropertyId() ); | |||
|
|||
return String.format( "CONSTRAINT ON ( %s:%s ) ASSERT exists(%s.%s)", | |||
nodeName, labelName, nodeName, propertyName ); | |||
} | |||
} |
51 changes: 51 additions & 0 deletions
51
...ain/java/org/neo4j/kernel/api/schema_new/constaints/RelExistenceConstraintDescriptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,51 @@ | |||
/* | |||
* Copyright (c) 2002-2017 "Neo Technology," | |||
* Network Engine for Objects in Lund AB [http://neotechnology.com] | |||
* | |||
* This file is part of Neo4j. | |||
* | |||
* Neo4j is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
package org.neo4j.kernel.api.schema_new.constaints; | |||
|
|||
import org.neo4j.kernel.api.TokenNameLookup; | |||
import org.neo4j.kernel.api.schema_new.RelationTypeSchemaDescriptor; | |||
|
|||
public class RelExistenceConstraintDescriptor extends ConstraintDescriptor | |||
{ | |||
private final RelationTypeSchemaDescriptor schema; | |||
|
|||
RelExistenceConstraintDescriptor( RelationTypeSchemaDescriptor schema ) | |||
{ | |||
super( Type.EXISTS ); | |||
this.schema = schema; | |||
} | |||
|
|||
@Override | |||
public RelationTypeSchemaDescriptor schema() | |||
{ | |||
return schema; | |||
} | |||
|
|||
@Override | |||
public String prettyPrint( TokenNameLookup tokenNameLookup ) | |||
{ | |||
String typeName = escapeLabelOrRelTyp( tokenNameLookup.relationshipTypeGetName( schema.getRelTypeId() ) ); | |||
String relName = typeName.toLowerCase(); | |||
String propertyName = tokenNameLookup.propertyKeyGetName( schema.getPropertyId() ); | |||
|
|||
return String.format( "CONSTRAINT ON ()-[ %s:%s ]-() ASSERT exists(%s.%s)", | |||
relName, typeName, relName, propertyName ); | |||
} | |||
} |
Oops, something went wrong.