Made failure message customizable.
This commit is contained in:
@@ -57,12 +57,16 @@ public abstract class AbstractConstructorEntityInstantiator<BACKING_INTERFACE, S
|
||||
private <T extends BACKING_INTERFACE> StateBackedCreator<T, STATE> createFailingInstantiator(final Class<STATE> stateType) {
|
||||
return new StateBackedCreator<T, STATE>() {
|
||||
public T create(STATE n, Class<T> c) throws Exception {
|
||||
throw new IllegalArgumentException(getClass().getSimpleName() + ": entity " + c +
|
||||
" must have either a constructor taking [" + stateType + "] or a no-arg constructor and state set method");
|
||||
throw new IllegalArgumentException(getFailingMessageForClass(c, stateType));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected String getFailingMessageForClass(Class<?> entityClass, Class<STATE> stateClass) {
|
||||
return getClass().getSimpleName() + ": entity " + entityClass +
|
||||
" must have either a constructor taking [" + stateClass + "] or a no-arg constructor and state setter.";
|
||||
}
|
||||
|
||||
private <T extends BACKING_INTERFACE> StateBackedCreator<T, STATE> emptyConstructorStateSettingInstantiator(Class<T> type, Class<STATE> stateType) {
|
||||
final Constructor<T> constructor = getNoArgConstructor(type);
|
||||
if (constructor == null) return null;
|
||||
|
||||
Reference in New Issue
Block a user