@Test public void createObjectDirectMappingSimpleTypeNull() { Map<List<String>, Object> params = new HashMap<>(); params.put(emptyList(), null); ValueWrapper<Object> initialInstance = runnerHelper.getDirectMapping(params); Object objectRaw = runnerHelper.createObject( initialInstance, String.class.getCanonicalName(), params, this.getClass().getClassLoader()); assertNull(objectRaw); }
@SuppressWarnings("unchecked") @Override protected Object createObject(ValueWrapper<Object> initialInstance, String className, Map<List<String>, Object> params, ClassLoader classLoader) { if (initialInstance.isValid() && !(initialInstance.getValue() instanceof Map)) { return initialInstance.getValue(); } Map<String, Object> toReturn = (Map<String, Object>) initialInstance.orElseGet(HashMap::new); for (Map.Entry<List<String>, Object> listObjectEntry : params.entrySet()) { if (listObjectEntry.getKey().isEmpty()) { continue; } List<String> allSteps = listObjectEntry.getKey(); List<String> steps = allSteps.subList(0, allSteps.size() - 1); String lastStep = allSteps.get(allSteps.size() - 1); Map<String, Object> targetMap = toReturn; for (String step : steps) { targetMap = (Map<String, Object>) targetMap.computeIfAbsent(step, k -> new HashMap<>()); } targetMap.put(lastStep, listObjectEntry.getValue()); } return toReturn; }
DMNScenarioRunnerHelper extends AbstractRunnerHelper { @SuppressWarnings("unchecked") @Override protected Object createObject(ValueWrapper<Object> initialInstance, String className, Map<List<String>, Object> params, ClassLoader classLoader) { if (initialInstance.isValid() && !(initialInstance.getValue() instanceof Map)) { return initialInstance.getValue(); } Map<String, Object> toReturn = (Map<String, Object>) initialInstance.orElseGet(HashMap::new); for (Map.Entry<List<String>, Object> listObjectEntry : params.entrySet()) { if (listObjectEntry.getKey().isEmpty()) { continue; } List<String> allSteps = listObjectEntry.getKey(); List<String> steps = allSteps.subList(0, allSteps.size() - 1); String lastStep = allSteps.get(allSteps.size() - 1); Map<String, Object> targetMap = toReturn; for (String step : steps) { targetMap = (Map<String, Object>) targetMap.computeIfAbsent(step, k -> new HashMap<>()); } targetMap.put(lastStep, listObjectEntry.getValue()); } return toReturn; } }
DMNScenarioRunnerHelper extends AbstractRunnerHelper { @SuppressWarnings("unchecked") @Override protected Object createObject(ValueWrapper<Object> initialInstance, String className, Map<List<String>, Object> params, ClassLoader classLoader) { if (initialInstance.isValid() && !(initialInstance.getValue() instanceof Map)) { return initialInstance.getValue(); } Map<String, Object> toReturn = (Map<String, Object>) initialInstance.orElseGet(HashMap::new); for (Map.Entry<List<String>, Object> listObjectEntry : params.entrySet()) { if (listObjectEntry.getKey().isEmpty()) { continue; } List<String> allSteps = listObjectEntry.getKey(); List<String> steps = allSteps.subList(0, allSteps.size() - 1); String lastStep = allSteps.get(allSteps.size() - 1); Map<String, Object> targetMap = toReturn; for (String step : steps) { targetMap = (Map<String, Object>) targetMap.computeIfAbsent(step, k -> new HashMap<>()); } targetMap.put(lastStep, listObjectEntry.getValue()); } return toReturn; }  }
DMNScenarioRunnerHelper extends AbstractRunnerHelper { @SuppressWarnings("unchecked") @Override protected Object createObject(ValueWrapper<Object> initialInstance, String className, Map<List<String>, Object> params, ClassLoader classLoader) { if (initialInstance.isValid() && !(initialInstance.getValue() instanceof Map)) { return initialInstance.getValue(); } Map<String, Object> toReturn = (Map<String, Object>) initialInstance.orElseGet(HashMap::new); for (Map.Entry<List<String>, Object> listObjectEntry : params.entrySet()) { if (listObjectEntry.getKey().isEmpty()) { continue; } List<String> allSteps = listObjectEntry.getKey(); List<String> steps = allSteps.subList(0, allSteps.size() - 1); String lastStep = allSteps.get(allSteps.size() - 1); Map<String, Object> targetMap = toReturn; for (String step : steps) { targetMap = (Map<String, Object>) targetMap.computeIfAbsent(step, k -> new HashMap<>()); } targetMap.put(lastStep, listObjectEntry.getValue()); } return toReturn; }   }
DMNScenarioRunnerHelper extends AbstractRunnerHelper { @SuppressWarnings("unchecked") @Override protected Object createObject(ValueWrapper<Object> initialInstance, String className, Map<List<String>, Object> params, ClassLoader classLoader) { if (initialInstance.isValid() && !(initialInstance.getValue() instanceof Map)) { return initialInstance.getValue(); } Map<String, Object> toReturn = (Map<String, Object>) initialInstance.orElseGet(HashMap::new); for (Map.Entry<List<String>, Object> listObjectEntry : params.entrySet()) { if (listObjectEntry.getKey().isEmpty()) { continue; } List<String> allSteps = listObjectEntry.getKey(); List<String> steps = allSteps.subList(0, allSteps.size() - 1); String lastStep = allSteps.get(allSteps.size() - 1); Map<String, Object> targetMap = toReturn; for (String step : steps) { targetMap = (Map<String, Object>) targetMap.computeIfAbsent(step, k -> new HashMap<>()); } targetMap.put(lastStep, listObjectEntry.getValue()); } return toReturn; }    }