@Test public void testAssignAliases() { final LinkedHashMap<String, List<Object>> possibleValueMap = new LinkedHashMap<>(); final List<Object> valuesA = new ArrayList<>(); valuesA.add("a"); valuesA.add("b"); valuesA.add("c"); final List<Object> valuesB = new ArrayList<>(); valuesB.add("d"); final List<Object> valuesC = new ArrayList<>(); valuesC.add("e"); valuesC.add("f"); final List<Object> valuesD = new ArrayList<>(); valuesD.add("g"); valuesD.add("h"); possibleValueMap.put("A", valuesA); possibleValueMap.put("B", valuesB); possibleValueMap.put("C", valuesC); possibleValueMap.put("D", valuesD); for (int i = 0; i < valuesA.size() * valuesB.size() * valuesC.size() * valuesD.size(); i++) { System.out.println(i + " : " + HL7Query.assignAliases(possibleValueMap, i)); } verifyAssignments(HL7Query.assignAliases(possibleValueMap, 0), "a", "d", "e", "g"); verifyAssignments(HL7Query.assignAliases(possibleValueMap, 1), "b", "d", "e", "g"); verifyAssignments(HL7Query.assignAliases(possibleValueMap, 2), "c", "d", "e", "g"); verifyAssignments(HL7Query.assignAliases(possibleValueMap, 3), "a", "d", "f", "g"); verifyAssignments(HL7Query.assignAliases(possibleValueMap, 4), "b", "d", "f", "g"); verifyAssignments(HL7Query.assignAliases(possibleValueMap, 5), "c", "d", "f", "g"); verifyAssignments(HL7Query.assignAliases(possibleValueMap, 6), "a", "d", "e", "h"); verifyAssignments(HL7Query.assignAliases(possibleValueMap, 7), "b", "d", "e", "h"); verifyAssignments(HL7Query.assignAliases(possibleValueMap, 8), "c", "d", "e", "h"); verifyAssignments(HL7Query.assignAliases(possibleValueMap, 9), "a", "d", "f", "h"); verifyAssignments(HL7Query.assignAliases(possibleValueMap, 10), "b", "d", "f", "h"); verifyAssignments(HL7Query.assignAliases(possibleValueMap, 11), "c", "d", "f", "h"); }
static Map<String, Object> assignAliases(final LinkedHashMap<String, List<Object>> possibleValues, final int iteration) { final Map<String, Object> aliasMap = new HashMap<>(); int divisor = 1; for (final Map.Entry<String, List<Object>> entry : possibleValues.entrySet()) { final String alias = entry.getKey(); final List<Object> validValues = entry.getValue(); final int idx = (iteration / divisor) % validValues.size(); final Object obj = validValues.get(idx); aliasMap.put(alias, obj); divisor *= validValues.size(); } return aliasMap; }
HL7Query { static Map<String, Object> assignAliases(final LinkedHashMap<String, List<Object>> possibleValues, final int iteration) { final Map<String, Object> aliasMap = new HashMap<>(); int divisor = 1; for (final Map.Entry<String, List<Object>> entry : possibleValues.entrySet()) { final String alias = entry.getKey(); final List<Object> validValues = entry.getValue(); final int idx = (iteration / divisor) % validValues.size(); final Object obj = validValues.get(idx); aliasMap.put(alias, obj); divisor *= validValues.size(); } return aliasMap; } }
HL7Query { static Map<String, Object> assignAliases(final LinkedHashMap<String, List<Object>> possibleValues, final int iteration) { final Map<String, Object> aliasMap = new HashMap<>(); int divisor = 1; for (final Map.Entry<String, List<Object>> entry : possibleValues.entrySet()) { final String alias = entry.getKey(); final List<Object> validValues = entry.getValue(); final int idx = (iteration / divisor) % validValues.size(); final Object obj = validValues.get(idx); aliasMap.put(alias, obj); divisor *= validValues.size(); } return aliasMap; } private  HL7Query(final Tree tree, final String query); }
HL7Query { static Map<String, Object> assignAliases(final LinkedHashMap<String, List<Object>> possibleValues, final int iteration) { final Map<String, Object> aliasMap = new HashMap<>(); int divisor = 1; for (final Map.Entry<String, List<Object>> entry : possibleValues.entrySet()) { final String alias = entry.getKey(); final List<Object> validValues = entry.getValue(); final int idx = (iteration / divisor) % validValues.size(); final Object obj = validValues.get(idx); aliasMap.put(alias, obj); divisor *= validValues.size(); } return aliasMap; } private  HL7Query(final Tree tree, final String query); String getQuery(); @Override String toString(); static HL7Query compile(final String query); List<Class<?>> getReturnTypes(); @SuppressWarnings("unchecked") QueryResult evaluate(final HL7Message message); String toTreeString(); }
HL7Query { static Map<String, Object> assignAliases(final LinkedHashMap<String, List<Object>> possibleValues, final int iteration) { final Map<String, Object> aliasMap = new HashMap<>(); int divisor = 1; for (final Map.Entry<String, List<Object>> entry : possibleValues.entrySet()) { final String alias = entry.getKey(); final List<Object> validValues = entry.getValue(); final int idx = (iteration / divisor) % validValues.size(); final Object obj = validValues.get(idx); aliasMap.put(alias, obj); divisor *= validValues.size(); } return aliasMap; } private  HL7Query(final Tree tree, final String query); String getQuery(); @Override String toString(); static HL7Query compile(final String query); List<Class<?>> getReturnTypes(); @SuppressWarnings("unchecked") QueryResult evaluate(final HL7Message message); String toTreeString();  }