Spring Data Commons

org.springframework.data.repository.core.support
Class ReflectionEntityInformation<T,ID extends Serializable>

java.lang.Object
  extended by org.springframework.data.repository.core.support.AbstractEntityInformation<T,ID>
      extended by org.springframework.data.repository.core.support.ReflectionEntityInformation<T,ID>
All Implemented Interfaces:
EntityInformation<T,ID>, EntityMetadata<T>

public class ReflectionEntityInformation<T,ID extends Serializable>
extends AbstractEntityInformation<T,ID>

EntityInformation implementation that inspects fields for an annotation and looks up this field's value to retrieve the id.

Author:
Oliver Gierke

Constructor Summary
ReflectionEntityInformation(Class<T> domainClass)
          Creates a new ReflectionEntityInformation inspecting the given domain class for a field carrying the Id annotation.
ReflectionEntityInformation(Class<T> domainClass, Class<? extends Annotation> annotation)
          Creates a new ReflectionEntityInformation inspecting the given domain class for a field carrying the given annotation.
 
Method Summary
 ID getId(Object entity)
          Returns the id of the given entity.
 Class<ID> getIdType()
          Returns the type of the id of the entity.
 
Methods inherited from class org.springframework.data.repository.core.support.AbstractEntityInformation
getJavaType, isNew
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionEntityInformation

public ReflectionEntityInformation(Class<T> domainClass)
Creates a new ReflectionEntityInformation inspecting the given domain class for a field carrying the Id annotation.

Parameters:
domainClass - must not be null.

ReflectionEntityInformation

public ReflectionEntityInformation(Class<T> domainClass,
                                   Class<? extends Annotation> annotation)
Creates a new ReflectionEntityInformation inspecting the given domain class for a field carrying the given annotation.

Parameters:
domainClass - must not be null.
annotation - must not be null.
Method Detail

getId

public ID getId(Object entity)
Description copied from interface: EntityInformation
Returns the id of the given entity.

Parameters:
entity - must never be null
Returns:

getIdType

public Class<ID> getIdType()
Description copied from interface: EntityInformation
Returns the type of the id of the entity.

Returns:

Spring Data Commons

Copyright © 2012. All Rights Reserved.