Unverified Commit 2d17f476 authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman 💥 Committed by GitHub
Browse files

Merge pull request #40 from jsight/patch-1

Allow the value to a setter to be null
parents 3fc3931a 480a517d
......@@ -3,3 +3,6 @@ target/
.project
.settings
site
.idea/
ferma.iml
......@@ -362,7 +362,7 @@ public class AdjacencyMethodHandler extends AbstractMethodHandler {
default:
throw new IllegalStateException("Direction not recognized.");
}
}).next(VertexFrame.class);
}).nextOrDefault(VertexFrame.class, null);
}
}
......@@ -645,16 +645,20 @@ public class AdjacencyMethodHandler extends AbstractMethodHandler {
switch (direction) {
case BOTH:
thiz.unlinkBoth(null, label);
thiz.getGraph().addFramedEdge(vertexFrame, thiz, label);
thiz.getGraph().addFramedEdge(thiz, vertexFrame, label);
if (vertexFrame != null) {
thiz.getGraph().addFramedEdge(vertexFrame, thiz, label);
thiz.getGraph().addFramedEdge(thiz, vertexFrame, label);
}
break;
case IN:
thiz.unlinkIn(null, label);
thiz.getGraph().addFramedEdge(vertexFrame, thiz, label);
if (vertexFrame != null)
thiz.getGraph().addFramedEdge(vertexFrame, thiz, label);
break;
case OUT:
thiz.unlinkOut(null, label);
thiz.getGraph().addFramedEdge(thiz, vertexFrame, label);
if (vertexFrame != null)
thiz.getGraph().addFramedEdge(thiz, vertexFrame, label);
break;
default:
throw new IllegalStateException(method.getName() + " is annotated with a direction other than BOTH, IN, or OUT.");
......
......@@ -323,6 +323,26 @@ public class AdjacencyMethodHandlerTest {
Assert.assertTrue(child instanceof GodExtended);
}
@Test
public void testSetSonNull() {
GodGraphLoader.load(godGraph);
final FramedGraph framedGraph = new DelegatingFramedGraph(godGraph, TEST_TYPES);
final List<? extends God> gods = framedGraph.traverse(
input -> input.V().has("name", "jupiter")).toList(God.class);
final God father = gods.iterator().next();
Assert.assertTrue(father != null);
final VertexFrame fatherVertex = father;
Assert.assertEquals(fatherVertex.getProperty("name"), "jupiter");
father.setSon(null);
final God sonNull = father.getSon();
Assert.assertNull(sonNull);
}
@Test
public void testAddSonDefault() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment