if (property1Name == null)
throw new NullPointerException("PropertyName1 must not be null.");
if (property2Name == null)
throw new NullPointerException("PropertyName2 must not be null.");
if ((bean1 == bean2) && (property1Name.equals(property2Name)))
throw new UsageException(
"Cannot connect a bean property to itself on the same bean.");
this.bean1 = bean1;
this.bean2 = bean2;
this.property1Name = property1Name;
this.property2Name = property2Name;
property1Descriptor = getPropertyDescriptor(bean1, property1Name);
property2Descriptor = getPropertyDescriptor(bean2, property2Name);
boolean canWriteProperty1 = property1Descriptor.getWriteMethod() != null;
boolean canWriteProperty2 = property2Descriptor.getWriteMethod() != null;
// Reject to connect to read-only properties
if (!canWriteProperty1 && !canWriteProperty2)
throw new UsageException(
"Cannot connect two read-only properties.");
property1ChangeHandler = new PropertyChangeHandler(
bean1, property1Descriptor, bean2, property2Descriptor);
property2ChangeHandler = new PropertyChangeHandler(