Changeset 8506 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2015-06-19T23:34:50+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/CheckParameterUtil.java
r8443 r8506 26 26 * @throws IllegalArgumentException if the primitive ID is not valid (negative or zero) 27 27 */ 28 public static void ensureValidPrimitiveId(PrimitiveId id, String parameterName) throws IllegalArgumentException{28 public static void ensureValidPrimitiveId(PrimitiveId id, String parameterName) { 29 29 ensureParameterNotNull(id, parameterName); 30 30 if (id.getUniqueId() <= 0) 31 throw new IllegalArgumentException(MessageFormat.format("Expected unique id > 0 for primitive ''{1}'', got {0}", id.getUniqueId(), parameterName)); 31 throw new IllegalArgumentException( 32 MessageFormat.format("Expected unique id > 0 for primitive ''{1}'', got {0}", id.getUniqueId(), parameterName)); 32 33 } 33 34 … … 39 40 * @since 5980 40 41 */ 41 public static void ensureValidCoordinates(LatLon latlon, String parameterName) throws IllegalArgumentException{42 public static void ensureValidCoordinates(LatLon latlon, String parameterName) { 42 43 ensureParameterNotNull(latlon, parameterName); 43 44 if (!latlon.isValid()) 44 throw new IllegalArgumentException(MessageFormat.format("Expected valid lat/lon for parameter ''{0}'', got {1}", parameterName, latlon)); 45 throw new IllegalArgumentException( 46 MessageFormat.format("Expected valid lat/lon for parameter ''{0}'', got {1}", parameterName, latlon)); 45 47 } 46 48 … … 52 54 * @since 5980 53 55 */ 54 public static void ensureValidCoordinates(EastNorth eastnorth, String parameterName) throws IllegalArgumentException{56 public static void ensureValidCoordinates(EastNorth eastnorth, String parameterName) { 55 57 ensureParameterNotNull(eastnorth, parameterName); 56 58 if (!eastnorth.isValid()) 57 throw new IllegalArgumentException(MessageFormat.format("Expected valid east/north for parameter ''{0}'', got {1}", parameterName, eastnorth)); 59 throw new IllegalArgumentException( 60 MessageFormat.format("Expected valid east/north for parameter ''{0}'', got {1}", parameterName, eastnorth)); 58 61 } 59 62 … … 64 67 * @throws IllegalArgumentException if the version is not valid (negative) 65 68 */ 66 public static void ensureValidVersion(long version, String parameterName) throws IllegalArgumentException{69 public static void ensureValidVersion(long version, String parameterName) { 67 70 if (version < 0) 68 throw new IllegalArgumentException(MessageFormat.format("Expected value of type long > 0 for parameter ''{0}'', got {1}", parameterName, version)); 71 throw new IllegalArgumentException( 72 MessageFormat.format("Expected value of type long > 0 for parameter ''{0}'', got {1}", parameterName, version)); 69 73 } 70 74 … … 75 79 * @throws IllegalArgumentException if the parameter is {@code null} 76 80 */ 77 public static void ensureParameterNotNull(Object value, String parameterName) throws IllegalArgumentException{81 public static void ensureParameterNotNull(Object value, String parameterName) { 78 82 if (value == null) 79 83 throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' must not be null", parameterName)); … … 86 90 * @since 3871 87 91 */ 88 public static void ensureParameterNotNull(Object value) throws IllegalArgumentException{92 public static void ensureParameterNotNull(Object value) { 89 93 if (value == null) 90 94 throw new IllegalArgumentException("Parameter must not be null"); … … 96 100 * @throws IllegalArgumentException if the condition does not hold 97 101 */ 98 public static void ensureThat(boolean condition, String message) throws IllegalArgumentException{102 public static void ensureThat(boolean condition, String message) { 99 103 if (!condition) 100 104 throw new IllegalArgumentException(message); … … 104 108 * Ensures that <code>id</code> is non-null primitive id of type {@link OsmPrimitiveType#NODE} 105 109 * 106 * @param id 110 * @param id the primitive id 107 111 * @param parameterName the name of the parameter to be checked 108 112 * @throws IllegalArgumentException if id is null 109 113 * @throws IllegalArgumentException if id.getType() != NODE 110 114 */ 111 public static void ensureValidNodeId(PrimitiveId id, String parameterName) throws IllegalArgumentException{115 public static void ensureValidNodeId(PrimitiveId id, String parameterName) { 112 116 ensureParameterNotNull(id, parameterName); 113 117 if (!id.getType().equals(OsmPrimitiveType.NODE)) 114 throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' of type node expected, got ''{1}''", parameterName, id.getType().getAPIName())); 118 throw new IllegalArgumentException( 119 MessageFormat.format("Parameter ''{0}'' of type node expected, got ''{1}''", parameterName, id.getType().getAPIName())); 115 120 } 116 121 }
Note:
See TracChangeset
for help on using the changeset viewer.