private ResetMode resolveResetMode() { ResetMode mode = ResetMode.NONE; if (hard) { mode = ResetMode.HARD; } if (mixed) { if (mode != ResetMode.NONE) { throw new InvalidParameterException("You may only specify one mode."); } mode = ResetMode.MIXED; } if (soft) { if (mode != ResetMode.NONE) { throw new InvalidParameterException("You may only specify one mode."); } mode = ResetMode.SOFT; } return mode; }
private ResetMode resolveResetMode() { ResetMode mode = ResetMode.NONE; if (hard) { mode = ResetMode.HARD; } if (mixed) { if (mode != ResetMode.NONE) { throw new InvalidParameterException("You may only specify one mode."); } mode = ResetMode.MIXED; } if (soft) { if (mode != ResetMode.NONE) { throw new InvalidParameterException("You may only specify one mode."); } mode = ResetMode.SOFT; } return mode; }
private ResetMode resolveResetMode() { ResetMode mode = ResetMode.NONE; if (hard) { mode = ResetMode.HARD; } if (mixed) { if (mode != ResetMode.NONE) { throw new InvalidParameterException("You may only specify one mode."); } mode = ResetMode.MIXED; } if (soft) { if (mode != ResetMode.NONE) { throw new InvalidParameterException("You may only specify one mode."); } mode = ResetMode.SOFT; } return mode; }
private CoordinateReferenceSystem parseCrs() { if (boundsCrs == null) { return null; } try { return CRS.decode(boundsCrs, true); } catch (Exception e) { throw new InvalidParameterException(String.format("Unrecognized CRS: '%s'", boundsCrs)); } }
private CoordinateReferenceSystem parseCrs() { if (boundsCrs == null) { return null; } try { return CRS.decode(boundsCrs, true); } catch (Exception e) { throw new InvalidParameterException(String.format("Unrecognized CRS: '%s'", boundsCrs)); } }
private CoordinateReferenceSystem parseCrs() { if (boundsCrs == null) { return null; } try { return CRS.decode(boundsCrs, true); } catch (Exception e) { throw new InvalidParameterException(String.format("Unrecognized CRS: '%s'", boundsCrs)); } }
/** * /** Checks the truth of the boolean expression and throws a {@link InvalidParameterException} * if its {@code false}. * <p> * CLI commands may use this helper method to check the validity of user supplied command * arguments. * * @param expression a boolean expression * @param errorMessageTemplate a template for the exception message should the check fail. The * message is formed as per {@link String#format(String, Object...)} * @param errorMessageArgs the arguments to be substituted into the message template. * @throws InvalidParameterException if {@code expression} is {@code false} * @throws IllegalFormatException if thrown by {@link String#format(String, Object...)} * @throws NullPointerException If the <tt>format</tt> is {@code null} * */ public static void checkParameter(boolean expression, String errorMessageTemplate, Object... errorMessageArgs) { if (!expression) { throw new InvalidParameterException(String.format(errorMessageTemplate, errorMessageArgs)); } } }
/** * Checks the truth of the boolean expression and throws a {@link InvalidParameterException} if * its {@code false}. * <p> * CLI commands may use this helper method to check the validity of user supplied command * arguments. * * @param expression a boolean expression * @param errorMessage the exception message to use if the check fails; will be converted to a * string using {@link String#valueOf(Object)} * @throws InvalidParameterException if {@code expression} is false */ public static void checkParameter(boolean expression, @Nullable Object errorMessage) { if (!expression) { throw new InvalidParameterException(String.valueOf(errorMessage)); } }
/** * Checks the truth of the boolean expression and throws a {@link InvalidParameterException} if * its {@code false}. * <p> * CLI commands may use this helper method to check the validity of user supplied command * arguments. * * @param expression a boolean expression * @param errorMessage the exception message to use if the check fails; will be converted to a * string using {@link String#valueOf(Object)} * @throws InvalidParameterException if {@code expression} is false */ public static void checkParameter(boolean expression, @Nullable Object errorMessage) { if (!expression) { throw new InvalidParameterException(String.valueOf(errorMessage)); } }
/** * /** Checks the truth of the boolean expression and throws a {@link InvalidParameterException} * if its {@code false}. * <p> * CLI commands may use this helper method to check the validity of user supplied command * arguments. * * @param expression a boolean expression * @param errorMessageTemplate a template for the exception message should the check fail. The * message is formed as per {@link String#format(String, Object...)} * @param errorMessageArgs the arguments to be substituted into the message template. * @throws InvalidParameterException if {@code expression} is {@code false} * @throws IllegalFormatException if thrown by {@link String#format(String, Object...)} * @throws NullPointerException If the <tt>format</tt> is {@code null} * */ public static void checkParameter(boolean expression, String errorMessageTemplate, Object... errorMessageArgs) { if (!expression) { throw new InvalidParameterException(String.format(errorMessageTemplate, errorMessageArgs)); } } }
/** * Checks the truth of the boolean expression and throws a {@link InvalidParameterException} if * its {@code false}. * <p> * CLI commands may use this helper method to check the validity of user supplied command * arguments. * * @param expression a boolean expression * @param errorMessage the exception message to use if the check fails; will be converted to a * string using {@link String#valueOf(Object)} * @throws InvalidParameterException if {@code expression} is false */ public static void checkParameter(boolean expression, @Nullable Object errorMessage) { if (!expression) { throw new InvalidParameterException(String.valueOf(errorMessage)); } }
/** * /** Checks the truth of the boolean expression and throws a {@link InvalidParameterException} * if its {@code false}. * <p> * CLI commands may use this helper method to check the validity of user supplied command * arguments. * * @param expression a boolean expression * @param errorMessageTemplate a template for the exception message should the check fail. The * message is formed as per {@link String#format(String, Object...)} * @param errorMessageArgs the arguments to be substituted into the message template. * @throws InvalidParameterException if {@code expression} is {@code false} * @throws IllegalFormatException if thrown by {@link String#format(String, Object...)} * @throws NullPointerException If the <tt>format</tt> is {@code null} * */ public static void checkParameter(boolean expression, String errorMessageTemplate, Object... errorMessageArgs) { if (!expression) { throw new InvalidParameterException(String.format(errorMessageTemplate, errorMessageArgs)); } } }
private Envelope parseBbox() { final String bbox = args.bbox; if (bbox != null) { String[] split = bbox.split(","); checkParameter(split.length == 4, String.format("Invalid bbox format: '%s'. Expected minx,miny,maxx,maxy", bbox)); try { double x1 = Double.parseDouble(split[0]); double y1 = Double.parseDouble(split[1]); double x2 = Double.parseDouble(split[2]); double y2 = Double.parseDouble(split[3]); Envelope envelope = new Envelope(x1, x2, y1, y2); checkParameter(!envelope.isNull(), "Provided envelope is nil"); return envelope; } catch (NumberFormatException e) { String message = String.format( "One or more bbox coordinate can't be parsed to double: '%s'", bbox); throw new InvalidParameterException(message, e); } } return null; }
/** * Executes the remote remove command. */ @Override public void runInternal(GeogigCLI cli) { if (params == null || params.size() != 1) { printUsage(cli); throw new CommandFailedException(); } try { cli.getGeogig().command(RemoteRemoveOp.class).setName(params.get(0)).call(); } catch (RemoteException e) { switch (e.statusCode) { case REMOTE_NOT_FOUND: throw new InvalidParameterException( "Could not find a remote called '" + params.get(0) + "'.", e); default: throw new CommandFailedException(e.getMessage(), e); } } }
/** * Executes the remote remove command. */ @Override public void runInternal(GeogigCLI cli) { if (params == null || params.size() != 1) { printUsage(cli); throw new CommandFailedException(); } try { cli.getGeogig().command(RemoteRemoveOp.class).setName(params.get(0)).call(); } catch (RemoteException e) { switch (e.statusCode) { case REMOTE_NOT_FOUND: throw new InvalidParameterException( "Could not find a remote called '" + params.get(0) + "'.", e); default: throw new CommandFailedException(e.getMessage(), e); } } }
/** * Executes the remote remove command. */ @Override public void runInternal(GeogigCLI cli) { if (params == null || params.size() != 1) { printUsage(cli); throw new CommandFailedException(); } try { cli.getGeogig().command(RemoteRemoveOp.class).setName(params.get(0)).call(); } catch (RemoteException e) { switch (e.statusCode) { case REMOTE_NOT_FOUND: throw new InvalidParameterException( "Could not find a remote called '" + params.get(0) + "'.", e); default: throw new CommandFailedException(e.getMessage(), e); } } }
return (SimpleFeatureType) revFeatureType.type(); } else { throw new InvalidParameterException( "Cannot find feature type for the specified path"); throw new InvalidParameterException("Cannot find feature type for the specified path");
return (SimpleFeatureType) revFeatureType.type(); } else { throw new InvalidParameterException( "Cannot find feature type for the specified path"); throw new InvalidParameterException("Cannot find feature type for the specified path");
return (SimpleFeatureType) revFeatureType.type(); } else { throw new InvalidParameterException( "Cannot find feature type for the specified path"); throw new InvalidParameterException("Cannot find feature type for the specified path");
return (SimpleFeatureType) revFeatureType.type(); } else { throw new InvalidParameterException( "Cannot find feature type for the specified path"); throw new InvalidParameterException("Cannot find feature type for the specified path");