use of com.canoo.dp.impl.remoting.PropertyImpl in project dolphin-platform by canoo.
the class PropertyBinderImpl method bind.
public <T> Binding bind(final Property<T> property, final Qualifier<T> qualifier) {
Assert.requireNonNull(property, "property");
Assert.requireNonNull(qualifier, "qualifier");
if (property instanceof PropertyImpl) {
try {
final PropertyImpl p = (PropertyImpl) property;
final Field attributeField = ReflectionHelper.getInheritedDeclaredField(PropertyImpl.class, "attribute");
final ServerAttribute attribute = (ServerAttribute) ReflectionHelper.getPrivileged(attributeField, p);
if (attribute == null) {
throw new NullPointerException("attribute == null");
}
attribute.setQualifier(qualifier.getIdentifier());
return new Binding() {
@Override
public void unbind() {
attribute.setQualifier(null);
}
};
} catch (Exception e) {
throw new BindingException("Can not bind the given property to the qualifier! Property: " + property + ", qualifier: " + qualifier, e);
}
} else {
throw new BindingException("Can not bind the given property to the qualifier! Property: " + property + ", qualifier: " + qualifier);
}
}
Aggregations