@Test public void divideFunction() throws Exception { NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(1); Function divident = new StringLiteralFunction("10"); Function divisor = new StringLiteralFunction("30"); Function f = new DivideFunction(divident, divisor, 1, 3); assertEquals(0, f.parameters().length); assertEquals(nf.format(0.333), f.getString(null)); assertFalse(f.getBoolean(null)); Collection<String> dialogFunctions = new ArrayList<>(); f.getFunctionDialogReferences(dialogFunctions); assertTrue(dialogFunctions.isEmpty()); f = new DivideFunction(divident, null, 1, 2); assertEquals(nf.format(10.0), f.getString(null)); f = new DivideFunction(divident, new StringLiteralFunction(FunctionLibrary.ERROR), 1, 2); assertEquals(FunctionLibrary.ERROR, f.getString(null)); f = new DivideFunction(new StringLiteralFunction(FunctionLibrary.ERROR), divisor, 1, 2); assertEquals(FunctionLibrary.ERROR, f.getString(null)); f = new DivideFunction(divident, new StringLiteralFunction("0"), 1, 2); assertEquals(FunctionLibrary.ERROR, f.getString(null)); f = new DivideFunction(new StringLiteralFunction("0"), divisor, 0, 2); assertEquals("0", f.getString(null)); }
public DivideFunction(Function dividendFunction, Function divisorFunction, int minScale, int maxScale) { Set<String> myparams = new HashSet<>(); myparams.addAll(Arrays.asList(dividendFunction.parameters())); if (divisorFunction != null) myparams.addAll(Arrays.asList(divisorFunction.parameters())); params = myparams.toArray(new String[0]); this.dividendFunction = dividendFunction; this.divisorFunction = divisorFunction; this.minScale = minScale; this.maxScale = maxScale; }
DivideFunction implements Function { public DivideFunction(Function dividendFunction, Function divisorFunction, int minScale, int maxScale) { Set<String> myparams = new HashSet<>(); myparams.addAll(Arrays.asList(dividendFunction.parameters())); if (divisorFunction != null) myparams.addAll(Arrays.asList(divisorFunction.parameters())); params = myparams.toArray(new String[0]); this.dividendFunction = dividendFunction; this.divisorFunction = divisorFunction; this.minScale = minScale; this.maxScale = maxScale; } }
DivideFunction implements Function { public DivideFunction(Function dividendFunction, Function divisorFunction, int minScale, int maxScale) { Set<String> myparams = new HashSet<>(); myparams.addAll(Arrays.asList(dividendFunction.parameters())); if (divisorFunction != null) myparams.addAll(Arrays.asList(divisorFunction.parameters())); params = myparams.toArray(new String[0]); this.dividendFunction = dividendFunction; this.divisorFunction = divisorFunction; this.minScale = minScale; this.maxScale = maxScale; } DivideFunction(Function dividendFunction, Function divisorFunction,
      int minScale, int maxScale); }
DivideFunction implements Function { public DivideFunction(Function dividendFunction, Function divisorFunction, int minScale, int maxScale) { Set<String> myparams = new HashSet<>(); myparams.addAll(Arrays.asList(dividendFunction.parameters())); if (divisorFunction != null) myparams.addAll(Arrays.asList(divisorFunction.parameters())); params = myparams.toArray(new String[0]); this.dividendFunction = dividendFunction; this.divisorFunction = divisorFunction; this.minScale = minScale; this.maxScale = maxScale; } DivideFunction(Function dividendFunction, Function divisorFunction,
      int minScale, int maxScale); @Override String[] parameters(); @Override void getFunctionDialogReferences(Collection<String> set); @Override String getString(Values parameters); @Override boolean getBoolean(Values parameters); }
DivideFunction implements Function { public DivideFunction(Function dividendFunction, Function divisorFunction, int minScale, int maxScale) { Set<String> myparams = new HashSet<>(); myparams.addAll(Arrays.asList(dividendFunction.parameters())); if (divisorFunction != null) myparams.addAll(Arrays.asList(divisorFunction.parameters())); params = myparams.toArray(new String[0]); this.dividendFunction = dividendFunction; this.divisorFunction = divisorFunction; this.minScale = minScale; this.maxScale = maxScale; } DivideFunction(Function dividendFunction, Function divisorFunction,
      int minScale, int maxScale); @Override String[] parameters(); @Override void getFunctionDialogReferences(Collection<String> set); @Override String getString(Values parameters); @Override boolean getBoolean(Values parameters);  }