Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit c905b2f

Browse files
rashtaoarcanefoam
authored andcommitted
data classes refactoring
1 parent b350c80 commit c905b2f

11 files changed

+150
-331
lines changed

src/main/java/com/arangodb/tinkerpop/gremlin/client/ArangoDBBaseEdge.java

Lines changed: 0 additions & 105 deletions
This file was deleted.

src/main/java/com/arangodb/tinkerpop/gremlin/client/ArangoDBGraphClient.java

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -291,37 +291,6 @@ public void deleteDb() throws ArangoDBGraphException {
291291
}
292292
}
293293

294-
/**
295-
* Get a document from the database. The method is generic so we it can be used to retrieve
296-
* vertices, properties or variables.
297-
*
298-
* @param <V> the value type
299-
* @param id the id of the document (should be a valid ArangoDB _id)
300-
* @param collection the collection from which the document is retrieved
301-
* @param docClass the returned document class
302-
* @return the document
303-
* @throws ArangoDBGraphException If there was an error retrieving the document
304-
*/
305-
306-
public <V extends ArangoDBBaseDocument> V getDocument(
307-
String id,
308-
String collection,
309-
Class<V> docClass) {
310-
logger.debug("Get document with id {} from {}:{}", id, graph.name(), collection);
311-
V result;
312-
try {
313-
result = db.graph(graph.name())
314-
.vertexCollection(collection)
315-
.getVertex(id, docClass);
316-
} catch (ArangoDBException e) {
317-
logger.error("Failed to retrieve vertex: {}", e.getErrorMessage());
318-
throw new ArangoDBGraphException("Failed to retrieve vertex.", e);
319-
}
320-
result.collection(collection);
321-
result.graph(graph);
322-
return result;
323-
}
324-
325294
public ArangoDBGraphVariables getGraphVariables() {
326295
logger.debug("Get graph variables");
327296
ArangoDBGraphVariables result;

src/main/java/com/arangodb/tinkerpop/gremlin/jsr223/ArangoDBGremlinPlugin.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class ArangoDBGremlinPlugin extends AbstractGremlinPlugin {
3232
try {
3333
IMPORTS = DefaultImportCustomizer.build().addClassImports(
3434
ArangoDBBaseDocument.class,
35-
ArangoDBBaseEdge.class,
3635
ArangoDBGraphClient.class,
3736
ArangoDBGraphException.class,
3837
ArangoDBPropertyFilter.class,
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.arangodb.tinkerpop.gremlin.structure;
2+
3+
import com.arangodb.serde.InternalKey;
4+
import com.arangodb.serde.InternalRev;
5+
6+
import java.util.HashMap;
7+
import java.util.Map;
8+
import java.util.Objects;
9+
10+
abstract class ArangoDBData<T> {
11+
private String label;
12+
13+
@InternalKey
14+
private String key;
15+
16+
@InternalRev
17+
private String rev;
18+
19+
private Map<String, T> properties = new HashMap<>();
20+
21+
public ArangoDBData() {
22+
}
23+
24+
public ArangoDBData(String label, String key) {
25+
Objects.requireNonNull(label, "label");
26+
if (label.isEmpty()) throw new IllegalArgumentException("empty label");
27+
if (key != null && key.isEmpty()) throw new IllegalArgumentException("empty key");
28+
29+
this.label = label;
30+
this.key = key;
31+
}
32+
33+
public String getKey() {
34+
return key;
35+
}
36+
37+
public void setKey(String key) {
38+
this.key = key;
39+
}
40+
41+
public String getRev() {
42+
return rev;
43+
}
44+
45+
public void setRev(String rev) {
46+
this.rev = rev;
47+
}
48+
49+
public String getLabel() {
50+
return label;
51+
}
52+
53+
public void setLabel(String label) {
54+
this.label = label;
55+
}
56+
57+
public Map<String, T> getProperties() {
58+
if (properties == null) {
59+
properties = new HashMap<>();
60+
}
61+
return properties;
62+
}
63+
64+
public void setProperties(Map<String, T> properties) {
65+
this.properties = properties;
66+
}
67+
68+
@Override
69+
public String toString() {
70+
return "key='" + key + '\'' +
71+
", label='" + label + '\'' +
72+
", rev='" + rev + '\'' +
73+
", properties=" + properties;
74+
}
75+
76+
@Override
77+
public boolean equals(Object o) {
78+
if (o == null || getClass() != o.getClass()) return false;
79+
ArangoDBData<?> that = (ArangoDBData<?>) o;
80+
return Objects.equals(label, that.label) && Objects.equals(key, that.key) && Objects.equals(rev, that.rev) && Objects.equals(properties, that.properties);
81+
}
82+
83+
@Override
84+
public int hashCode() {
85+
return Objects.hash(label, key, rev, properties);
86+
}
87+
}

src/main/java/com/arangodb/tinkerpop/gremlin/structure/ArangoDBEdge.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ public ArangoDBEdge(final String id, final String label, final String outVertexI
6161
key = null;
6262
}
6363

64-
if (inferredLabel.isEmpty()) {
65-
throw new IllegalArgumentException("empty label");
66-
}
67-
68-
if (key != null && key.isEmpty()) {
69-
throw new IllegalArgumentException("empty key");
70-
}
71-
7264
data = new ArangoDBEdgeData(inferredLabel, key, outVertexId, inVertexId);
7365
removed = false;
7466
}
@@ -141,7 +133,7 @@ public <V> Property<V> property(final String key) {
141133

142134
@Override
143135
public Set<String> keys() {
144-
return data.keys();
136+
return data.getProperties().keySet();
145137
}
146138

147139
@Override

0 commit comments

Comments
 (0)