![JAR search and dependency download from the Maven repository](/logo.png)
com.dooapp.gaedo.finders.id.BadIdAnnotatedClassException Maven / Gradle / Ivy
/**
*
*/
package com.dooapp.gaedo.finders.id;
import java.util.Collection;
import com.dooapp.gaedo.CrudServiceException;
import com.dooapp.gaedo.finders.id.AnnotationsFinder.Annotations;
/**
* That class various id elements does not allow the correct definition of a simple id :
*
* - Either the class has no field annotated with one of the {@link Annotations.ID} possible values
* - Or the class has too many elements with such annotations
* - Or the class has only one field with such annotation, which is good, but the field is not correctly typed
*
* As a remainder, for a class to be persisted using GAE, it must have as id field something like
*
* @Id
* private long use_any_name_you_want_here;
*
* the name id is irrelevant here. However, the annotation and the type are.
* @author Nicolas
*
*/
public class BadIdAnnotatedClassException extends CrudServiceException {
private static String toString(Collection expectedIdClasses) {
StringBuilder sOut = new StringBuilder();
if(expectedIdClasses!=null) {
for(Class> c : expectedIdClasses) {
sOut.append("\n\t").append(c.getName());
}
}
return sOut.toString();
}
public BadIdAnnotatedClassException(Class> containedClass, Collection expectedIdClasses) {
this("Class "+containedClass.getName()+" must have EXACTLY one field annotated with @Id of one of these types : "+toString(expectedIdClasses));
}
protected BadIdAnnotatedClassException(String message) {
super(message);
}
public BadIdAnnotatedClassException(Class> containedClass) {
this("Class "+containedClass.getName()+" must have EXACTLY one field annotated with @Id");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy