xapi.args.ArgHandlerInt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xapi-dev Show documentation
Show all versions of xapi-dev Show documentation
Everything needed to run a comprehensive dev environment.
Just type X_ and pick a service from autocomplete;
new dev modules will be added as they are built.
The only dev service not included in the uber jar is xapi-dev-maven,
as it includes all runtime dependencies of maven, adding ~4 seconds to build time,
and 6 megabytes to the final output jar size (without xapi-dev-maven, it's ~1MB).
The newest version!
package xapi.args;
/**
* Argument handler for flags that take an integer as their parameter.
*
* Based on original implementation from the GWT project.
*
* @author GWT team "gwtproject.org"
* @author James X. Nelson "[email protected]"
*
*/
public abstract class ArgHandlerInt extends ArgHandler {
@Override
public int handle(String[] args, int startIndex) {
int value;
if (startIndex + 1 < args.length) {
try {
value = Integer.parseInt(args[startIndex + 1]);
} catch (NumberFormatException e) {
// fall-through
value = -1;
}
setInt(value);
return 1;
}
System.err.println(getTag() + " should be followed by an integer");
return -1;
}
@Override
public boolean isRequired() {
return false;
}
public abstract void setInt(int value);
}