diff --git a/src/mdo/java/InputLocation.java b/src/mdo/java/InputLocation.java index 7cd567740313..6e93ddae993e 100644 --- a/src/mdo/java/InputLocation.java +++ b/src/mdo/java/InputLocation.java @@ -99,6 +99,7 @@ public InputSource getSource() { @Override public InputLocation getLocation(Object key) { + Objects.requireNonNull(key, "key"); return locations != null ? locations.get(key) : null; } diff --git a/src/mdo/java/InputLocationTracker.java b/src/mdo/java/InputLocationTracker.java index 365cf7f97e1d..a70ac293cf10 100644 --- a/src/mdo/java/InputLocationTracker.java +++ b/src/mdo/java/InputLocationTracker.java @@ -18,7 +18,23 @@ */ package ${package}; +/** + * Tracks input source locations for model fields. + *
+ * Implementations provide a mapping from keys (typically field names or indices) to + * {@link InputLocation} instances to support precise error reporting and diagnostics. + * Keys must be non-null. + * + * @since 4.0.0 + */ public interface InputLocationTracker { + /** + * Gets the location of the specified field in the input source. + * + * @param field the key of the field, must not be {@code null} + * @return the location of the field in the input source or {@code null} if unknown + * @throws NullPointerException if {@code field} is {@code null} + */ InputLocation getLocation(Object field); /** diff --git a/src/mdo/model.vm b/src/mdo/model.vm index dc08d3542187..5bcfa7246d9b 100644 --- a/src/mdo/model.vm +++ b/src/mdo/model.vm @@ -240,8 +240,13 @@ public class ${class.name} #if ( $locationTracking && !$class.superClass ) /** * Gets the location of the specified field in the input source. + * + * @param key the key of the field, must not be {@code null} + * @return the location of the field in the input source or {@code null} if unknown + * @throws NullPointerException if {@code key} is {@code null} */ public InputLocation getLocation(Object key) { + Objects.requireNonNull(key, "key"); return locations.get(key); }