// Path: src/main/java/com/github/rwitzel/couchrepository/api/EntityInformation.java
// public interface EntityInformation<T, ID extends Serializable> {
// 
//     /**
//      * Converts the given ID to a CouchDB identifier.
//      * 
//      * @param id the ID of the entity 
//      * @return Returns the transformed identifier.
//      */
//     String toCouchId(ID id);
// 
//     List<String> toCouchIds(Iterable<ID> iter);
// 
//     /**
//      * @param entity the entity
//      * @return Returns the CouchDb identifier of the entity.
//      */
//     String getCouchId(T entity);
// 
//     /**
//      * Sets the identifier of the entity, i.e. transforms the given CouchDb identifier if necessary.
//      * 
//      * @param entity the entity
//      * @param couchId the CouchID for the entity
//      */
//     void setId(T entity, String couchId);
// 
//     /**
//      * @param entity the entity
//      * @return Returns the revision of the given entity.
//      */
//     String getRev(T entity);
// 
//     /**
//      * Sets the revision in the given entity.
//      * 
//      * @param entity the entity
//      * @param rev the new revision for the entity 
//      */
//     void setRev(T entity, String rev);
// 
//     /**
//      * @param entity the entity
//      * @return Returns true if the given entity is new, i.e. it does not have a revision.
//      */
//     boolean isNew(T entity);
// }


import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.data.domain.Persistable;
import org.springframework.util.ReflectionUtils;
import com.github.rwitzel.couchrepository.api.EntityInformation;
            if (field != null) {
                ReflectionUtils.makeAccessible(field);
                return ReflectionUtils.getField(field, entity);
            }

        }

        if (exceptionOnMissingProperty) {
        	throw new RuntimeException("value for document properties " + properties + " not found");
        }
        else {
        	return null;
        }
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    protected void setPropertyValue(T entity, Object newValue, String defaultPropertyInMap, String... properties) {

        for (String property : properties) {

            if (entity instanceof Map) {
                Map map = (Map) entity;
                if (map.containsKey(property)) {
                    map.put(property, newValue);
                    return;
                }
            }
            Field field = ReflectionUtils.findField(type, property);
            if (field != null) {
                ReflectionUtils.makeAccessible(field);
// Path: src/main/java/com/github/rwitzel/couchrepository/api/EntityInformation.java
// public interface EntityInformation<T, ID extends Serializable> {
// 
//     /**
//      * Converts the given ID to a CouchDB identifier.
//      * 
//      * @param id the ID of the entity 
//      * @return Returns the transformed identifier.
//      */
//     String toCouchId(ID id);
// 
//     List<String> toCouchIds(Iterable<ID> iter);
// 
//     /**
//      * @param entity the entity
//      * @return Returns the CouchDb identifier of the entity.
//      */
//     String getCouchId(T entity);
// 
//     /**
//      * Sets the identifier of the entity, i.e. transforms the given CouchDb identifier if necessary.
//      * 
//      * @param entity the entity
//      * @param couchId the CouchID for the entity
//      */
//     void setId(T entity, String couchId);
// 
//     /**
//      * @param entity the entity
//      * @return Returns the revision of the given entity.
//      */
//     String getRev(T entity);
// 
//     /**
//      * Sets the revision in the given entity.
//      * 
//      * @param entity the entity
//      * @param rev the new revision for the entity 
//      */
//     void setRev(T entity, String rev);
// 
//     /**
//      * @param entity the entity
//      * @return Returns true if the given entity is new, i.e. it does not have a revision.
//      */
//     boolean isNew(T entity);
// }


// Path: src/main/java/com/github/rwitzel/couchrepository/support/GenericEntityInformation.java
import java.io.Serializable;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.springframework.data.domain.Persistable;
import org.springframework.util.ReflectionUtils;
import com.github.rwitzel.couchrepository.api.EntityInformation;

            if (field != null) {
                ReflectionUtils.makeAccessible(field);
                return ReflectionUtils.getField(field, entity);
            }

        }

        if (exceptionOnMissingProperty) {
        	throw new RuntimeException("value for document properties " + properties + " not found");
        }
        else {
        	return null;
        }
    }

    @SuppressWarnings({ "rawtypes", "unchecked" })
    protected void setPropertyValue(T entity, Object newValue, String defaultPropertyInMap, String... properties) {

        for (String property : properties) {

            if (entity instanceof Map) {
                Map map = (Map) entity;
                if (map.containsKey(property)) {
                    map.put(property, newValue);
                    return;
                }
            }
            Field field = ReflectionUtils.findField(type, property);
            if (field != null) {
                ReflectionUtils.makeAccessible(field);
                ReflectionUtils.setField(field, entity, newValue);