Repository: opennlp Updated Branches: refs/heads/master e0612227a -> c75bce142
OPENNLP-919: Remove type variable from varargs Project: http://git-wip-us.apache.org/repos/asf/opennlp/repo Commit: http://git-wip-us.apache.org/repos/asf/opennlp/commit/c75bce14 Tree: http://git-wip-us.apache.org/repos/asf/opennlp/tree/c75bce14 Diff: http://git-wip-us.apache.org/repos/asf/opennlp/diff/c75bce14 Branch: refs/heads/master Commit: c75bce14266b727c0bd022929d3ee10bc3062704 Parents: e061222 Author: Jörn Kottmann <[email protected]> Authored: Tue Jan 17 18:17:36 2017 +0100 Committer: Jörn Kottmann <[email protected]> Committed: Tue Jan 17 18:17:36 2017 +0100 ---------------------------------------------------------------------- .../opennlp/tools/cmdline/ArgumentParser.java | 21 ++++++++++---------- .../java/opennlp/tools/cmdline/CmdLineTool.java | 7 +++---- .../opennlp/tools/cmdline/TypedCmdLineTool.java | 4 ++-- 3 files changed, 15 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/opennlp/blob/c75bce14/opennlp-tools/src/main/java/opennlp/tools/cmdline/ArgumentParser.java ---------------------------------------------------------------------- diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/ArgumentParser.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/ArgumentParser.java index bec3cf1..631bc34 100644 --- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/ArgumentParser.java +++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/ArgumentParser.java @@ -161,8 +161,8 @@ public class ArgumentParser { private ArgumentParser() { } - private static <T> void checkProxyInterfaces(Class<T>... proxyInterfaces) { - for (Class<T> proxyInterface : proxyInterfaces) { + private static void checkProxyInterfaces(Class<?>... proxyInterfaces) { + for (Class<?> proxyInterface : proxyInterfaces) { if (null != proxyInterface) { if (!proxyInterface.isInterface()) throw new IllegalArgumentException("proxy interface is not an interface!"); @@ -269,14 +269,14 @@ public class ArgumentParser { * @param argProxyInterfaces interfaces with parameter descriptions * @return the help message usage string */ - public static <T> List<Argument> createArguments(Class<T>... argProxyInterfaces) { + public static List<Argument> createArguments(Class<?>... argProxyInterfaces) { checkProxyInterfaces(argProxyInterfaces); Set<String> duplicateFilter = new HashSet<>(); List<Argument> arguments = new LinkedList<>(); - for (Class<T> argProxyInterface : argProxyInterfaces) { + for (Class<?> argProxyInterface : argProxyInterfaces) { if (null != argProxyInterface) { for (Method method : argProxyInterface.getMethods()) { @@ -321,14 +321,14 @@ public class ArgumentParser { * @param argProxyInterfaces interfaces with parameter descriptions * @return the help message usage string */ - public static <T> String createUsage(Class<T>... argProxyInterfaces) { + public static String createUsage(Class<?>... argProxyInterfaces) { checkProxyInterfaces(argProxyInterfaces); Set<String> duplicateFilter = new HashSet<>(); StringBuilder usage = new StringBuilder(); StringBuilder details = new StringBuilder(); - for (Class<T> argProxyInterface : argProxyInterfaces) { + for (Class<?> argProxyInterface : argProxyInterfaces) { if (null != argProxyInterface) { for (Method method : argProxyInterface.getMethods()) { @@ -398,7 +398,7 @@ public class ArgumentParser { * @param argProxyInterfaces interfaces with parameters description * @return true, if arguments are valid */ - public static <T> boolean validateArguments(String args[], Class<T>... argProxyInterfaces) { + public static boolean validateArguments(String args[], Class<?>... argProxyInterfaces) { return null == validateArgumentsLoudly(args, argProxyInterfaces); } @@ -409,8 +409,7 @@ public class ArgumentParser { * @param argProxyInterface interface with parameters description * @return null, if arguments are valid or error message otherwise */ - @SuppressWarnings({"unchecked"}) - public static <T> String validateArgumentsLoudly(String args[], Class<T> argProxyInterface) { + public static String validateArgumentsLoudly(String args[], Class<?> argProxyInterface) { return validateArgumentsLoudly(args, new Class[]{argProxyInterface}); } @@ -421,7 +420,7 @@ public class ArgumentParser { * @param argProxyInterfaces interfaces with parameters description * @return null, if arguments are valid or error message otherwise */ - public static <T> String validateArgumentsLoudly(String args[], Class<T>... argProxyInterfaces) { + public static String validateArgumentsLoudly(String args[], Class<?>... argProxyInterfaces) { // number of parameters must be always be even if (args.length % 2 != 0) { return "Number of parameters must be always be even"; @@ -430,7 +429,7 @@ public class ArgumentParser { int argumentCount = 0; List<String> parameters = new ArrayList<>(Arrays.asList(args)); - for (Class<T> argProxyInterface : argProxyInterfaces) { + for (Class<?> argProxyInterface : argProxyInterfaces) { for (Method method : argProxyInterface.getMethods()) { String paramName = methodNameToParameter(method.getName()); int paramIndex = CmdLineUtil.getParameterIndex(paramName, args); http://git-wip-us.apache.org/repos/asf/opennlp/blob/c75bce14/opennlp-tools/src/main/java/opennlp/tools/cmdline/CmdLineTool.java ---------------------------------------------------------------------- diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/CmdLineTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/CmdLineTool.java index 63f3e8c..149de5c 100644 --- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/CmdLineTool.java +++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/CmdLineTool.java @@ -47,12 +47,11 @@ public abstract class CmdLineTool { return true; } - @SuppressWarnings({"unchecked"}) - protected <T> String getBasicHelp(Class<T> argProxyInterface) { + protected String getBasicHelp(Class<?> argProxyInterface) { return getBasicHelp(new Class[]{argProxyInterface}); } - protected <T> String getBasicHelp(Class<T>... argProxyInterfaces) { + protected String getBasicHelp(Class<?>... argProxyInterfaces) { return "Usage: " + CLI.CMD + " " + getName() + " " + ArgumentParser.createUsage(argProxyInterfaces); } @@ -80,4 +79,4 @@ public abstract class CmdLineTool { public String getShortDescription() { return ""; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/opennlp/blob/c75bce14/opennlp-tools/src/main/java/opennlp/tools/cmdline/TypedCmdLineTool.java ---------------------------------------------------------------------- diff --git a/opennlp-tools/src/main/java/opennlp/tools/cmdline/TypedCmdLineTool.java b/opennlp-tools/src/main/java/opennlp/tools/cmdline/TypedCmdLineTool.java index f43532f..bf4b381 100644 --- a/opennlp-tools/src/main/java/opennlp/tools/cmdline/TypedCmdLineTool.java +++ b/opennlp-tools/src/main/java/opennlp/tools/cmdline/TypedCmdLineTool.java @@ -88,7 +88,7 @@ public abstract class TypedCmdLineTool<T> } @Override - protected <A> String getBasicHelp(Class<A>... argProxyInterfaces) { + protected String getBasicHelp(Class<?>... argProxyInterfaces) { Map<String, ObjectStreamFactory<T>> factories = StreamFactoryRegistry.getFactories(type); String formatsHelp = " "; @@ -125,4 +125,4 @@ public abstract class TypedCmdLineTool<T> * @return a description on how to use the tool */ public abstract String getHelp(String format); -} \ No newline at end of file +}
