@Test public void testFunctionLibrary() { FunctionLibrary baseLib = new FunctionLibrary(); Function f1 = new StringLiteralFunction("test1"); Function f2 = new StringLiteralFunction("test2"); assertThrows(NullPointerException.class, () -> baseLib.add(null, f1)); assertThrows(NullPointerException.class, () -> baseLib.add("test1", null)); baseLib.add("test1", f1); assertEquals(f1, baseLib.get("test1")); assertTrue(baseLib.hasFunction("test1")); assertFalse(baseLib.hasFunction("test2")); assertNull(baseLib.get("test2")); assertEquals(1, baseLib.getFunctionNames().size()); FunctionLibrary lib = new FunctionLibrary(baseLib, true); lib.add("test2", f2); assertEquals(f1, lib.get("test1")); assertTrue(lib.hasFunction("test1")); assertEquals(2, lib.getFunctionNames().size()); Iterator<Function> iter = lib.iterator(); assertTrue(iter.hasNext()); assertEquals(f2, iter.next()); assertFalse(iter.hasNext()); assertThrows(UnsupportedOperationException.class, () -> iter.remove()); assertTrue(lib.remove("test2")); assertTrue(baseLib.remove("test1")); }
public FunctionLibrary() { this(null); }
FunctionLibrary implements Iterable<Function> { public FunctionLibrary() { this(null); } }
FunctionLibrary implements Iterable<Function> { public FunctionLibrary() { this(null); } FunctionLibrary();  FunctionLibrary(FunctionLibrary baselib);  FunctionLibrary(FunctionLibrary baselib, boolean ordered); }
FunctionLibrary implements Iterable<Function> { public FunctionLibrary() { this(null); } FunctionLibrary();  FunctionLibrary(FunctionLibrary baselib);  FunctionLibrary(FunctionLibrary baselib, boolean ordered); void add(String funcName, Function func); Function get(String funcName); boolean remove(String funcName); boolean hasFunction(String funcName); Set<String> getFunctionNames(); @Override Iterator<Function> iterator(); }
FunctionLibrary implements Iterable<Function> { public FunctionLibrary() { this(null); } FunctionLibrary();  FunctionLibrary(FunctionLibrary baselib);  FunctionLibrary(FunctionLibrary baselib, boolean ordered); void add(String funcName, Function func); Function get(String funcName); boolean remove(String funcName); boolean hasFunction(String funcName); Set<String> getFunctionNames(); @Override Iterator<Function> iterator(); static final String ERROR; }