Index: /trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java	(revision 12821)
+++ /trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java	(revision 12822)
@@ -148,5 +148,5 @@
         static void checkObject(final Object obj) {
             CheckParameterUtil.ensureThat(obj instanceof Expression || obj instanceof String,
-                    "instance of Exception or String expected, but got " + obj);
+                    () -> "instance of Exception or String expected, but got " + obj);
         }
 
Index: /trunk/src/org/openstreetmap/josm/tools/CheckParameterUtil.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/CheckParameterUtil.java	(revision 12821)
+++ /trunk/src/org/openstreetmap/josm/tools/CheckParameterUtil.java	(revision 12822)
@@ -4,4 +4,5 @@
 import java.text.MessageFormat;
 import java.util.function.Predicate;
+import java.util.function.Supplier;
 
 import org.openstreetmap.josm.data.coor.EastNorth;
@@ -151,8 +152,25 @@
      * @param message error message
      * @throws IllegalArgumentException if the condition does not hold
+     * @see #ensureThat(boolean, Supplier)
      */
     public static void ensureThat(boolean condition, String message) {
         if (!condition)
             throw new IllegalArgumentException(message);
+    }
+
+    /**
+     * Ensures that the condition {@code condition} holds.
+     *
+     * This method can be used when the message is not a plain string literal,
+     * but somehow constructed. Using a {@link Supplier} improves the performance,
+     * as the string construction is skipped when the condition holds.
+     * @param condition The condition to check
+     * @param messageSupplier supplier of the error message
+     * @throws IllegalArgumentException if the condition does not hold
+     * @since 12822
+     */
+    public static void ensureThat(boolean condition, Supplier<String> messageSupplier) {
+        if (!condition)
+            throw new IllegalArgumentException(messageSupplier.get());
     }
 
