public Node getOrCreateNode(String indexName, String key, Object value, final Map<String, Object> nodeProperties, final Collection<String> labels) {
     if (indexName ==null || key == null || value==null) throw new IllegalArgumentException("Unique index "+ indexName +" key "+key+" value must not be null");
     if (value instanceof Number) value= ValueContext.numeric((Number)value);
     UniqueFactory.UniqueNodeFactory factory = new UniqueFactory.UniqueNodeFactory(delegate, indexName) {
         protected void initialize(Node node, Map<String, Object> _) {
             setProperties(node,nodeProperties);
             setLabels(node,labels);
         }
     };
     return factory.getOrCreate(key, value);
 }
 @Override
 public Relationship getOrCreateRelationship(String indexName, String key, Object value, final Node startNode, final Node endNode, final String type, final Map<String, Object> properties) {
     if (indexName ==null || key == null || value==null) throw new IllegalArgumentException("Unique index "+ indexName +" key "+key+" value must not be null");
     if (startNode ==null || endNode == null || type==null) throw new IllegalArgumentException("StartNode "+ startNode +" EndNode "+ endNode +" and type "+type+" must not be null");
     if (value instanceof Number) value= ValueContext.numeric((Number)value);
     UniqueFactory.UniqueRelationshipFactory factory = new UniqueFactory.UniqueRelationshipFactory(delegate, indexName) {
         @Override
         protected Relationship create(Map<String, Object> _) {
             final Relationship relationship = startNode.createRelationshipTo(endNode, DynamicRelationshipType.withName(type));
             return setProperties(relationship, properties);
         }
     };
     return factory.getOrCreate(key, value);
 }