/** * Returns the value of the specified Field on the object bound by this {@link BindingContext} * * @param field {@link Field} to pull the value from * @param klass return type of value in the {@link Field} * @return value of type <code>klass</code> from field <code>field</code> on bound object. * @throws IllegalArgumentException if the passed {@link Field} is not a field on the object * bound by this {@link BindingContext} */ public <T> T getFieldObject(Field field, Class<T> klass) throws IllegalArgumentException { return Reflections.getFieldObject(object, field, klass); }
/** * If Throwable is a RuntimeException or Error, rethrow it. If not, throw a * new PalantirRuntimeException(ex) */ public static RuntimeException throwUncheckedException(Throwable ex) { throwIfInstance(ex, RuntimeException.class); throwIfInstance(ex, Error.class); throw createRuntimeException(ex); }
public boolean apply(Field from) { return isFieldFinal(from); } };
public void actionPerformed(ActionEvent e) { try { mutator.set(enumValue); } catch (Exception ex) { Wiring.logger.error("exception in JToggleButton binding", ex); //$NON-NLS-1$ } } });
public <T extends Enum<?> & ModelUpdate> void update(T... changed) { if (!BindingContext.isOn(ons, changed)) { return; } try { updateComboModel(combo, (List<?>)mutator.get(), nullValue); } catch (Exception ex) { Wiring.logger.error("exception in JList binding", ex); } } };
/** * Starting at the bottom of a class hierarchy, visit all classes (ancestors) in the hierarchy. Does * not visit interfaces. * @param klass Class to use as the bottom of the class hierarchy * @param visitor Visitor object */ public static void visitClassHierarchy(Class<?> klass, Visitor<Class<?>> visitor) { while (klass != null) { visitor.visit(klass); klass = klass.getSuperclass(); } }
public void visit(Class<?> c) { annotatedFields.addAll(getAnnotatedFields(c, annotation)); } });
public void visit(Class<?> c) { classes.addAll(getTypesOfType(c, targetClass)); } });
public void visit(Class<?> c) { fields.addAll(getFieldsOfType(c, targetClass)); } });
public List<Field> getAnnotatedFields(Class<? extends Annotation> klass) { return Reflections.getAnnotatedFieldsForClassHierarchy(object.getClass(), klass); }
private static RuntimeException createRuntimeException(Throwable ex) { return createRuntimeException(ex.getMessage(), ex); }
public List<ObjectFieldMethod> getAnnotatedParameterlessMethods(final Class<? extends Annotation> annotation) { return Lists.newArrayList(Iterables.filter(Reflections.getParameterlessMethodsForClassHierarchy(object), new Predicate<ObjectFieldMethod>() { public boolean apply(ObjectFieldMethod input) { return input.getMethod().isAnnotationPresent(annotation); } })); }
public T apply(F from) { try { return returnType.cast(readMethod.invoke(from)); } catch (Exception e) { throw Throwables.throwUncheckedException(e); } } };
public void actionPerformed(ActionEvent e) { try { mutator.set(booleanValue); } catch (Exception ex) { Wiring.logger.error("exception in JRadioButton binding", ex); //$NON-NLS-1$ } } });
public <T extends Enum<?> & ModelUpdate> void update(T... changed) { try { button.setSelected(mutator.get() == enumValue); } catch (Exception ex) { Wiring.logger.error("exception in JToggleButton binding", ex); //$NON-NLS-1$ } } };
private void updateModel() { try { mutator.set(textField.getText()); } catch (Exception ex) { Wiring.logger.error("exception in JTextField binding", ex); } } });
public <T extends Enum<?> & ModelUpdate> void update(T... changed) { if (!BindingContext.isOn(ons, changed)) { return; } try { updateListModel(list, (List<?>)mutator.get()); } catch (Exception ex) { Wiring.logger.error("exception in JList binding", ex); } } };
public void stateChanged(ChangeEvent e) { try { if (!slider.getValueIsAdjusting()) { mutator.set(slider.getValue()); } } catch (Exception ex) { Wiring.logger.error("exception in JSlider binding", ex); } } };
public <T extends Enum<?> & ModelUpdate> void update(T... changed) { try { abstractButton.setSelected((Boolean)mutator.get()); } catch (Exception ex) { Wiring.logger.error("exception in AbstractButton binding", ex); } } };
public void actionPerformed(ActionEvent e) { try { mutator.set(abstractButton.isSelected()); } catch (Exception ex) { Wiring.logger.error("exception in AbstractButton binding", ex); } } });