@Test public void testParseMatch() throws Exception { Function f = FunctionFactory.parse(new ConfigThingy("MATCH", "\"abc\""), funcLib, dialogLib, context); assertTrue(f instanceof MatchFunction); assertThrows(ConfigurationErrorException.class, () -> FunctionFactory.parse(new ConfigThingy("MATCH", "\"abc\" \"[\""), funcLib, dialogLib, context)); }
private static Function parseMATCH(ConfigThingy conf, FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context) { Function strFun; Function reFun; try { strFun = parse(conf.getFirstChild(), funcLib, dialogLib, context); reFun = parse(conf.getLastChild(), funcLib, dialogLib, context); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException( L.m("Funktion vom Typ \"MATCH\" erfordert genau 2 Parameter, nicht %1", conf.count()), x); } String regex = reFun.getString(new Values.None()); Pattern p; try { p = Pattern.compile(regex); } catch (PatternSyntaxException x) { throw new ConfigurationErrorException(L.m("Fehler in regex \"%1\"", regex), x); } return new MatchFunction(strFun, p); }
FunctionFactory { private static Function parseMATCH(ConfigThingy conf, FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context) { Function strFun; Function reFun; try { strFun = parse(conf.getFirstChild(), funcLib, dialogLib, context); reFun = parse(conf.getLastChild(), funcLib, dialogLib, context); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException( L.m("Funktion vom Typ \"MATCH\" erfordert genau 2 Parameter, nicht %1", conf.count()), x); } String regex = reFun.getString(new Values.None()); Pattern p; try { p = Pattern.compile(regex); } catch (PatternSyntaxException x) { throw new ConfigurationErrorException(L.m("Fehler in regex \"%1\"", regex), x); } return new MatchFunction(strFun, p); } }
FunctionFactory { private static Function parseMATCH(ConfigThingy conf, FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context) { Function strFun; Function reFun; try { strFun = parse(conf.getFirstChild(), funcLib, dialogLib, context); reFun = parse(conf.getLastChild(), funcLib, dialogLib, context); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException( L.m("Funktion vom Typ \"MATCH\" erfordert genau 2 Parameter, nicht %1", conf.count()), x); } String regex = reFun.getString(new Values.None()); Pattern p; try { p = Pattern.compile(regex); } catch (PatternSyntaxException x) { throw new ConfigurationErrorException(L.m("Fehler in regex \"%1\"", regex), x); } return new MatchFunction(strFun, p); } private  FunctionFactory(); }
FunctionFactory { private static Function parseMATCH(ConfigThingy conf, FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context) { Function strFun; Function reFun; try { strFun = parse(conf.getFirstChild(), funcLib, dialogLib, context); reFun = parse(conf.getLastChild(), funcLib, dialogLib, context); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException( L.m("Funktion vom Typ \"MATCH\" erfordert genau 2 Parameter, nicht %1", conf.count()), x); } String regex = reFun.getString(new Values.None()); Pattern p; try { p = Pattern.compile(regex); } catch (PatternSyntaxException x) { throw new ConfigurationErrorException(L.m("Fehler in regex \"%1\"", regex), x); } return new MatchFunction(strFun, p); } private  FunctionFactory(); static Function alwaysTrueFunction(); static Function parseGrandchildren(ConfigThingy conf,
      FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context); static Function parseChildren(ConfigThingy conf, FunctionLibrary funcLib,
      DialogLibrary dialogLib, Map<Object, Object> context); static Function parse(ConfigThingy conf, FunctionLibrary funcLib,
      DialogLibrary dialogLib, Map<Object, Object> context); static FunctionLibrary parseFunctions(ConfigThingy conf,
      DialogLibrary dialogLib, Map<Object, Object> context, FunctionLibrary baselib); static FunctionLibrary parseFunctions(FunctionLibrary funcs,
      ConfigThingy conf, String section, DialogLibrary dialogLib,
      Map<Object, Object> context); static Map<String, Function> parseTrafos(ConfigThingy trafoConf, String nodeName, FunctionLibrary funcLib, DialogLibrary dialogLib,
      Map<Object, Object> context); }
FunctionFactory { private static Function parseMATCH(ConfigThingy conf, FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context) { Function strFun; Function reFun; try { strFun = parse(conf.getFirstChild(), funcLib, dialogLib, context); reFun = parse(conf.getLastChild(), funcLib, dialogLib, context); } catch (NodeNotFoundException x) { throw new ConfigurationErrorException( L.m("Funktion vom Typ \"MATCH\" erfordert genau 2 Parameter, nicht %1", conf.count()), x); } String regex = reFun.getString(new Values.None()); Pattern p; try { p = Pattern.compile(regex); } catch (PatternSyntaxException x) { throw new ConfigurationErrorException(L.m("Fehler in regex \"%1\"", regex), x); } return new MatchFunction(strFun, p); } private  FunctionFactory(); static Function alwaysTrueFunction(); static Function parseGrandchildren(ConfigThingy conf,
      FunctionLibrary funcLib, DialogLibrary dialogLib, Map<Object, Object> context); static Function parseChildren(ConfigThingy conf, FunctionLibrary funcLib,
      DialogLibrary dialogLib, Map<Object, Object> context); static Function parse(ConfigThingy conf, FunctionLibrary funcLib,
      DialogLibrary dialogLib, Map<Object, Object> context); static FunctionLibrary parseFunctions(ConfigThingy conf,
      DialogLibrary dialogLib, Map<Object, Object> context, FunctionLibrary baselib); static FunctionLibrary parseFunctions(FunctionLibrary funcs,
      ConfigThingy conf, String section, DialogLibrary dialogLib,
      Map<Object, Object> context); static Map<String, Function> parseTrafos(ConfigThingy trafoConf, String nodeName, FunctionLibrary funcLib, DialogLibrary dialogLib,
      Map<Object, Object> context);  }