public static Direction parseDirection(String direction) { if (direction == null || direction.isEmpty()) { return Direction.BOTH; } try { return Direction.valueOf(direction); } catch (Exception e) { throw new IllegalArgumentException(String.format( "Direction value must be in [OUT, IN, BOTH], " + "but got '%s'", direction)); } }
@Override public EdgeLabel make() { TypeDefinitionMap definition = makeDefinition(); Preconditions.checkArgument(unidirectionality==Direction.BOTH || !getMultiplicity().isUnique(unidirectionality.opposite()), "Unidirectional labels cannot have restricted multiplicity at the other end"); Preconditions.checkArgument(unidirectionality==Direction.BOTH || !hasSortKey() || !getMultiplicity().isUnique(unidirectionality), "Unidirectional labels with restricted multiplicity cannot have a sort key"); Preconditions.checkArgument(unidirectionality!=Direction.IN || definition.getValue(INVISIBLE,Boolean.class)); definition.setValue(UNIDIRECTIONAL, unidirectionality); return tx.makeEdgeLabel(getName(), definition); }
public Builder direction(final Direction direction) { configuration.setProperty(DIRECTION_CFG_KEY, direction.toString()); return this; } }
@Override public int hashCode() { int result = super.hashCode() ^ this.direction.hashCode() ^ this.returnClass.hashCode(); for (final String edgeLabel : this.edgeLabels) { result ^= edgeLabel.hashCode(); } return result; }
@Override public EdgeLabel make() { TypeDefinitionMap definition = makeDefinition(); Preconditions.checkArgument(unidirectionality==Direction.BOTH || !getMultiplicity().isUnique(unidirectionality.opposite()), "Unidirectional labels cannot have restricted multiplicity at the other end"); Preconditions.checkArgument(unidirectionality==Direction.BOTH || !hasSortKey() || !getMultiplicity().isUnique(unidirectionality), "Unidirectional labels with restricted multiplicity cannot have a sort key"); Preconditions.checkArgument(unidirectionality!=Direction.IN || definition.getValue(INVISIBLE,Boolean.class)); definition.setValue(UNIDIRECTIONAL, unidirectionality); return tx.makeEdgeLabel(getName(), definition); }
public Builder direction(final Direction direction) { configuration.setProperty(DIRECTION_CFG_KEY, direction.toString()); return this; } }
@Override public int hashCode() { return super.hashCode() ^ this.direction.hashCode(); }
public static org.neo4j.tinkerpop.api.Neo4jDirection mapDirection(final Direction direction) { if (direction.equals(Direction.OUT)) return org.neo4j.tinkerpop.api.Neo4jDirection.OUTGOING; else if (direction.equals(Direction.IN)) return org.neo4j.tinkerpop.api.Neo4jDirection.INCOMING; else return org.neo4j.tinkerpop.api.Neo4jDirection.BOTH; }
@Override public void loadState(final Graph graph, final Configuration configuration) { direction = Direction.valueOf(configuration.getString(DIRECTION_CFG_KEY)); switch (direction) { case IN: this.messageScope = this.inMessageScope; break; case OUT: this.messageScope = this.outMessageScope; break; case BOTH: this.messageScope = this.bothMessageScope; break; default: throw new IllegalStateException("Should not reach this point!"); } }
private void internalToString(StringBuilder sb) { if (sb.length() > 0) { sb.append("\n"); } for (int i = 0; i < this.stepDepth; i++) { sb.append("\t"); } sb.append(this.schemaTable.toString()).append(" ") .append(this.stepDepth).append(" ") .append(this.hasContainers.toString()).append(" ") .append("Comparators = ") .append(this.sqlgComparatorHolder.toString()).append(" ") .append("Range = ") .append(String.valueOf(this.sqlgRangeHolder.getRange())).append(" ") .append(this.direction != null ? this.direction.toString() : "").append(" ") .append("isVertexStep = ").append(this.isEdgeVertexStep()) .append(" isUntilFirst = ").append(this.isUntilFirst()) .append(" labels = ").append(this.labels); for (SchemaTableTree child : children) { child.internalToString(sb); } }
@Override public int hashCode() { int result = super.hashCode() ^ this.direction.hashCode() ^ this.returnClass.hashCode(); for (final String edgeLabel : this.edgeLabels) { result ^= edgeLabel.hashCode(); } return result; }
/** * Checks whether a given step is optimizable or not. * * @param step1 an edge-emitting step * @param step2 a vertex-emitting step * @return <code>true</code> if step1 is not labeled and emits edges and step2 emits vertices, * otherwise <code>false</code> */ private static boolean isOptimizable(final Step step1, final Step step2) { if (step1 instanceof VertexStep && ((VertexStep) step1).returnsEdge() && step1.getLabels().isEmpty()) { final Direction step1Dir = ((VertexStep) step1).getDirection(); if (step1Dir.equals(Direction.BOTH)) { return step2 instanceof EdgeOtherVertexStep; } return step2 instanceof EdgeOtherVertexStep || (step2 instanceof EdgeVertexStep && ((EdgeVertexStep) step2).getDirection().equals(step1Dir.opposite())); } return false; }
@Override public void loadState(final Graph graph, final Configuration configuration) { direction = Direction.valueOf(configuration.getString(DIRECTION_CFG_KEY)); switch (direction) { case IN: this.messageScope = this.inMessageScope; break; case OUT: this.messageScope = this.outMessageScope; break; case BOTH: this.messageScope = this.bothMessageScope; break; default: throw new IllegalStateException("Should not reach this point!"); } }
private void internalToString(StringBuilder sb) { if (sb.length() > 0) { sb.append("\n"); } for (int i = 0; i < this.stepDepth; i++) { sb.append("\t"); } sb.append(this.schemaTable.toString()).append(" ") .append(this.stepDepth).append(" ") .append(this.hasContainers.toString()).append(" ") .append("Comparators = ") .append(this.sqlgComparatorHolder.toString()).append(" ") .append("Range = ") .append(String.valueOf(this.sqlgRangeHolder.getRange())).append(" ") .append(this.direction != null ? this.direction.toString() : "").append(" ") .append("isVertexStep = ").append(this.isEdgeVertexStep()) .append(" isUntilFirst = ").append(this.isUntilFirst()) .append(" labels = ").append(this.labels); for (SchemaTableTree child : children) { child.internalToString(sb); } }