All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.objectify.impl.load.CollisionDetectingSetter Maven / Gradle / Ivy

Go to download

*** THIS VERSION UPLOADED FOR USE WITH CEDAR-COMMON, TO AVOID DEPENDENCIES ON GOOGLE CODE-BASED MAVEN REPOSITORIES. *** The simplest convenient interface to the Google App Engine datastore

The newest version!
package com.googlecode.objectify.impl.load;

import java.util.Collection;

import com.googlecode.objectify.impl.LoadContext;

/**
 * 

Base for setters which perform rudimentary collision detection. This is how * {@code @AlsoLoad} values avoid stepping on the normally loaded values.

*/ abstract public class CollisionDetectingSetter extends Setter { /** * If non-null check this field in the entity to see if we're stepping on someone * else's field. This prevents {@code AlsoLoad} values from overwriting normal ones. */ Collection collisionPaths; /** * @param collisionPaths can be null */ public CollisionDetectingSetter(Collection collisionPaths) { this.collisionPaths = collisionPaths; } /* (non-Javadoc) * @see com.googlecode.objectify.impl.load.Setter#set(java.lang.Object, java.lang.Object, com.googlecode.objectify.impl.LoadContext) */ public final void set(Object toPojo, Object value, LoadContext context) { if (this.collisionPaths != null) for (String collPath: this.collisionPaths) if (context.getEntity().hasProperty(collPath)) throw new IllegalStateException("Tried to load the same field twice. Check the path " + collPath + " in entity " + context.getEntity().toString()); this.safeSet(toPojo, value, context); } /** * Just like set() but called after collision detection is performed. */ abstract protected void safeSet(Object toPojo, Object value, LoadContext context); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy