private Clickable getClickable(String name) { List<Field> fields = ReflectionUtils.getFields(this, IClickable.class); Collection<Clickable> clickables = select(fields, f -> (Clickable) ReflectionUtils.getFieldValue(f, this)); return LinqUtils.first( clickables, cl -> cl.getName().contains(getElementName(name.toLowerCase()))); }
private Button getSubmitButton() { List<Field> fields = ReflectionUtils.getFields(this, IButton.class); switch (fields.size()) { case 0: throw JDISettings.exception("Can't find any buttons on form '%s.", toString()); case 1: return (Button) ReflectionUtils.getFieldValue(fields.get(0), this); default: throw JDISettings.exception( "Form '%s' have more than 1 button. Use submit(entity, buttonName) for this case instead", toString()); } }
public void fill(MapArray<String, String> objStrings) { LinqUtils.foreach( ReflectionUtils.getFields(this, ISetValue.class), element -> { String fieldValue = objStrings.first( (name, value) -> GetElement.namesEqual(name, AnnotationsUtil.getElementName(element))); if (fieldValue != null) { ISetValue setValueElement = (ISetValue) ReflectionUtils.getFieldValue(element, this); doActionRule.invoke(fieldValue, val -> setValueAction(val, setValueElement)); } }); }
public void verify(MapArray<String, String> objStrings, JActionTT<String, String> compare) { LinqUtils.foreach( ReflectionUtils.getFields(this, IHasValue.class), element -> { String fieldValue = objStrings.first( (name, value) -> GetElement.namesEqual(name, AnnotationsUtil.getElementName(element))); if (fieldValue != null) { IHasValue getValueElement = (IHasValue) ReflectionUtils.getFieldValue(element, this); doActionRule.invoke( fieldValue, val -> compare.invoke(getValueAction(getValueElement).trim(), val)); } }); }
private void setText(String text) { Field field = ReflectionUtils.getFields(this, ISetValue.class).get(0); ISetValue setValueElement = (ISetValue) ReflectionUtils.getFieldValue(field, this); doActionRule.invoke(text, val -> setValueAction(val, setValueElement)); }
protected String getValueAction() { return PrintUtils.print( LinqUtils.select( ReflectionUtils.getFields(this, IHasValue.class), field -> ((IHasValue) ReflectionUtils.getFieldValue(field, this)).getValue())); }