Browse files

Changed directions of ConnectionMode and futher generalized Connectio…

…nsModes
  • Loading branch information...
1 parent 0f9e841 commit 6db5d14f06068b4dad87cbfec8d275143ef3d503 @NielsHoogeveen NielsHoogeveen committed Aug 10, 2011
View
BIN doc/images/connector_modes.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 src/main/java/org/neo4j/collections/graphdb/BijectiveConnectionMode.java
@@ -19,6 +19,6 @@
*/
package org.neo4j.collections.graphdb;
-public interface BijectiveConnectionMode extends InjectiveConnectionMode, SurjectiveConnectionMode{
+public interface BijectiveConnectionMode extends LeftRestrictedConnectionMode, RightRestrictedConnectionMode{
}
View
2 src/main/java/org/neo4j/collections/graphdb/Edge.java
@@ -34,6 +34,6 @@
public <T extends ConnectionMode> Iterable<Vertex> getVertices(ConnectorType<T> connectorType);
- public <U extends InjectiveConnectionMode>Vertex getVertex(ConnectorType<U> connectorType);
+ public <U extends LeftRestrictedConnectionMode>Vertex getVertex(ConnectorType<U> connectorType);
}
View
2 src/main/java/org/neo4j/collections/graphdb/InjectiveConnectionMode.java
@@ -19,6 +19,6 @@
*/
package org.neo4j.collections.graphdb;
-public interface InjectiveConnectionMode extends ConnectionMode{
+public interface InjectiveConnectionMode extends LeftUnrestrictedConnectionMode, RightRestrictedConnectionMode{
}
View
44 src/main/java/org/neo4j/collections/graphdb/LeftRestricedEdgeElement.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright (c) 2002-2011 "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 Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.neo4j.collections.graphdb;
+
+import java.util.ArrayList;
+
+public class LeftRestricedEdgeElement extends EdgeElement{
+
+ private static Iterable<Vertex> toElements(Vertex vertex){
+ ArrayList<Vertex> elements = new ArrayList<Vertex>();
+ elements.add(vertex);
+ return elements;
+ }
+
+ private final Vertex element;
+
+ public <T extends LeftRestrictedConnectionMode> LeftRestricedEdgeElement(ConnectorType<T> connector,
+ Vertex element) {
+ super(connector, toElements(element));
+ this.element = element;
+ }
+
+ public Vertex getElement(){
+ return element;
+ }
+
+}
View
24 src/main/java/org/neo4j/collections/graphdb/LeftRestrictedConnectionMode.java
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2002-2011 "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 Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.neo4j.collections.graphdb;
+
+public interface LeftRestrictedConnectionMode extends ConnectionMode {
+
+}
View
24 src/main/java/org/neo4j/collections/graphdb/LeftUnrestrictedConnectionMode.java
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2002-2011 "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 Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.neo4j.collections.graphdb;
+
+public interface LeftUnrestrictedConnectionMode extends ConnectionMode {
+
+}
View
24 src/main/java/org/neo4j/collections/graphdb/RightRestrictedConnectionMode.java
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2002-2011 "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 Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.neo4j.collections.graphdb;
+
+public interface RightRestrictedConnectionMode extends ConnectionMode {
+
+}
View
24 src/main/java/org/neo4j/collections/graphdb/RightUnrestrictedConnectionMode.java
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2002-2011 "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 Affero 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.neo4j.collections.graphdb;
+
+public interface RightUnrestrictedConnectionMode extends ConnectionMode {
+
+}
View
2 src/main/java/org/neo4j/collections/graphdb/SurjectiveConnectionMode.java
@@ -19,6 +19,6 @@
*/
package org.neo4j.collections.graphdb;
-public interface SurjectiveConnectionMode extends ConnectionMode{
+public interface SurjectiveConnectionMode extends LeftRestrictedConnectionMode, RightUnrestrictedConnectionMode{
}
View
2 src/main/java/org/neo4j/collections/graphdb/UnrestrictedConnectionMode.java
@@ -19,6 +19,6 @@
*/
package org.neo4j.collections.graphdb;
-public interface UnrestrictedConnectionMode extends ConnectionMode{
+public interface UnrestrictedConnectionMode extends LeftUnrestrictedConnectionMode, RightUnrestrictedConnectionMode{
}
View
8 src/main/java/org/neo4j/collections/graphdb/impl/BinaryConnectorTypeImpl.java
@@ -22,18 +22,18 @@
import org.neo4j.collections.graphdb.BinaryConnectorType;
import org.neo4j.collections.graphdb.ConnectionMode;
import org.neo4j.collections.graphdb.DatabaseService;
-import org.neo4j.collections.graphdb.InjectiveConnectionMode;
+import org.neo4j.collections.graphdb.SurjectiveConnectionMode;
import org.neo4j.graphdb.Node;
-public abstract class BinaryConnectorTypeImpl extends ConnectorTypeImpl<InjectiveConnectionMode> implements BinaryConnectorType{
+public abstract class BinaryConnectorTypeImpl extends ConnectorTypeImpl<SurjectiveConnectionMode> implements BinaryConnectorType{
private BinaryConnectorTypeImpl(Node node) {
super(node);
}
@Override
- public InjectiveConnectionMode getConnectionMode() {
- return ConnectionMode.INJECTIVE;
+ public SurjectiveConnectionMode getConnectionMode() {
+ return ConnectionMode.SURJECTIVE;
}
private static final String startConnectorName = "StartConnector";
View
13 src/main/java/org/neo4j/collections/graphdb/impl/BinaryEdgeImpl.java
@@ -29,7 +29,8 @@
import org.neo4j.collections.graphdb.ConnectorType;
import org.neo4j.collections.graphdb.EdgeType;
import org.neo4j.collections.graphdb.InjectiveConnectionMode;
-import org.neo4j.collections.graphdb.InjectiveEdgeElement;
+import org.neo4j.collections.graphdb.LeftRestrictedConnectionMode;
+import org.neo4j.collections.graphdb.LeftRestricedEdgeElement;
import org.neo4j.collections.graphdb.Vertex;
import org.neo4j.collections.graphdb.VertexType;
import org.neo4j.graphdb.DynamicRelationshipType;
@@ -116,8 +117,8 @@ public Node getNode() {
@Override
public Iterable<EdgeElement> getEdgeElements(){
ArrayList<EdgeElement> relements = new ArrayList<EdgeElement>();
- relements.add(new InjectiveEdgeElement(getType().getStartConnector().getConnectorType(), getStartVertex()));
- relements.add(new InjectiveEdgeElement(getType().getEndConnector().getConnectorType(), getEndVertex()));
+ relements.add(new LeftRestricedEdgeElement(getType().getStartConnector().getConnectorType(), getStartVertex()));
+ relements.add(new LeftRestricedEdgeElement(getType().getEndConnector().getConnectorType(), getEndVertex()));
return relements;
}
@@ -136,7 +137,7 @@ public Node getNode() {
}
@Override
- public <U extends InjectiveConnectionMode>Vertex getVertex(ConnectorType<U> connectorType) {
+ public <U extends LeftRestrictedConnectionMode>Vertex getVertex(ConnectorType<U> connectorType) {
if(connectorType.getName().equals(getType().getStartConnector().getName())){
return getDb().getVertex(rel.getStartNode());
}else if(connectorType.getName().equals(getType().getEndConnector().getName())){
@@ -173,10 +174,10 @@ public Vertex getStartVertex() {
}
ArrayList<EdgeElement> relements = new ArrayList<EdgeElement>();
if(includeStart){
- relements.add(new InjectiveEdgeElement(getType().getStartConnector().getConnectorType(), getStartVertex()));
+ relements.add(new LeftRestricedEdgeElement(getType().getStartConnector().getConnectorType(), getStartVertex()));
}
if(includeEnd){
- relements.add(new InjectiveEdgeElement(getType().getEndConnector().getConnectorType(), getEndVertex()));
+ relements.add(new LeftRestricedEdgeElement(getType().getEndConnector().getConnectorType(), getEndVertex()));
}
return relements;
}
View
9 src/main/java/org/neo4j/collections/graphdb/impl/BinaryEdgeTypeImpl.java
@@ -29,6 +29,7 @@
import org.neo4j.collections.graphdb.DatabaseService;
import org.neo4j.collections.graphdb.Connector;
import org.neo4j.collections.graphdb.InjectiveConnectionMode;
+import org.neo4j.collections.graphdb.SurjectiveConnectionMode;
import org.neo4j.collections.graphdb.Vertex;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.DynamicRelationshipType;
@@ -106,13 +107,13 @@ public boolean hasEdge(Vertex vertex, Direction dir) {
}
@Override
- public Connector<InjectiveConnectionMode> getStartConnector() {
- return new Connector<InjectiveConnectionMode>(BinaryConnectorTypeImpl.StartConnector.getOrCreateInstance(getDb()), this);
+ public Connector<SurjectiveConnectionMode> getStartConnector() {
+ return new Connector<SurjectiveConnectionMode>(BinaryConnectorTypeImpl.StartConnector.getOrCreateInstance(getDb()), this);
}
@Override
- public Connector<InjectiveConnectionMode> getEndConnector() {
- return new Connector<InjectiveConnectionMode>(BinaryConnectorTypeImpl.EndConnector.getOrCreateInstance(getDb()), this);
+ public Connector<SurjectiveConnectionMode> getEndConnector() {
+ return new Connector<SurjectiveConnectionMode>(BinaryConnectorTypeImpl.EndConnector.getOrCreateInstance(getDb()), this);
}
}
View
4 src/main/java/org/neo4j/collections/graphdb/impl/EdgeImpl.java
@@ -37,7 +37,7 @@
import org.neo4j.collections.graphdb.Edge;
import org.neo4j.collections.graphdb.EdgeElement;
import org.neo4j.collections.graphdb.EdgeType;
-import org.neo4j.collections.graphdb.InjectiveConnectionMode;
+import org.neo4j.collections.graphdb.LeftRestrictedConnectionMode;
import org.neo4j.collections.graphdb.Vertex;
import org.neo4j.collections.graphdb.VertexType;
@@ -194,7 +194,7 @@ public EdgeType getType() {
}
@Override
- public <U extends InjectiveConnectionMode>Vertex getVertex(ConnectorType<U> connectorType) {
+ public <U extends LeftRestrictedConnectionMode>Vertex getVertex(ConnectorType<U> connectorType) {
return getDb().getVertex(getNode().getSingleRelationship(DynamicRelationshipType.withName(getType().getName()+EDGEROLE_SEPARATOR+connectorType.getName()), Direction.OUTGOING).getEndNode());
}
View
3 src/main/java/org/neo4j/collections/graphdb/impl/NullaryEdgeImpl.java
@@ -26,6 +26,7 @@
import org.neo4j.collections.graphdb.EdgeElement;
import org.neo4j.collections.graphdb.EdgeType;
import org.neo4j.collections.graphdb.InjectiveConnectionMode;
+import org.neo4j.collections.graphdb.LeftRestrictedConnectionMode;
import org.neo4j.collections.graphdb.NullaryEdge;
import org.neo4j.collections.graphdb.Vertex;
import org.neo4j.collections.graphdb.impl.NullaryConnectorTypeImpl.NullaryConnectorType;
@@ -76,7 +77,7 @@ public boolean isType(EdgeType relType) {
}
@Override
- public <U extends InjectiveConnectionMode> Vertex getVertex(
+ public <U extends LeftRestrictedConnectionMode> Vertex getVertex(
ConnectorType<U> connectorType) {
// TODO Auto-generated method stub
return null;
View
9 src/main/java/org/neo4j/collections/graphdb/impl/PropertyImpl.java
@@ -28,7 +28,8 @@
import org.neo4j.collections.graphdb.EdgeElement;
import org.neo4j.collections.graphdb.EdgeType;
import org.neo4j.collections.graphdb.InjectiveConnectionMode;
-import org.neo4j.collections.graphdb.InjectiveEdgeElement;
+import org.neo4j.collections.graphdb.LeftRestricedEdgeElement;
+import org.neo4j.collections.graphdb.LeftRestrictedConnectionMode;
import org.neo4j.collections.graphdb.VertexType;
import org.neo4j.graphdb.Node;
import org.neo4j.collections.graphdb.Property;
@@ -136,12 +137,12 @@ public boolean isType(EdgeType relType) {
@Override
public Iterable<EdgeElement> getEdgeElements() {
ArrayList<EdgeElement> elems = new ArrayList<EdgeElement>();
- elems.add(new InjectiveEdgeElement(getType().getPropertyConnector().getConnectorType(), getVertex()));
+ elems.add(new LeftRestricedEdgeElement(getType().getPropertyConnector().getConnectorType(), getVertex()));
return elems;
}
@Override
- public <U extends InjectiveConnectionMode>Vertex getVertex(ConnectorType<U> connectorType) {
+ public <U extends LeftRestrictedConnectionMode>Vertex getVertex(ConnectorType<U> connectorType) {
if(connectorType.getName().equals(getDb().getPropertyRoleType().getName())){
return getVertex();
}else{
@@ -150,7 +151,7 @@ public boolean isType(EdgeType relType) {
}
@Override
- public Iterable<EdgeElement> getEdgeElements(ConnectorType<?>... roleType) {
+ public Iterable<EdgeElement> getEdgeElements(ConnectorType<?>... connectorType) {
return getEdgeElements();
}
View
6 src/main/java/org/neo4j/collections/graphdb/impl/SortableBinaryEdgeImpl.java
@@ -24,7 +24,7 @@
import org.neo4j.collections.graphdb.BinaryEdgeType;
import org.neo4j.collections.graphdb.EdgeType;
import org.neo4j.collections.graphdb.Vertex;
-import org.neo4j.collections.graphdb.InjectiveEdgeElement;
+import org.neo4j.collections.graphdb.LeftRestricedEdgeElement;
import org.neo4j.collections.graphdb.VertexType;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.Node;
@@ -99,8 +99,8 @@ public boolean isType(EdgeType relType) {
@Override
public Iterable<EdgeElement> getEdgeElements(){
ArrayList<EdgeElement> relements = new ArrayList<EdgeElement>();
- relements.add(new InjectiveEdgeElement(getType().getStartConnector().getConnectorType(), getDb().getVertex(rel.getStartNode())));
- relements.add(new InjectiveEdgeElement(getType().getEndConnector().getConnectorType(), getDb().getVertex(rel.getEndNode())));
+ relements.add(new LeftRestricedEdgeElement(getType().getStartConnector().getConnectorType(), getDb().getVertex(rel.getStartNode())));
+ relements.add(new LeftRestricedEdgeElement(getType().getEndConnector().getConnectorType(), getDb().getVertex(rel.getEndNode())));
return relements;
}

0 comments on commit 6db5d14

Please sign in to comment.