private F.Option<ModelMetadata> getModel(final String name) { ModelMetadata modelInfo = null; try { modelInfo = (ModelMetadata) Cache.getOrElse( getClass().getName() + "_ModelMetadata_" + name, new Callable<Object>() { @Override public Object call() throws Exception { return Iterables.find( modelRegistry.getModels(), new Predicate<ModelMetadata>() { @Override public boolean apply(ModelMetadata model) { String modelName = model.getName(); return modelName.equals(name); } }, null); } }, 0); } catch (Exception e) { e.printStackTrace(); } return modelInfo == null ? F.Option.<ModelMetadata>None() : F.Option.Some(modelInfo); }
@Override public F.Option<Pager> bind(String key, Map<String, String[]> data) { if (data.containsKey(key + ".index") && data.containsKey(key + ".size")) { try { index = Integer.parseInt(data.get(key + ".index")[0]); size = Integer.parseInt(data.get(key + ".size")[0]); return F.Option.Some(this); } catch (NumberFormatException e) { return F.Option.None(); } } else { return F.Option.None(); } }
@Override public F.Option<Product> bind(String key, Map<String, String[]> data) { return F.Option.Some(findByEan(data.get("ean")[0])); }
private F.Option<? extends ControllerProxy<?, ?>> getController(ModelMetadata model) throws IncompatibleControllerException { ControllerProxy<?, ?> crud = controllerRegistry.getController(model.getKeyField().getType(), model.getType()); return crud == null ? F.Option.<ControllerProxy<?, ?>>None() : F.Option.Some(crud); }