1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.neo4j.examples.server;
20
21 public class Relationship {
22
23 public static final String OUT = "out";
24 public static final String IN = "in";
25 public static final String BOTH = "both";
26 private String type;
27 private String direction;
28
29 public String toJsonCollection() {
30 StringBuilder sb = new StringBuilder();
31 sb.append("{ ");
32 sb.append(" \"type\" : \"" + type + "\"");
33 if(direction != null) {
34 sb.append(", \"direction\" : \"" + direction + "\"");
35 }
36 sb.append(" }");
37 return sb.toString();
38 }
39
40 public Relationship(String type, String direction) {
41 setType(type);
42 setDirection(direction);
43 }
44
45
46 public Relationship(String type) {
47 this(type, null);
48 }
49
50 public void setType(String type) {
51 this.type = type;
52 }
53
54 public void setDirection(String direction) {
55 this.direction = direction;
56 }
57 }