/** * Create a bindings template from the pair-wise names and specifiers. * Each even-numbered (starting with zero) argument is a binding name, * and each odd-numbered (starting with one) argument is a binding spec. * * @param namesAndSpecs names and specs in "name", "spec", ... form * @return A bindings template that can be used to resolve a bindings instance */ public static BindingsTemplate getTemplate(String... namesAndSpecs) { if ((namesAndSpecs.length % 2) != 0) { throw new RuntimeException( "args must be in 'name','spec', pairs. " + "This can't be true for " + namesAndSpecs.length + "elements."); } Map<String, String> specmap = new HashMap<>(); for (int i = 0; i < namesAndSpecs.length; i += 2) { specmap.put(namesAndSpecs[i], namesAndSpecs[i + 1]); } return getTemplate(specmap); }