Spring Data Graph

org.springframework.data.graph.neo4j.finder
Class AbstractFinder<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>

java.lang.Object
  extended by org.springframework.data.graph.neo4j.finder.AbstractFinder<S,T>
Type Parameters:
T - GraphBacked target of this finder, enables the finder methods to return this concrete type
S - Type of backing state, either Node or Relationship
All Implemented Interfaces:
Finder<S,T>
Direct Known Subclasses:
NodeFinder, RelationshipFinder

public abstract class AbstractFinder<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>
extends Object
implements Finder<S,T>

Repository like finder for Node and Relationship-Entities. Provides finder methods for direct access, access via NodeTypeStrategy and indexing.


Field Summary
protected  Class<T> clazz
          Target graphbacked type
protected  GraphDatabaseContext graphDatabaseContext
           
 
Constructor Summary
AbstractFinder(GraphDatabaseContext graphDatabaseContext, Class<T> clazz)
           
 
Method Summary
 long count()
           
protected  T createEntity(S node)
           
protected
<T extends Number>
org.apache.lucene.search.NumericRangeQuery<T>
createInclusiveRangeQuery(String property, Number from, Number to)
           
 Iterable<T> findAll()
           
 Iterable<T> findAllByPropertyValue(String indexName, String property, Object value)
          Index based exact finder.
 Iterable<T> findAllByQuery(String indexName, String key, Object query)
          Index based fulltext / query object finder.
 Iterable<T> findAllByRange(String indexName, String property, Number from, Number to)
           
 T findById(long id)
           
 T findByPropertyValue(String indexName, String property, Object value)
          Index based single finder.
protected abstract  S getById(long id)
           
protected  org.neo4j.graphdb.index.Index<S> getIndex(String indexName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.data.graph.neo4j.finder.Finder
findAllByTraversal
 

Field Detail

clazz

protected final Class<T extends GraphBacked<S>> clazz
Target graphbacked type


graphDatabaseContext

protected final GraphDatabaseContext graphDatabaseContext
Constructor Detail

AbstractFinder

public AbstractFinder(GraphDatabaseContext graphDatabaseContext,
                      Class<T> clazz)
Method Detail

count

public long count()
Specified by:
count in interface Finder<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>
Returns:
Number of instances of the target type in the graph.

findAll

public Iterable<T> findAll()
Specified by:
findAll in interface Finder<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>
Returns:
lazy Iterable over all instances of the target type.

findById

public T findById(long id)
Specified by:
findById in interface Finder<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>
Parameters:
id - id
Returns:
Entity with the given id or null.

findByPropertyValue

public T findByPropertyValue(String indexName,
                             String property,
                             Object value)
Index based single finder.

Specified by:
findByPropertyValue in interface Finder<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>
Parameters:
indexName - or null for default
property -
value -
Returns:
Single Entity with this property and value

getIndex

protected org.neo4j.graphdb.index.Index<S> getIndex(String indexName)

createEntity

protected T createEntity(S node)

findAllByPropertyValue

public Iterable<T> findAllByPropertyValue(String indexName,
                                          String property,
                                          Object value)
Index based exact finder.

Specified by:
findAllByPropertyValue in interface Finder<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>
Parameters:
indexName - or null for default index
property -
value -
Returns:
Iterable over Entities with this property and value

findAllByQuery

public Iterable<T> findAllByQuery(String indexName,
                                  String key,
                                  Object query)
Index based fulltext / query object finder.

Specified by:
findAllByQuery in interface Finder<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>
Parameters:
indexName - or null for default index
key - key of the field to query
query - lucene query object or query-string @return Iterable over Entities with this property and value

findAllByRange

public Iterable<T> findAllByRange(String indexName,
                                  String property,
                                  Number from,
                                  Number to)
Specified by:
findAllByRange in interface Finder<S extends org.neo4j.graphdb.PropertyContainer,T extends GraphBacked<S>>

createInclusiveRangeQuery

protected <T extends Number> org.apache.lucene.search.NumericRangeQuery<T> createInclusiveRangeQuery(String property,
                                                                                                     Number from,
                                                                                                     Number to)

getById

protected abstract S getById(long id)

Spring Data Graph

Copyright © 2011. All Rights Reserved.