public static <S, V> FastBeanProperty create (final String name) { return new FastBeanProperty<S, V>(name); }
@Override public boolean isReadable (final S bean) { try { getGetter(bean); return true; } catch (Exception e) { return false; } }
@Override public boolean isWriteable (final S bean) { try { getSetter(bean); return true; } catch (Exception e) { return false; } }
@Override public boolean isAvailable() { FastBeanProperty available = FastBeanProperty.create("available"); if (!available.isReadable(get())) // in a couple of tests we put arbitrary classes here { return true; } return (Boolean)available.getValue(get()); } }
private Method getSetter (final S bean) { final String key = bean.getClass().getName() + "." + name; Method setter = setterCache.get(key); if (setter == null) { try { setter = bean.getClass().getMethod("set" + capitalized(name), getWriteType(bean)); setterCache.put(key, setter); } catch (Exception e) { throw new RuntimeException(e); } } return setter; }
private Method getGetter (final S bean) { final String key = bean.getClass().getName() + "." + name; Method getter = getterCache.get(key); if (getter == null) { try { getter = bean.getClass().getMethod("get" + capitalized(name)); } catch (Exception e) { try { getter = bean.getClass().getMethod("is" + capitalized(name)); } catch (Exception e2) { throw new RuntimeException(e2); } } getterCache.put(key, getter); } return getter; }
private Method getSetter (final S bean) { final String key = bean.getClass().getName() + "." + name; Method setter = setterCache.get(key); if (setter == null) { try { setter = bean.getClass().getMethod("set" + capitalized(name), getWriteType(bean)); setterCache.put(key, setter); } catch (Exception e) { throw new RuntimeException(e); } } return setter; }
private Method getGetter (final S bean) { final String key = bean.getClass().getName() + "." + name; Method getter = getterCache.get(key); if (getter == null) { try { getter = bean.getClass().getMethod("get" + capitalized(name)); } catch (Exception e) { try { getter = bean.getClass().getMethod("is" + capitalized(name)); } catch (Exception e2) { throw new RuntimeException(e2); } } getterCache.put(key, getter); } return getter; }
final Property property = FastBeanProperty.create(propertyName);
@Override public boolean isReadable (final S bean) { try { getGetter(bean); return true; } catch (Exception e) { return false; } }
@Override public boolean isWriteable (final S bean) { try { getSetter(bean); return true; } catch (Exception e) { return false; } }
public static <S, V> FastBeanProperty create (final String name) { return new FastBeanProperty<S, V>(name); }
@Override public Class<? extends V> getWriteType (final S bean) { return (Class<? extends V>)getGetter(bean).getReturnType(); }
@Override public void setValue (final S bean, final V value) { try { getSetter(bean).invoke(bean, value); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
@Override public Class<? extends V> getWriteType (final S bean) { return (Class<? extends V>)getGetter(bean).getReturnType(); }
@Override public void setValue (final S bean, final V value) { try { getSetter(bean).invoke(bean, value); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
@Override public V getValue (final S bean) { try { return (V)getGetter(bean).invoke(bean); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
@Override public V getValue (final S bean) { try { return (V)getGetter(bean).invoke(bean); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }