Permalink
Browse files

Updated implementors of Element for new property signatures

  • Loading branch information...
1 parent 6f9173a commit 46b02006a2bc49ccadc8f713b84e21c995b5220d @BrynCooke BrynCooke committed Mar 9, 2013
Showing with 53 additions and 53 deletions.
  1. +4 −4 blueprints-core/src/main/java/com/tinkerpop/blueprints/impls/tg/TinkerElement.java
  2. +3 −3 blueprints-core/src/main/java/com/tinkerpop/blueprints/util/wrappers/event/EventElement.java
  3. +2 −2 blueprints-core/src/main/java/com/tinkerpop/blueprints/util/wrappers/id/IdElement.java
  4. +2 −2 blueprints-core/src/main/java/com/tinkerpop/blueprints/util/wrappers/partition/PartitionElement.java
  5. +1 −1 blueprints-core/src/main/java/com/tinkerpop/blueprints/util/wrappers/readonly/ReadOnlyElement.java
  6. +2 −2 blueprints-core/src/main/java/com/tinkerpop/blueprints/util/wrappers/wrapped/WrappedElement.java
  7. +5 −5 blueprints-dex-graph/src/main/java/com/tinkerpop/blueprints/impls/dex/DexElement.java
  8. +4 −4 blueprints-neo4j-graph/src/main/java/com/tinkerpop/blueprints/impls/neo4j/Neo4jElement.java
  9. +2 −2 blueprints-neo4j-graph/src/main/java/com/tinkerpop/blueprints/impls/neo4j/batch/Neo4jBatchEdge.java
  10. +2 −2 ...rints-neo4j-graph/src/main/java/com/tinkerpop/blueprints/impls/neo4j/batch/Neo4jBatchElement.java
  11. +2 −2 ...prints-neo4j-graph/src/main/java/com/tinkerpop/blueprints/impls/neo4j/batch/Neo4jBatchVertex.java
  12. +6 −6 blueprints-orient-graph/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientElement.java
  13. +4 −4 blueprints-rexster-graph/src/main/java/com/tinkerpop/blueprints/impls/rexster/RexsterElement.java
  14. +4 −4 blueprints-sail-graph/src/main/java/com/tinkerpop/blueprints/impls/sail/SailEdge.java
  15. +10 −10 blueprints-sail-graph/src/main/java/com/tinkerpop/blueprints/impls/sail/SailVertex.java
@@ -32,8 +32,8 @@ protected TinkerElement(final String id, final TinkerGraph graph) {
return new HashSet<String>(this.properties.keySet());
}
- public Object getProperty(final String key) {
- return this.properties.get(key);
+ public <T> T getProperty(final String key) {
+ return (T) this.properties.get(key);
}
public void setProperty(final String key, final Object value) {
@@ -51,13 +51,13 @@ public void setProperty(final String key, final Object value) {
this.graph.edgeKeyIndex.autoUpdate(key, value, oldValue, (TinkerEdge) this);
}
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
Object oldValue = this.properties.remove(key);
if (this instanceof TinkerVertex)
this.graph.vertexKeyIndex.autoRemove(key, oldValue, (TinkerVertex) this);
else
this.graph.edgeKeyIndex.autoRemove(key, oldValue, (TinkerEdge) this);
- return oldValue;
+ return (T) oldValue;
}
@@ -56,7 +56,7 @@ public Object getId() {
/**
* Raises a vertexPropertyRemoved or edgePropertyRemoved event.
*/
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
final Object propertyRemoved = baseElement.removeProperty(key);
if (this instanceof Vertex) {
@@ -65,10 +65,10 @@ public Object removeProperty(final String key) {
this.onEdgePropertyRemoved((Edge) this, key, propertyRemoved);
}
- return propertyRemoved;
+ return (T) propertyRemoved;
}
- public Object getProperty(final String key) {
+ public <T> T getProperty(final String key) {
return this.baseElement.getProperty(key);
}
@@ -21,7 +21,7 @@ protected IdElement(final Element baseElement, final IdGraph idGraph) {
this.idGraph = idGraph;
}
- public Object getProperty(final String key) {
+ public <T> T getProperty(final String key) {
if (key.equals(IdGraph.ID)) {
return null;
}
@@ -45,7 +45,7 @@ public void setProperty(final String key, final Object value) {
baseElement.setProperty(key, value);
}
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
if (key.equals(IdGraph.ID)) {
throw new IllegalArgumentException("Unable to remove value for reserved property " + IdGraph.ID);
}
@@ -26,13 +26,13 @@ public void setProperty(final String key, final Object value) {
this.baseElement.setProperty(key, value);
}
- public Object getProperty(final String key) {
+ public <T> T getProperty(final String key) {
if (key.equals(this.graph.getPartitionKey()))
return null;
return this.baseElement.getProperty(key);
}
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
if (key.equals(this.graph.getPartitionKey()))
return null;
return this.baseElement.removeProperty(key);
@@ -33,7 +33,7 @@ public Object removeProperty(final String key) throws UnsupportedOperationExcept
throw new UnsupportedOperationException(ReadOnlyTokens.MUTATE_ERROR_MESSAGE);
}
- public Object getProperty(final String key) {
+ public <T> T getProperty(final String key) {
return this.baseElement.getProperty(key);
}
@@ -20,11 +20,11 @@ public void setProperty(final String key, final Object value) {
this.baseElement.setProperty(key, value);
}
- public Object getProperty(final String key) {
+ public <T> T getProperty(final String key) {
return this.baseElement.getProperty(key);
}
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
return this.baseElement.removeProperty(key);
}
@@ -90,13 +90,13 @@ protected DexElement(final DexGraph g, final long oid) {
* @see com.tinkerpop.blueprints.Element#getProperty(java.lang.String)
*/
@Override
- public Object getProperty(final String key) {
+ public <T> T getProperty(final String key) {
graph.autoStartTransaction();
int type = getObjectType();
if (key.compareTo(StringFactory.LABEL) == 0) {
com.sparsity.dex.gdb.Type tdata = graph.getRawGraph().getType(type);
- return tdata.getName();
+ return (T) tdata.getName();
}
int attr = graph.getRawGraph().findAttribute(getObjectType(), key);
if (attr == com.sparsity.dex.gdb.Attribute.InvalidAttribute) {
@@ -129,7 +129,7 @@ public Object getProperty(final String key) {
throw new UnsupportedOperationException(DexTokens.TYPE_EXCEPTION_MESSAGE);
}
}
- return result;
+ return (T) result;
}
/*
@@ -252,15 +252,15 @@ public void setProperty(final String key, final Object value) {
* com.tinkerpop.blueprints.Element#removeProperty(java.lang.String)
*/
@Override
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
graph.autoStartTransaction();
try {
Object ret = getProperty(key);
com.sparsity.dex.gdb.Value v = new com.sparsity.dex.gdb.Value();
v.setNull();
setProperty(key, v);
- return ret;
+ return (T) ret;
} catch (RuntimeException e) {
return null;
}
@@ -29,9 +29,9 @@ public Neo4jElement(final Neo4jGraph graph) {
this.graph = graph;
}
- public Object getProperty(final String key) {
+ public <T> T getProperty(final String key) {
if (this.rawElement.hasProperty(key))
- return this.rawElement.getProperty(key);
+ return (T) this.rawElement.getProperty(key);
else
return null;
}
@@ -49,12 +49,12 @@ public void setProperty(final String key, final Object value) {
this.rawElement.setProperty(key, tryConvertCollectionToArray(value));
}
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
if (!this.rawElement.hasProperty(key))
return null;
else {
this.graph.autoStartTransaction();
- return this.rawElement.removeProperty(key);
+ return (T) this.rawElement.removeProperty(key);
}
}
@@ -20,11 +20,11 @@ public Neo4jBatchEdge(final Neo4jBatchGraph graph, final Long id, final String l
this.label = label;
}
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
final Map<String, Object> properties = this.getPropertyMapClone();
final Object value = properties.remove(key);
this.graph.getRawGraph().setRelationshipProperties(this.id, properties);
- return value;
+ return (T) value;
}
@@ -30,8 +30,8 @@ public Object getId() {
return this.getPropertyMap().keySet();
}
- public Object getProperty(final String key) {
- return this.getPropertyMap().get(key);
+ public <T> T getProperty(final String key) {
+ return (T) this.getPropertyMap().get(key);
}
protected Map<String, Object> getPropertyMapClone() {
@@ -18,11 +18,11 @@ public Neo4jBatchVertex(final Neo4jBatchGraph graph, final Long id) {
super(graph, id);
}
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
final Map<String, Object> properties = this.getPropertyMapClone();
final Object value = properties.remove(key);
this.graph.getRawGraph().setNodeProperties(this.id, properties);
- return value;
+ return (T) value;
}
@@ -44,23 +44,23 @@ public void setProperty(final String key, final Object value) {
this.graph.getRawGraph().save(rawElement);
}
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
this.graph.autoStartTransaction();
final Object oldValue = this.rawElement.removeField(key);
this.save();
- return oldValue;
+ return (T) oldValue;
}
- public Object getProperty(final String key) {
+ public <T> T getProperty(final String key) {
if (key == null)
return null;
if (key.equals("_class"))
- return rawElement.getSchemaClass().getName();
+ return (T) rawElement.getSchemaClass().getName();
else if (key.equals("_version"))
- return rawElement.getVersion();
+ return (T) new Integer(rawElement.getVersion());
else if (key.equals("_rid"))
- return rawElement.getIdentity().toString();
+ return (T) rawElement.getIdentity().toString();
return this.rawElement.field(key);
}
@@ -63,7 +63,7 @@ public void remove() {
this.graph.removeEdge((Edge) this);
}
- public Object getProperty(final String key) {
+ public <T> T getProperty(final String key) {
JSONObject rawElement;
if (this instanceof Vertex)
rawElement = RestHelper.getResultObject(this.graph.getGraphURI() + RexsterTokens.SLASH_VERTICES_SLASH + RestHelper.encode(this.getId()) + RexsterTokens.QUESTION + RexsterTokens.REXSTER_SHOW_TYPES_EQUALS_TRUE);
@@ -72,7 +72,7 @@ public Object getProperty(final String key) {
JSONObject typedProperty = rawElement.optJSONObject(key);
if (null != typedProperty)
- return RestHelper.typeCast(typedProperty.optString(RexsterTokens.TYPE), typedProperty.opt(RexsterTokens.VALUE));
+ return (T) RestHelper.typeCast(typedProperty.optString(RexsterTokens.TYPE), typedProperty.opt(RexsterTokens.VALUE));
else
return null;
}
@@ -103,7 +103,7 @@ public int hashCode() {
return this.getId().hashCode();
}
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
Object object = this.getProperty(key);
@@ -112,7 +112,7 @@ public Object removeProperty(final String key) {
else
RestHelper.delete(this.graph.getGraphURI() + RexsterTokens.SLASH_EDGES_SLASH + RestHelper.encode(this.getId()) + RexsterTokens.QUESTION + RestHelper.encode(key));
- return object;
+ return (T) object;
}
public boolean equals(final Object object) {
@@ -58,13 +58,13 @@ public boolean hasNamedGraph() {
return keys;
}
- public Object getProperty(final String key) {
+ public <T> T getProperty(final String key) {
if (key.equals(SailTokens.NAMED_GRAPH)) {
Resource resource = this.rawEdge.getContext();
if (null == resource)
return null;
else
- return resource.stringValue();
+ return (T) resource.stringValue();
} else
return null;
}
@@ -84,14 +84,14 @@ public void setProperty(final String key, final Object value) {
}
}
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
if (key.equals(SailTokens.NAMED_GRAPH)) {
try {
Resource ng = this.rawEdge.getContext();
SailHelper.removeStatement(this.rawEdge, this.graph.getSailConnection().get());
this.rawEdge = new StatementImpl(this.rawEdge.getSubject(), this.rawEdge.getPredicate(), this.rawEdge.getObject());
SailHelper.addStatement(this.rawEdge, this.graph.getSailConnection().get());
- return ng;
+ return (T) ng;
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
@@ -93,7 +93,7 @@ public void setProperty(final String key, final Object value) {
}
}
- public Object removeProperty(final String key) {
+ public <T> T removeProperty(final String key) {
if (this.rawVertex instanceof Resource) {
throw new RuntimeException(URI_BLANK_NODE_PROPERTIES);
} else {
@@ -103,35 +103,35 @@ public Object removeProperty(final String key) {
this.updateLiteral(oldLiteral, (Literal) this.rawVertex);
}
if (key.equals(SailTokens.DATATYPE)) {
- return oldLiteral.getDatatype().toString();
+ return (T) oldLiteral.getDatatype().toString();
} else if (key.equals(SailTokens.LANGUAGE)) {
- return oldLiteral.getLanguage();
+ return (T) oldLiteral.getLanguage();
}
}
return null;
}
- public Object getProperty(final String key) {
+ public <T> T getProperty(final String key) {
if (key.equals(SailTokens.KIND)) {
if (this.rawVertex instanceof Literal)
- return SailTokens.LITERAL;
+ return (T) SailTokens.LITERAL;
else if (this.rawVertex instanceof URI)
- return SailTokens.URI;
+ return (T) SailTokens.URI;
else
- return SailTokens.BNODE;
+ return (T) SailTokens.BNODE;
}
if (this.rawVertex instanceof Literal) {
final Literal literal = (Literal) rawVertex;
if (key.equals(SailTokens.DATATYPE)) {
if (null != literal.getDatatype())
- return literal.getDatatype().stringValue();
+ return (T) literal.getDatatype().stringValue();
else
return null;
} else if (key.equals(SailTokens.LANGUAGE)) {
- return literal.getLanguage();
+ return (T) literal.getLanguage();
} else if (key.equals(SailTokens.VALUE)) {
- return castLiteral(literal);
+ return (T) castLiteral(literal);
}
}
return null;

0 comments on commit 46b0200

Please sign in to comment.