MCPcopy
hub / github.com/apache/groovy / setProperty

Method setProperty

src/main/java/groovy/lang/MetaBeanProperty.java:100–113  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

invokeMissingPropertyMethod · 0.95

Calls 7

getSetterMethod · 0.95
getFieldMethod · 0.95
setPropertyMethod · 0.95
castToTypeMethod · 0.95
invokeMethod · 0.95
isFinalMethod · 0.65
getTypeMethod · 0.65

Tested by

no test coverage detected