Spring Data Graph

org.springframework.data.neo4j.core
Interface TypeRepresentationStrategy<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>

All Known Subinterfaces:
NodeTypeRepresentationStrategy, RelationshipTypeRepresentationStrategy
All Known Implementing Classes:
IndexingNodeTypeRepresentationStrategy, IndexingRelationshipTypeRepresentationStrategy, NoopNodeTypeRepresentationStrategy, NoopRelationshipTypeRepresentationStrategy, SubReferenceNodeTypeRepresentationStrategy

public interface TypeRepresentationStrategy<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>

Strategy to handle representation of java types in the graph. Possible implementation are type/class nodes (forming an inheritance chain) that is linked to from the instance and keeps a count of the instances. Another approach could use indexing and a type property on the instance fields. Contains a callback on entity creation that can setup the type representation. The finder methods are delegated to for the appropriate calls for the strategy set for the datastore.

Since:
13.09.2010
Author:
Michael Hunger

Method Summary
 long count(Class<? extends T> entityClass)
           
<U extends T>
U
createEntity(S state)
          Instantiate the entity given its state.
<U extends T>
U
createEntity(S state, Class<U> type)
          Instantiate the entity given its state.
<U extends T>
org.neo4j.helpers.collection.ClosableIterable<U>
findAll(Class<U> clazz)
           
<U extends T>
Class<U>
getJavaType(S state)
           
 void postEntityCreation(S state, Class<? extends T> type)
          Callback for setting up and/or storing type information after creation.
 void preEntityRemoval(S state)
          Callback for cleaning up type information before removal.
<U extends T>
U
projectEntity(S state, Class<U> type)
          Instantiate the entity of the given type, with the given state as backing state.
 

Method Detail

postEntityCreation

void postEntityCreation(S state,
                        Class<? extends T> type)
Callback for setting up and/or storing type information after creation.

Parameters:
state - Backing state of entity being created
type - Type of entity being created

findAll

<U extends T> org.neo4j.helpers.collection.ClosableIterable<U> findAll(Class<U> clazz)
Parameters:
clazz - Type whose instances should be iterated over
Returns:
lazy Iterable over all instances of the given type

count

long count(Class<? extends T> entityClass)
Parameters:
entityClass -
Returns:
number of instances of this class contained in the graph

getJavaType

<U extends T> Class<U> getJavaType(S state)
Parameters:
state -
Returns:
java type that of the node entity of this node

preEntityRemoval

void preEntityRemoval(S state)
Callback for cleaning up type information before removal. If state does not have any state associated, doesn't do anything.

Parameters:
state - Backing state of entity being removed

createEntity

<U extends T> U createEntity(S state)
                         throws IllegalStateException
Instantiate the entity given its state. The type of the entity is inferred by the strategy from the state.

Type Parameters:
U - Helper parameter for castless use
Parameters:
state - Backing state of entity to be instantiated
Returns:
Entity instance
Throws:
IllegalStateException - If the strategy is unable to infer any type from the state

createEntity

<U extends T> U createEntity(S state,
                             Class<U> type)
                         throws IllegalStateException,
                                IllegalArgumentException
Instantiate the entity given its state. The type of the desired entity is also specified. If the type is not compatible with what the strategy can infer from the state, IllegalArgumentException is thrown.

Parameters:
state - Backing state of entity to be instantiated
type - Type of entity to be instantiated
Returns:
Entity instance
Throws:
IllegalStateException - If the strategy is unable to infer any type from the state
IllegalArgumentException - If the specified type does not match the inferred type

projectEntity

<U extends T> U projectEntity(S state,
                              Class<U> type)
Instantiate the entity of the given type, with the given state as backing state. No checking is done by the strategy.

Parameters:
state - Backing state of entity to be instantiated
type - Type of entity to be instantiated
Returns:
Entity instance.

Spring Data Graph

Copyright © 2011 SpringSource. All Rights Reserved.