@Test public void findModel(){ PMML pmml = new PMML(); TreeModel firstTreeModel = new TreeModel() .setModelName("first"); TreeModel secondTreeModel = new TreeModel() .setModelName("second"); pmml.addModels(firstTreeModel, secondTreeModel); assertSame(firstTreeModel, PMMLUtil.findModel(pmml, TreeModel.class)); firstTreeModel.setScorable(false); assertSame(secondTreeModel, PMMLUtil.findModel(pmml, TreeModel.class)); secondTreeModel.setScorable(false); try { PMMLUtil.findModel(pmml, TreeModel.class); fail(); } catch(MissingElementException mee){ } }
static public Model findModel(PMML pmml, String modelName){ Model model; if(modelName != null){ model = PMMLUtil.findModel(pmml, (Model object) -> Objects.equals(object.getModelName(), modelName), "<Model>@modelName=" + modelName); } else { model = PMMLUtil.findModel(pmml, (Model object) -> object.isScorable(), "<Model>@isScorable=true"); } return model; }
PMMLUtil { static public Model findModel(PMML pmml, String modelName){ Model model; if(modelName != null){ model = PMMLUtil.findModel(pmml, (Model object) -> Objects.equals(object.getModelName(), modelName), "<Model>@modelName=" + modelName); } else { model = PMMLUtil.findModel(pmml, (Model object) -> object.isScorable(), "<Model>@isScorable=true"); } return model; } }
PMMLUtil { static public Model findModel(PMML pmml, String modelName){ Model model; if(modelName != null){ model = PMMLUtil.findModel(pmml, (Model object) -> Objects.equals(object.getModelName(), modelName), "<Model>@modelName=" + modelName); } else { model = PMMLUtil.findModel(pmml, (Model object) -> object.isScorable(), "<Model>@isScorable=true"); } return model; } private  PMMLUtil(); }
PMMLUtil { static public Model findModel(PMML pmml, String modelName){ Model model; if(modelName != null){ model = PMMLUtil.findModel(pmml, (Model object) -> Objects.equals(object.getModelName(), modelName), "<Model>@modelName=" + modelName); } else { model = PMMLUtil.findModel(pmml, (Model object) -> object.isScorable(), "<Model>@isScorable=true"); } return model; } private  PMMLUtil(); static Model findModel(PMML pmml, String modelName); static M findModel(PMML pmml, Class<? extends M> clazz); static Model findModel(PMML pmml, Predicate<Model> predicate, String predicateXPath); }
PMMLUtil { static public Model findModel(PMML pmml, String modelName){ Model model; if(modelName != null){ model = PMMLUtil.findModel(pmml, (Model object) -> Objects.equals(object.getModelName(), modelName), "<Model>@modelName=" + modelName); } else { model = PMMLUtil.findModel(pmml, (Model object) -> object.isScorable(), "<Model>@isScorable=true"); } return model; } private  PMMLUtil(); static Model findModel(PMML pmml, String modelName); static M findModel(PMML pmml, Class<? extends M> clazz); static Model findModel(PMML pmml, Predicate<Model> predicate, String predicateXPath);  }