@Test public void replaceFunction() throws Exception { Function input = new StringLiteralFunction("abc"); Pattern p = Pattern.compile("abc"); Function replace = new StringLiteralFunction("def"); Function f = new ReplaceFunction(input, p, replace); assertEquals(0, f.parameters().length); assertEquals("def", f.getString(null)); assertFalse(f.getBoolean(null)); Collection<String> dialogFunctions = new ArrayList<>(); f.getFunctionDialogReferences(dialogFunctions); assertTrue(dialogFunctions.isEmpty()); f = new ReplaceFunction(new StringLiteralFunction(FunctionLibrary.ERROR), p, replace); assertEquals(FunctionLibrary.ERROR, f.getString(null)); f = new ReplaceFunction(input, p, new StringLiteralFunction(FunctionLibrary.ERROR)); assertEquals(FunctionLibrary.ERROR, f.getString(null)); }
public ReplaceFunction(Function input, Pattern p, Function replace) { pattern = p; this.input = input; this.replace = replace; Set<String> paramset = new HashSet<>(); paramset.addAll(Arrays.asList(input.parameters())); paramset.addAll(Arrays.asList(replace.parameters())); this.params = paramset.toArray(new String[] {}); }
ReplaceFunction implements Function { public ReplaceFunction(Function input, Pattern p, Function replace) { pattern = p; this.input = input; this.replace = replace; Set<String> paramset = new HashSet<>(); paramset.addAll(Arrays.asList(input.parameters())); paramset.addAll(Arrays.asList(replace.parameters())); this.params = paramset.toArray(new String[] {}); } }
ReplaceFunction implements Function { public ReplaceFunction(Function input, Pattern p, Function replace) { pattern = p; this.input = input; this.replace = replace; Set<String> paramset = new HashSet<>(); paramset.addAll(Arrays.asList(input.parameters())); paramset.addAll(Arrays.asList(replace.parameters())); this.params = paramset.toArray(new String[] {}); } ReplaceFunction(Function input, Pattern p, Function replace); }
ReplaceFunction implements Function { public ReplaceFunction(Function input, Pattern p, Function replace) { pattern = p; this.input = input; this.replace = replace; Set<String> paramset = new HashSet<>(); paramset.addAll(Arrays.asList(input.parameters())); paramset.addAll(Arrays.asList(replace.parameters())); this.params = paramset.toArray(new String[] {}); } ReplaceFunction(Function input, Pattern p, Function replace); @Override String getString(Values parameters); @Override String[] parameters(); @Override void getFunctionDialogReferences(Collection<String> set); @Override boolean getBoolean(Values parameters); }
ReplaceFunction implements Function { public ReplaceFunction(Function input, Pattern p, Function replace) { pattern = p; this.input = input; this.replace = replace; Set<String> paramset = new HashSet<>(); paramset.addAll(Arrays.asList(input.parameters())); paramset.addAll(Arrays.asList(replace.parameters())); this.params = paramset.toArray(new String[] {}); } ReplaceFunction(Function input, Pattern p, Function replace); @Override String getString(Values parameters); @Override String[] parameters(); @Override void getFunctionDialogReferences(Collection<String> set); @Override boolean getBoolean(Values parameters);  }