Spring Data Neo4j

org.springframework.data.neo4j.fieldaccess
Interface DynamicProperties

All Known Implementing Classes:
DynamicPropertiesContainer, ManagedPrefixedDynamicProperties, PrefixedDynamicProperties

public interface DynamicProperties

A DynamicProperties property on a @NodeEntity stores all its properties dynamically on the underlying node itself.

This dynamic property only is available inside a transaction, i.e. when the entity has been saved.

The key/value pairs of the DynamicProperties property are stored on the node with the keys prefixed with the property name that is returned by DelegatingFieldAccessorFactory#getNeo4jPropertyName(Field).

 @NodeEntity
 class Person {
     String name;
     DynamicProperties personalProperties = new DynamicPropertiesContainer();
 }
 
 Person p = new Person();
 p.persist();
 p.personalProperties.setProperty("ZIP", 8000);
 p.personalProperties.setProperty("City", "Zuerich");
 
results in a node with the properties:
 "personalProperties-ZIP" => 8000
 "personalProperties-City" => "Zuerich"
 


Method Summary
 Map<String,Object> asMap()
           
 DynamicProperties createFrom(Map<String,Object> map)
          Creates a new instance with the properties set from the given map with setPropertiesFrom(Map)
 Object getProperty(String key)
           
 Object getProperty(String key, Object defaultValue)
           
 Iterable<String> getPropertyKeys()
          Returns all keys
 boolean hasProperty(String key)
           
 Object removeProperty(String key)
          Removes the property with the given key
 void setPropertiesFrom(Map<String,Object> map)
          Sets a property for all key/value pairs in the given map
 void setProperty(String key, Object value)
          Set the value of the property with the given key to the given value and overwrites it when such a property already exists.
 

Method Detail

hasProperty

boolean hasProperty(String key)
Parameters:
key - the key to be checked
Returns:
true if a property with the given key exists

getProperty

Object getProperty(String key)
Parameters:
key - key of the property to get
Returns:
the property with the given key, or null if no such property exists and hasProperty(java.lang.String) returns false

getProperty

Object getProperty(String key,
                   Object defaultValue)
Parameters:
key - key of the property to get
defaultValue - the default value to return if no property with the given key exists
Returns:
the property with the given key or defaultValue if no such property exists and hasProperty(java.lang.String) returns false

setProperty

void setProperty(String key,
                 Object value)
Set the value of the property with the given key to the given value and overwrites it when such a property already exists.

Parameters:
key - key of the property
value - value of the property

removeProperty

Object removeProperty(String key)
Removes the property with the given key

Parameters:
key -
Returns:
the property that has been removed or null if no such property exists and hasProperty(java.lang.String) returns false

getPropertyKeys

Iterable<String> getPropertyKeys()
Returns all keys

Returns:
iterable over all keys

asMap

Map<String,Object> asMap()
Returns:
a map with all properties key/value pairs

setPropertiesFrom

void setPropertiesFrom(Map<String,Object> map)
Sets a property for all key/value pairs in the given map

Parameters:
map - that contains the key/value pairs to set

createFrom

DynamicProperties createFrom(Map<String,Object> map)
Creates a new instance with the properties set from the given map with setPropertiesFrom(Map)

Parameters:
map - that contains the key/value pairs to set
Returns:
a new DynamicProperties instance

Spring Data Neo4j

Copyright © 2012 SpringSource. All Rights Reserved.