DATACMNS-1359 - Improved exception message for missing accessors and getters.
The exception messages used in the PersistentProperty.getRequired(Getter|Setter|Wither|Field)(…) now mention the name of the property that's offending.
This commit is contained in:
@@ -87,7 +87,7 @@ public interface PersistentProperty<P extends PersistentProperty<P>> {
|
||||
Method getter = getGetter();
|
||||
|
||||
if (getter == null) {
|
||||
throw new IllegalArgumentException("No getter available for this persistent property!");
|
||||
throw new IllegalArgumentException(String.format("No getter available for persistent property %s!", this));
|
||||
}
|
||||
|
||||
return getter;
|
||||
@@ -107,7 +107,7 @@ public interface PersistentProperty<P extends PersistentProperty<P>> {
|
||||
Method setter = getSetter();
|
||||
|
||||
if (setter == null) {
|
||||
throw new IllegalArgumentException("No setter available for this persistent property!");
|
||||
throw new IllegalArgumentException(String.format("No setter available for persistent property %s!", this));
|
||||
}
|
||||
|
||||
return setter;
|
||||
@@ -145,7 +145,7 @@ public interface PersistentProperty<P extends PersistentProperty<P>> {
|
||||
Method wither = getWither();
|
||||
|
||||
if (wither == null) {
|
||||
throw new IllegalArgumentException("No wither available for this persistent property!");
|
||||
throw new IllegalArgumentException(String.format("No wither available for persistent property %s!", this));
|
||||
}
|
||||
|
||||
return wither;
|
||||
@@ -159,7 +159,7 @@ public interface PersistentProperty<P extends PersistentProperty<P>> {
|
||||
Field field = getField();
|
||||
|
||||
if (field == null) {
|
||||
throw new IllegalArgumentException("No field backing this persistent property!");
|
||||
throw new IllegalArgumentException(String.format("No field backing persistent property %s!", this));
|
||||
}
|
||||
|
||||
return field;
|
||||
|
||||
@@ -67,7 +67,8 @@ public class Property {
|
||||
);
|
||||
this.hashCode = Lazy.of(() -> withFieldOrDescriptor(Object::hashCode));
|
||||
this.name = Lazy.of(() -> withFieldOrDescriptor(Field::getName, FeatureDescriptor::getName));
|
||||
this.toString = Lazy.of(() -> withFieldOrDescriptor(Object::toString));
|
||||
this.toString = Lazy.of(() -> withFieldOrDescriptor(Object::toString,
|
||||
it -> String.format("%s.%s", type.getType().getName(), it.getDisplayName())));
|
||||
|
||||
this.getter = descriptor.map(PropertyDescriptor::getReadMethod)//
|
||||
.filter(it -> getType() != null)//
|
||||
|
||||
Reference in New Issue
Block a user