public Collection<Binding> wire(BindingContext context) throws IllegalArgumentException { List<Field> boundFields = context.getAnnotatedFields(Bound.class); List<Binding> bindings = Lists.newArrayList(); for (Field field : boundFields) { Bound bound = field.getAnnotation(Bound.class); bindings.addAll(wire(bound, context, field)); } return bindings; }
public Collection<Binding> wire(BindingContext context) { List<Field> actions = context.getAnnotatedFields(OnClick.class); for (Field field : actions) { OnClick onClick = field.getAnnotation(OnClick.class); try { wire(onClick, field, context); } catch (Exception e) { throw new BindingException("could not wire up @OnClick on " + field.getName(), e); } } return ImmutableList.of(); }
public Collection<Binding> wire(BindingContext context) { List<Field> boundFields = context.getAnnotatedFields(BoundLocation.class); List<Binding> bindings = Lists.newArrayList(); for (Field field : boundFields) { BoundLocation bound = field.getAnnotation(BoundLocation.class); try { bindings.addAll(wire(bound, context, field)); } catch (Exception e) { throw Throwables.throwUncheckedException(e); } } return bindings; }
public Collection<Binding> wire(BindingContext context) { List<Field> actions = context.getAnnotatedFields(OnChange.class); for (Field field : actions) { OnChange change = field.getAnnotation(OnChange.class); try { wire(change, field, context); } catch (Exception e) { throw new BindingException("could not wire up @OnChange on " + field.getName(), e); } } return ImmutableList.of(); }
public Collection<Binding> wire(BindingContext context) { List<Field> boundFields = context.getAnnotatedFields(BoundSelection.class); List<Binding> bindings = Lists.newArrayList(); for (Field field : boundFields) { BoundSelection bound = field.getAnnotation(BoundSelection.class); try { bindings.addAll(wire(bound, context, field)); } catch (Exception e) { throw Throwables.throwUncheckedException(e); } } return bindings; }
public Collection<Binding> wire(BindingContext context) { List<Field> boundFields = context.getAnnotatedFields(BoundExtent.class); List<Binding> bindings = Lists.newArrayList(); for (Field field : boundFields) { BoundExtent bound = field.getAnnotation(BoundExtent.class); try { bindings.addAll(wire(bound, context, field)); } catch (Exception e) { throw Throwables.throwUncheckedException(e); } } return bindings; }
public Collection<Binding> wire(final BindingContext context) { final List<Field> actions = context.getAnnotatedFields(EnabledIf.class); final List<Binding> bindings = Lists.newArrayList(); for (final Field field : actions) { final EnabledIf action = field.getAnnotation(EnabledIf.class); final String to = action.to(); final boolean invert = (action.type() == Type.INVERTED); try { bindings.addAll(wire(to, field, context, invert)); } catch (final Exception e) { throw new BindingException("could not wire up @EnabledIf on " + field.getName(), e); } } return bindings; }
public Collection<Binding> wire(final BindingContext context) { final List<Field> actions = context.getAnnotatedFields(VisibleIf.class); final List<Binding> bindings = Lists.newArrayList(); for (final Field field : actions) { final VisibleIf action = field.getAnnotation(VisibleIf.class); final String to = action.to(); final boolean invert = (action.type() == Type.INVERTED); try { bindings.addAll(wire(to, field, context, invert)); } catch (final Exception e) { throw new BindingException("could not wire up @VisibleIf on " + field.getName(), e); } } return bindings; }
/** * Wires all {@link Action} bindings in the passed context. * Called by {@link Bindings#createBindings(BindingContext)} as part of runtime wiring * process. * * @param context */ public Collection<Binding> wire(BindingContext context) { List<Field> actions = context.getAnnotatedFields(Action.class); for (Field field : actions) { Action action = field.getAnnotation(Action.class); String call = action.call(); try { wire(call, field, context); } catch (Exception e) { throw new BindingException("could not wire up @Action on " + field.getName(), e); } } return ImmutableList.of(); }
private Map<String, ObjectFieldMethod> indexBindableMethods() throws IllegalArgumentException { // Get all fields marked @Bindable List<Field> bindables = getAnnotatedFields(Bindable.class); if (Iterables.any(bindables, Predicates.not(Reflections.IS_FIELD_FINAL))) { throw new BindingException("all @Bindables have to be final"); } // Add all BindableModels bindables.addAll(getBindableModelFields()); // Index those methods. List<ObjectFieldMethod> methods = getParameterlessMethodsOnFieldTypes(object, bindables); // Add methods for classes marked @Bindable if (Reflections.isClassAnnotatedForClassHierarchy(object, Bindable.class)) { methods.addAll(Reflections.getParameterlessMethodsForClassHierarchy(object)); } return indexMethods(methods); }
public Collection<Binding> wire(BindingContext context) { List<Field> actions = context.getAnnotatedFields(OnFocusChange.class); for (Field field : actions) { OnFocusChange focusChange = field.getAnnotation(OnFocusChange.class); String lost = normalizeString(focusChange.lost()); String gained = normalizeString(focusChange.gained()); if (Bound.Utilities.isNullOrBlank(lost) && Bound.Utilities.isNullOrBlank(gained)) { throw new BindingException("either lost or gained must be specified on @OnFocusChange on " + field.getName()); } try { wire(lost, gained, field, context); } catch (Exception e) { throw new BindingException("could not wire up @OnFocusChange " + field.getName(), e); } } return ImmutableList.of(); }
public Collection<Binding> wire(BindingContext context) { List<Field> loggedModels = context.getAnnotatedFields(LoggedModel.class); List<Binding> bindings = Lists.newArrayList(); for (Field field : loggedModels) { final LoggedModel annotation = field.getAnnotation(LoggedModel.class); final String loggerParam = annotation.logger(); final String fieldName = field.getName(); if (BindableModel.class.isAssignableFrom(field.getType())) { BindableModel model = context.getFieldObject(field, BindableModel.class); Binding binding = new Binding() { public <T extends Enum<?> & ModelUpdate> void update(T... changed) { for (T t : changed){ Logger logger = LoggerFactory.getLogger(loggerParam); if (logger.isInfoEnabled()) { logger.info(t.toString() + ": " + fieldName); } } } }; model.bind(binding); bindings.add(binding); } else { throw new BindingException("Can only log a BindableModel."); } } return bindings; } }