/** * Generate only the values which have matching keys in the provided * map according to their bind point names, and assign them to the * map under that name. It is an error for a key name to be defined * in the map for which there is no mapper. * * @param donorMap - a user-provided Map<String,Object> * @param input - the input for which to generate the values */ public void updateMap(Map<String, Object> donorMap, long input) { for (String s : donorMap.keySet()) { donorMap.put(s, get(s, input)); } }
private Object getFieldValue(String fieldName, long coordinate) { int i = bindings.getTemplate().getBindPointNames().indexOf(fieldName); if (i<0) { throw new RuntimeException("field name '" + fieldName + "' does not exist in bindings:" + bindings); } Object o = bindings.get(i, coordinate); return o; }
@Override public String bindValues(StringCompositor context, Bindings bindings, long cycle) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < templateSegments.length; i++) { if (i % 2 == 0) { sb.append(templateSegments[i]); } else { String key = templateSegments[i]; Object value = bindings.get(key, cycle); String valueString = stringfunc.apply(value); sb.append(valueString); } } return sb.toString(); }
for (int i = 0; i < count; i++) { for (String f : fieldNames) { suffixedMap.put(f+i,get(f,input+i));
/** * Generate only the values named in fieldNames, and then call the user-provided * field setter for each name and object generated. * * @param fieldSetter user-provided object that implements {@link FieldSetter}. * @param input the input for which to generate values * @param fieldName A varargs list of field names, or a String[] of names to set */ public void setNamedFields(FieldSetter fieldSetter, long input, String... fieldName) { for (String s : fieldName) { fieldSetter.setField(s, get(s, input)); } }
/** * Generate all the values named in the bindings for a number of iterations, calling * a user-provided field setter for each name and object generated, with the * iteration number appended to the fieldName, but only for the named bindings. * * @param fieldSetter user-provided object that implements {@link FieldSetter} * @param input the base input value for which the objects should be generated * @param count the number of iterations to generate values and names for * @param fieldName the field names for which to generate values and names */ public void setNamedFieldsIterated(FieldSetter fieldSetter, long input, int count, String... fieldName) { for (int i = 0; i < count; i++) { for (String s : fieldName) { fieldSetter.setField(s + i, get(s, input + i)); } } }