Sets the property on the given object to the new value. @param object on which to set the property @param newValue the new value of the property @throws RuntimeException if the property could not be set
(final Object object, Object newValue)
| 98 | * @throws RuntimeException if the property could not be set |
| 99 | */ |
| 100 | @Override |
| 101 | public void setProperty(final Object object, Object newValue) { |
| 102 | MetaMethod setter = getSetter(); |
| 103 | if (setter == null) { |
| 104 | CachedField field = getField(); |
| 105 | if (field != null && !field.isFinal()) { |
| 106 | field.setProperty(object, newValue); |
| 107 | return; |
| 108 | } |
| 109 | throw new GroovyRuntimeException("Cannot set read-only property: " + name); |
| 110 | } |
| 111 | newValue = DefaultTypeTransformation.castToType(newValue, getType()); |
| 112 | setter.invoke(object, new Object[]{newValue}); |
| 113 | } |
| 114 | |
| 115 | //-------------------------------------------------------------------------- |
| 116 |
no test coverage detected