Index: /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java	(revision 12712)
+++ /trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java	(revision 12713)
@@ -76,5 +76,5 @@
     public ParentRelationLoadingTask(Relation child, OsmDataLayer layer, boolean full, PleaseWaitProgressMonitor monitor) {
         super(tr("Download referring relations"), monitor, false /* don't ignore exception */);
-        CheckParameterUtil.ensureValidPrimitiveId(child, "child");
+        CheckParameterUtil.ensure(child, "child", "id > 0", ch -> ch.getUniqueId() > 0);
         CheckParameterUtil.ensureParameterNotNull(layer, "layer");
         referrers = null;
Index: /trunk/src/org/openstreetmap/josm/gui/history/HistoryLoadTask.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/history/HistoryLoadTask.java	(revision 12712)
+++ /trunk/src/org/openstreetmap/josm/gui/history/HistoryLoadTask.java	(revision 12713)
@@ -81,5 +81,5 @@
      */
     public HistoryLoadTask add(PrimitiveId pid) {
-        CheckParameterUtil.ensureValidPrimitiveId(pid, "pid");
+        CheckParameterUtil.ensure(pid, "pid", "pid > 0", id -> id.getUniqueId() > 0);
         toLoad.add(pid);
         return this;
@@ -119,5 +119,5 @@
      */
     public HistoryLoadTask add(OsmPrimitive primitive) {
-        CheckParameterUtil.ensureValidPrimitiveId(primitive, "primitive");
+        CheckParameterUtil.ensure(primitive, "primitive", "id > 0", prim -> prim.getUniqueId() > 0);
         return add(primitive.getPrimitiveId());
     }
Index: /trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java	(revision 12712)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java	(revision 12713)
@@ -216,5 +216,5 @@
 
     private void setDisplacement(EastNorth displacement) {
-        CheckParameterUtil.ensureValidCoordinates(displacement, "displacement");
+        CheckParameterUtil.ensure(displacement, "displacement", EastNorth::isValid);
         this.displacement = displacement;
         fireSettingsChange(DISPLACEMENT);
Index: /trunk/src/org/openstreetmap/josm/io/OsmServerBackreferenceReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmServerBackreferenceReader.java	(revision 12712)
+++ /trunk/src/org/openstreetmap/josm/io/OsmServerBackreferenceReader.java	(revision 12713)
@@ -52,5 +52,5 @@
      */
     public OsmServerBackreferenceReader(OsmPrimitive primitive) {
-        CheckParameterUtil.ensureValidPrimitiveId(primitive, "primitive");
+        CheckParameterUtil.ensure(primitive, "primitive", "id > 0", prim -> prim.getUniqueId() > 0);
         this.id = primitive.getId();
         this.primitiveType = OsmPrimitiveType.from(primitive);
Index: /trunk/src/org/openstreetmap/josm/io/OsmServerObjectReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/OsmServerObjectReader.java	(revision 12712)
+++ /trunk/src/org/openstreetmap/josm/io/OsmServerObjectReader.java	(revision 12713)
@@ -96,5 +96,5 @@
 
     protected OsmServerObjectReader(PrimitiveId id, boolean full, int version) {
-        CheckParameterUtil.ensureValidPrimitiveId(id, "id");
+        CheckParameterUtil.ensure(id, "id", "id > 0", pid -> pid.getUniqueId() > 0);
         this.id = id;
         this.full = full;
Index: /trunk/src/org/openstreetmap/josm/tools/CheckParameterUtil.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/CheckParameterUtil.java	(revision 12712)
+++ /trunk/src/org/openstreetmap/josm/tools/CheckParameterUtil.java	(revision 12713)
@@ -3,4 +3,5 @@
 
 import java.text.MessageFormat;
+import java.util.function.Predicate;
 
 import org.openstreetmap.josm.data.coor.EastNorth;
@@ -21,9 +22,53 @@
 
     /**
+     * Ensures that a parameter is not null and that a certain condition holds.
+     * @param <T> parameter type
+     * @param obj parameter value
+     * @param parameterName parameter name
+     * @param conditionMsg string, stating the condition
+     * @param condition the condition to check
+     * @throws IllegalArgumentException in case the object is null or the condition
+     * is violated
+     * @since 12713
+     */
+    public static <T> void ensure(T obj, String parameterName, String conditionMsg, Predicate<T> condition) {
+        ensureParameterNotNull(obj, parameterName);
+        if (!condition.test(obj))
+            throw new IllegalArgumentException(
+                    MessageFormat.format("Parameter value ''{0}'' of type {1} is invalid, violated condition: ''{2}'', got ''{3}''",
+                            parameterName,
+                            obj.getClass().getCanonicalName(),
+                            conditionMsg,
+                            obj));
+    }
+
+    /**
+     * Ensures that a parameter is not null and that a certain condition holds.
+     * @param <T> parameter type
+     * @param obj parameter value
+     * @param parameterName parameter name
+     * @param condition the condition to check
+     * @throws IllegalArgumentException in case the object is null or the condition
+     * is violated
+     * @since 12713
+     */
+    public static <T> void ensure(T obj, String parameterName, Predicate<T> condition) {
+        ensureParameterNotNull(obj, parameterName);
+        if (!condition.test(obj))
+            throw new IllegalArgumentException(
+                    MessageFormat.format("Parameter value ''{0}'' of type {1} is invalid, got ''{2}''",
+                            parameterName,
+                            obj.getClass().getCanonicalName(),
+                            obj));
+    }
+
+    /**
      * Ensures an OSM primitive ID is valid
      * @param id The id to check
      * @param parameterName The parameter name
      * @throws IllegalArgumentException if the primitive ID is not valid (negative or zero)
+     * @deprecated use {@link #ensure(Object, String, String, Predicate)}
      */
+    @Deprecated
     public static void ensureValidPrimitiveId(PrimitiveId id, String parameterName) {
         ensureParameterNotNull(id, parameterName);
@@ -39,5 +84,7 @@
      * @throws IllegalArgumentException if the lat/lon are {@code null} or not valid
      * @since 5980
+     * @deprecated use {@link #ensure(Object, String, Predicate)}
      */
+    @Deprecated
     public static void ensureValidCoordinates(LatLon latlon, String parameterName) {
         ensureParameterNotNull(latlon, parameterName);
@@ -53,5 +100,7 @@
      * @throws IllegalArgumentException if the east/north are {@code null} or not valid
      * @since 5980
+     * @deprecated use {@link #ensure(Object, String, Predicate)}
      */
+    @Deprecated
     public static void ensureValidCoordinates(EastNorth eastnorth, String parameterName) {
         ensureParameterNotNull(eastnorth, parameterName);
@@ -66,5 +115,7 @@
      * @param parameterName The parameter name
      * @throws IllegalArgumentException if the version is not valid (negative)
+     * @deprecated use {@link #ensure(Object, String, String, Predicate)}
      */
+    @Deprecated
     public static void ensureValidVersion(long version, String parameterName) {
         if (version < 0)
@@ -113,5 +164,7 @@
      * @throws IllegalArgumentException if id is null
      * @throws IllegalArgumentException if id.getType() != NODE
+     * @deprecated use {@link #ensure(Object, String, String, Predicate)}
      */
+    @Deprecated
     public static void ensureValidNodeId(PrimitiveId id, String parameterName) {
         ensureParameterNotNull(id, parameterName);
Index: /trunk/src/org/openstreetmap/josm/tools/Geometry.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Geometry.java	(revision 12712)
+++ /trunk/src/org/openstreetmap/josm/tools/Geometry.java	(revision 12713)
@@ -292,8 +292,8 @@
     public static EastNorth getSegmentSegmentIntersection(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4) {
 
-        CheckParameterUtil.ensureValidCoordinates(p1, "p1");
-        CheckParameterUtil.ensureValidCoordinates(p2, "p2");
-        CheckParameterUtil.ensureValidCoordinates(p3, "p3");
-        CheckParameterUtil.ensureValidCoordinates(p4, "p4");
+        CheckParameterUtil.ensure(p1, "p1", EastNorth::isValid);
+        CheckParameterUtil.ensure(p2, "p2", EastNorth::isValid);
+        CheckParameterUtil.ensure(p3, "p3", EastNorth::isValid);
+        CheckParameterUtil.ensure(p4, "p4", EastNorth::isValid);
 
         double x1 = p1.getX();
@@ -357,8 +357,8 @@
     public static EastNorth getLineLineIntersection(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4) {
 
-        CheckParameterUtil.ensureValidCoordinates(p1, "p1");
-        CheckParameterUtil.ensureValidCoordinates(p2, "p2");
-        CheckParameterUtil.ensureValidCoordinates(p3, "p3");
-        CheckParameterUtil.ensureValidCoordinates(p4, "p4");
+        CheckParameterUtil.ensure(p1, "p1", EastNorth::isValid);
+        CheckParameterUtil.ensure(p2, "p2", EastNorth::isValid);
+        CheckParameterUtil.ensure(p3, "p3", EastNorth::isValid);
+        CheckParameterUtil.ensure(p4, "p4", EastNorth::isValid);
 
         // Basically, the formula from wikipedia is used:
@@ -400,8 +400,8 @@
     public static boolean segmentsParallel(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4) {
 
-        CheckParameterUtil.ensureValidCoordinates(p1, "p1");
-        CheckParameterUtil.ensureValidCoordinates(p2, "p2");
-        CheckParameterUtil.ensureValidCoordinates(p3, "p3");
-        CheckParameterUtil.ensureValidCoordinates(p4, "p4");
+        CheckParameterUtil.ensure(p1, "p1", EastNorth::isValid);
+        CheckParameterUtil.ensure(p2, "p2", EastNorth::isValid);
+        CheckParameterUtil.ensure(p3, "p3", EastNorth::isValid);
+        CheckParameterUtil.ensure(p4, "p4", EastNorth::isValid);
 
         // Convert line from (point, point) form to ax+by=c
@@ -486,7 +486,7 @@
     public static boolean angleIsClockwise(EastNorth commonNode, EastNorth firstNode, EastNorth secondNode) {
 
-        CheckParameterUtil.ensureValidCoordinates(commonNode, "commonNode");
-        CheckParameterUtil.ensureValidCoordinates(firstNode, "firstNode");
-        CheckParameterUtil.ensureValidCoordinates(secondNode, "secondNode");
+        CheckParameterUtil.ensure(commonNode, "commonNode", EastNorth::isValid);
+        CheckParameterUtil.ensure(firstNode, "firstNode", EastNorth::isValid);
+        CheckParameterUtil.ensure(secondNode, "secondNode", EastNorth::isValid);
 
         double dy1 = firstNode.getY() - commonNode.getY();
@@ -771,6 +771,6 @@
     public static double getSegmentAngle(EastNorth p1, EastNorth p2) {
 
-        CheckParameterUtil.ensureValidCoordinates(p1, "p1");
-        CheckParameterUtil.ensureValidCoordinates(p2, "p2");
+        CheckParameterUtil.ensure(p1, "p1", EastNorth::isValid);
+        CheckParameterUtil.ensure(p2, "p2", EastNorth::isValid);
 
         return Math.atan2(p2.north() - p1.north(), p2.east() - p1.east());
@@ -787,7 +787,7 @@
     public static double getCornerAngle(EastNorth p1, EastNorth p2, EastNorth p3) {
 
-        CheckParameterUtil.ensureValidCoordinates(p1, "p1");
-        CheckParameterUtil.ensureValidCoordinates(p2, "p2");
-        CheckParameterUtil.ensureValidCoordinates(p3, "p3");
+        CheckParameterUtil.ensure(p1, "p1", EastNorth::isValid);
+        CheckParameterUtil.ensure(p2, "p2", EastNorth::isValid);
+        CheckParameterUtil.ensure(p3, "p3", EastNorth::isValid);
 
         Double result = getSegmentAngle(p2, p1) - getSegmentAngle(p2, p3);
