public interface PropertyContainer
nodes
and
relationships
.
Properties are key-value pairs. The keys are always strings. Valid property
value types are all the Java primitives (int
, byte
,
float
, etc), java.lang.String
s, the Spatial
and Temporal types and arrays of any of these.
The complete list of currently supported property types is:
boolean
byte
short
int
long
float
double
char
java.lang.String
org.neo4j.graphdb.spatial.Point
java.time.LocalDate
java.time.OffsetTime
java.time.LocalTime
java.time.ZonedDateTime
java.time.OffsetDateTime
and it will
be converted to a ZonedDateTime
internally.java.time.LocalDateTime
java.time.temporal.TemporalAmount
java.time.Duration
and java.time.Period
which will be converted to a single Neo4j Duration
type. This means loss of type information, so properties of this type, when read back using
getProperty
will be only of type java.time.temporal.TemporalAmount
.int[]
, String[]
or LocalTime[]
Please note that Neo4j does NOT accept arbitrary objects as property
values. setProperty()
takes a
java.lang.Object
only to avoid an explosion of overloaded
setProperty()
methods.
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
getAllProperties()
Returns all existing properties.
|
GraphDatabaseService |
getGraphDatabase()
|
Map<String,Object> |
getProperties(String... keys)
Returns specified existing properties.
|
Object |
getProperty(String key)
Returns the property value associated with the given key.
|
Object |
getProperty(String key,
Object defaultValue)
Returns the property value associated with the given key, or a default
value.
|
Iterable<String> |
getPropertyKeys()
Returns all existing property keys, or an empty iterable if this property
container has no properties.
|
boolean |
hasProperty(String key)
Returns
true if this property container has a property
accessible through the given key, false otherwise. |
Object |
removeProperty(String key)
Removes the property associated with the given key and returns the old
value.
|
void |
setProperty(String key,
Object value)
Sets the property value for the given key to
value . |
GraphDatabaseService getGraphDatabase()
boolean hasProperty(String key)
true
if this property container has a property
accessible through the given key, false
otherwise. If key is
null
, this method returns false
.key
- the property keytrue
if this property container has a property
accessible through the given key, false
otherwiseObject getProperty(String key)
String
, a Point
,
a valid temporal type, or an array of any of the valid types.
See the the class description
for a full list of known types.
If there's no property associated with key
an unchecked
exception is raised. The idiomatic way to avoid an exception for an
unknown key and instead get null
back is to use a default
value: Object valueOrNull =
nodeOrRel.getProperty( key, null )
key
- the property keyNotFoundException
- if there's no property associated with
key
Object getProperty(String key, Object defaultValue)
String
, a Point
,
a valid temporal type, or an array of any of the valid types.
See the the class description
for a full list of known types.key
- the property keydefaultValue
- the default value that will be returned if no
property value was associated with the given keyvoid setProperty(String key, Object value)
value
. The
property value must be one of the valid property types, i.e. a Java primitive,
a String
, a Point
,
a valid temporal type, or an array of any of the valid types.
See the the class description
for a full list of known types.
This means that null
is not an accepted property value.
key
- the key with which the new property value will be associatedvalue
- the new property value, of one of the valid property typesIllegalArgumentException
- if value
is of an
unsupported type (including null
)Object removeProperty(String key)
null
will be returned.key
- the property keyIterable<String> getPropertyKeys()
Map<String,Object> getProperties(String... keys)
keys
- the property keys to returnNullPointerException
- if the array of keys or any key is nullCopyright © 2002–2019 The Neo4j Graph Database Project. All rights reserved.