- Timestamp:
- 2017-09-11T09:56:28+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r12649 r12822 148 148 static void checkObject(final Object obj) { 149 149 CheckParameterUtil.ensureThat(obj instanceof Expression || obj instanceof String, 150 "instance of Exception or String expected, but got " + obj);150 () -> "instance of Exception or String expected, but got " + obj); 151 151 } 152 152 -
trunk/src/org/openstreetmap/josm/tools/CheckParameterUtil.java
r12713 r12822 4 4 import java.text.MessageFormat; 5 5 import java.util.function.Predicate; 6 import java.util.function.Supplier; 6 7 7 8 import org.openstreetmap.josm.data.coor.EastNorth; … … 151 152 * @param message error message 152 153 * @throws IllegalArgumentException if the condition does not hold 154 * @see #ensureThat(boolean, Supplier) 153 155 */ 154 156 public static void ensureThat(boolean condition, String message) { 155 157 if (!condition) 156 158 throw new IllegalArgumentException(message); 159 } 160 161 /** 162 * Ensures that the condition {@code condition} holds. 163 * 164 * This method can be used when the message is not a plain string literal, 165 * but somehow constructed. Using a {@link Supplier} improves the performance, 166 * as the string construction is skipped when the condition holds. 167 * @param condition The condition to check 168 * @param messageSupplier supplier of the error message 169 * @throws IllegalArgumentException if the condition does not hold 170 * @since 12822 171 */ 172 public static void ensureThat(boolean condition, Supplier<String> messageSupplier) { 173 if (!condition) 174 throw new IllegalArgumentException(messageSupplier.get()); 157 175 } 158 176
Note:
See TracChangeset
for help on using the changeset viewer.