protected Callback createInterceptor (final Object bean, final Object ... arguments) { return new JavaBeanAspect(bean, this, arguments); } }
@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; } }
@BeforeMethod public void setup() { logger.info("******** setup()"); final JavaBeanEnhancer enhancer = new JavaBeanEnhancer(); bean = new CompositeMockItem(); enhancedBean = (CompositeMockItem)enhancer.createEnhancedBean(bean); logger.info("******** setup() completed"); }
@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()); } }
@Test public void testCorrectEventSource() throws Exception { logger.info("******** testCorrectEventSource()"); final PropertyChangeListenerMock listener = new PropertyChangeListenerMock(); ((JavaBean)enhancedBean).addPropertyChangeListener(listener); enhancedBean.setName("new name"); AssertJUnit.assertFalse(listener.events.isEmpty()); AssertJUnit.assertTrue(enhancedBean == listener.events.get(0).getSource()); }
public static <S, V> FastBeanProperty create (final String name) { return new FastBeanProperty<S, V>(name); }
/*************************************************************************** * * **************************************************************************/ private Object doEquals (Object other) { if (other instanceof JavaBean) { other = ((JavaBean)other).__getDelegate(); } return bean.equals(other); }
/*************************************************************************** * * **************************************************************************/ public JavaBeanAspect (final Object bean, final AbstractEnhancer<?> enhancer, final Object ... arguments) { this.bean = bean; fixContainedBeans(bean, enhancer, arguments); this.edtCompliant = Arrays.asList(arguments).contains(JavaBeanEnhancer.EDT_COMPLIANT); }
@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; } }
protected Callback createInterceptor (final Object bean, final Object ... arguments) { return new JavaBeanAspect(bean, this, arguments); } }
public static <S, V> FastBeanProperty create (final String name) { return new FastBeanProperty<S, V>(name); }
/*************************************************************************** * * **************************************************************************/ private Object doEquals (Object other) { if (other instanceof JavaBean) { other = ((JavaBean)other).__getDelegate(); } return bean.equals(other); }
/*************************************************************************** * * **************************************************************************/ public JavaBeanAspect (final Object bean, final AbstractEnhancer<?> enhancer, final Object ... arguments) { this.bean = bean; fixContainedBeans(bean, enhancer, arguments); this.edtCompliant = Arrays.asList(arguments).contains(JavaBeanEnhancer.EDT_COMPLIANT); }
@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 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); } }