Changeset 13173 in josm for trunk/src/org/openstreetmap/josm/tools/CheckParameterUtil.java
- Timestamp:
- 2017-11-28T00:56:29+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/CheckParameterUtil.java
r12822 r13173 5 5 import java.util.function.Predicate; 6 6 import java.util.function.Supplier; 7 8 import org.openstreetmap.josm.data.coor.EastNorth;9 import org.openstreetmap.josm.data.coor.LatLon;10 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;11 import org.openstreetmap.josm.data.osm.PrimitiveId;12 7 13 8 /** … … 65 60 66 61 /** 67 * Ensures an OSM primitive ID is valid68 * @param id The id to check69 * @param parameterName The parameter name70 * @throws IllegalArgumentException if the primitive ID is not valid (negative or zero)71 * @deprecated use {@link #ensure(Object, String, String, Predicate)}72 */73 @Deprecated74 public static void ensureValidPrimitiveId(PrimitiveId id, String parameterName) {75 ensureParameterNotNull(id, parameterName);76 if (id.getUniqueId() <= 0)77 throw new IllegalArgumentException(78 MessageFormat.format("Expected unique id > 0 for primitive ''{1}'', got {0}", id.getUniqueId(), parameterName));79 }80 81 /**82 * Ensures lat/lon coordinates are valid83 * @param latlon The lat/lon to check84 * @param parameterName The parameter name85 * @throws IllegalArgumentException if the lat/lon are {@code null} or not valid86 * @since 598087 * @deprecated use {@link #ensure(Object, String, Predicate)}88 */89 @Deprecated90 public static void ensureValidCoordinates(LatLon latlon, String parameterName) {91 ensureParameterNotNull(latlon, parameterName);92 if (!latlon.isValid())93 throw new IllegalArgumentException(94 MessageFormat.format("Expected valid lat/lon for parameter ''{0}'', got {1}", parameterName, latlon));95 }96 97 /**98 * Ensures east/north coordinates are valid99 * @param eastnorth The east/north to check100 * @param parameterName The parameter name101 * @throws IllegalArgumentException if the east/north are {@code null} or not valid102 * @since 5980103 * @deprecated use {@link #ensure(Object, String, Predicate)}104 */105 @Deprecated106 public static void ensureValidCoordinates(EastNorth eastnorth, String parameterName) {107 ensureParameterNotNull(eastnorth, parameterName);108 if (!eastnorth.isValid())109 throw new IllegalArgumentException(110 MessageFormat.format("Expected valid east/north for parameter ''{0}'', got {1}", parameterName, eastnorth));111 }112 113 /**114 * Ensures a version number is valid115 * @param version The version to check116 * @param parameterName The parameter name117 * @throws IllegalArgumentException if the version is not valid (negative)118 * @deprecated use {@link #ensure(Object, String, String, Predicate)}119 */120 @Deprecated121 public static void ensureValidVersion(long version, String parameterName) {122 if (version < 0)123 throw new IllegalArgumentException(124 MessageFormat.format("Expected value of type long > 0 for parameter ''{0}'', got {1}", parameterName, version));125 }126 127 /**128 62 * Ensures a parameter is not {@code null} 129 63 * @param value The parameter to check … … 174 108 throw new IllegalArgumentException(messageSupplier.get()); 175 109 } 176 177 /**178 * Ensures that <code>id</code> is non-null primitive id of type {@link OsmPrimitiveType#NODE}179 *180 * @param id the primitive id181 * @param parameterName the name of the parameter to be checked182 * @throws IllegalArgumentException if id is null183 * @throws IllegalArgumentException if id.getType() != NODE184 * @deprecated use {@link #ensure(Object, String, String, Predicate)}185 */186 @Deprecated187 public static void ensureValidNodeId(PrimitiveId id, String parameterName) {188 ensureParameterNotNull(id, parameterName);189 if (!id.getType().equals(OsmPrimitiveType.NODE))190 throw new IllegalArgumentException(191 MessageFormat.format("Parameter ''{0}'' of type node expected, got ''{1}''", parameterName, id.getType().getAPIName()));192 }193 110 }
Note:
See TracChangeset
for help on using the changeset viewer.