001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.apache.commons.beanutils2; 019 020import java.beans.PropertyDescriptor; 021import java.lang.reflect.InvocationTargetException; 022import java.lang.reflect.Method; 023import java.util.Map; 024 025/** 026 * <p> 027 * Utility methods for using Java Reflection APIs to facilitate generic property getter and setter operations on Java objects. 028 * </p> 029 * 030 * <p> 031 * The implementations for these methods are provided by {@code PropertyUtilsBean}. For more details see {@link PropertyUtilsBean}. 032 * </p> 033 * 034 * @see PropertyUtilsBean 035 * @see org.apache.commons.beanutils2.expression.Resolver 036 */ 037 038public class PropertyUtils { 039 040 /** 041 * Adds a {@code BeanIntrospector}. This object is invoked when the property descriptors of a class need to be obtained. 042 * 043 * @param introspector the {@code BeanIntrospector} to be added (must not be <strong>null</strong> 044 * @throws IllegalArgumentException if the argument is <strong>null</strong> 045 * @since 1.9 046 */ 047 public static void addBeanIntrospector(final BeanIntrospector introspector) { 048 PropertyUtilsBean.getInstance().addBeanIntrospector(introspector); 049 } 050 051 /** 052 * Clear any cached property descriptors information for all classes loaded by any class loaders. This is useful in cases where class loaders are thrown 053 * away to implement class reloading. 054 * 055 * <p> 056 * For more details see {@code PropertyUtilsBean}. 057 * </p> 058 * 059 * @see PropertyUtilsBean#clearDescriptors 060 */ 061 public static void clearDescriptors() { 062 PropertyUtilsBean.getInstance().clearDescriptors(); 063 } 064 065 /** 066 * <p> 067 * Copy property values from the "origin" bean to the "destination" bean for all cases where the property names are the same (even though the actual getter 068 * and setter methods might have been customized via {@code BeanInfo} classes). 069 * </p> 070 * 071 * <p> 072 * For more details see {@code PropertyUtilsBean}. 073 * </p> 074 * 075 * @param dest Destination bean whose properties are modified 076 * @param orig Origin bean whose properties are retrieved 077 * @throws IllegalAccessException if the caller does not have access to the property accessor method 078 * @throws IllegalArgumentException if the {@code dest} or {@code orig} argument is null 079 * @throws InvocationTargetException if the property accessor method throws an exception 080 * @throws NoSuchMethodException if an accessor method for this property cannot be found 081 * @see PropertyUtilsBean#copyProperties 082 */ 083 public static void copyProperties(final Object dest, final Object orig) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 084 PropertyUtilsBean.getInstance().copyProperties(dest, orig); 085 } 086 087 /** 088 * <p> 089 * Return the entire set of properties for which the specified bean provides a read method. 090 * </p> 091 * 092 * <p> 093 * For more details see {@code PropertyUtilsBean}. 094 * </p> 095 * 096 * @param bean Bean whose properties are to be extracted 097 * @return The set of properties for the bean 098 * @throws IllegalAccessException if the caller does not have access to the property accessor method 099 * @throws IllegalArgumentException if {@code bean} is null 100 * @throws InvocationTargetException if the property accessor method throws an exception 101 * @throws NoSuchMethodException if an accessor method for this property cannot be found 102 * @see PropertyUtilsBean#describe 103 */ 104 public static Map<String, Object> describe(final Object bean) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 105 return PropertyUtilsBean.getInstance().describe(bean); 106 } 107 108 /** 109 * <p> 110 * Return the value of the specified indexed property of the specified bean, with no type conversions. 111 * </p> 112 * 113 * <p> 114 * For more details see {@code PropertyUtilsBean}. 115 * </p> 116 * 117 * @param bean Bean whose property is to be extracted 118 * @param name {@code propertyname[index]} of the property value to be extracted 119 * @return the indexed property value 120 * @throws IndexOutOfBoundsException if the specified index is outside the valid range for the underlying property 121 * @throws IllegalAccessException if the caller does not have access to the property accessor method 122 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 123 * @throws InvocationTargetException if the property accessor method throws an exception 124 * @throws NoSuchMethodException if an accessor method for this property cannot be found 125 * @see PropertyUtilsBean#getIndexedProperty(Object,String) 126 */ 127 public static Object getIndexedProperty(final Object bean, final String name) 128 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 129 return PropertyUtilsBean.getInstance().getIndexedProperty(bean, name); 130 } 131 132 /** 133 * <p> 134 * Return the value of the specified indexed property of the specified bean, with no type conversions. 135 * </p> 136 * 137 * <p> 138 * For more details see {@code PropertyUtilsBean}. 139 * </p> 140 * 141 * @param bean Bean whose property is to be extracted 142 * @param name Simple property name of the property value to be extracted 143 * @param index Index of the property value to be extracted 144 * @return the indexed property value 145 * @throws IndexOutOfBoundsException if the specified index is outside the valid range for the underlying property 146 * @throws IllegalAccessException if the caller does not have access to the property accessor method 147 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 148 * @throws InvocationTargetException if the property accessor method throws an exception 149 * @throws NoSuchMethodException if an accessor method for this property cannot be found 150 * @see PropertyUtilsBean#getIndexedProperty(Object,String, int) 151 */ 152 public static Object getIndexedProperty(final Object bean, final String name, final int index) 153 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 154 return PropertyUtilsBean.getInstance().getIndexedProperty(bean, name, index); 155 } 156 157 /** 158 * <p> 159 * Return the value of the specified mapped property of the specified bean, with no type conversions. 160 * </p> 161 * 162 * <p> 163 * For more details see {@code PropertyUtilsBean}. 164 * </p> 165 * 166 * @param bean Bean whose property is to be extracted 167 * @param name {@code propertyname(key)} of the property value to be extracted 168 * @return the mapped property value 169 * @throws IllegalAccessException if the caller does not have access to the property accessor method 170 * @throws InvocationTargetException if the property accessor method throws an exception 171 * @throws NoSuchMethodException if an accessor method for this property cannot be found 172 * @see PropertyUtilsBean#getMappedProperty(Object,String) 173 */ 174 public static Object getMappedProperty(final Object bean, final String name) 175 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 176 return PropertyUtilsBean.getInstance().getMappedProperty(bean, name); 177 } 178 179 /** 180 * <p> 181 * Return the value of the specified mapped property of the specified bean, with no type conversions. 182 * </p> 183 * 184 * <p> 185 * For more details see {@code PropertyUtilsBean}. 186 * </p> 187 * 188 * @param bean Bean whose property is to be extracted 189 * @param name Mapped property name of the property value to be extracted 190 * @param key Key of the property value to be extracted 191 * @return the mapped property value 192 * @throws IllegalAccessException if the caller does not have access to the property accessor method 193 * @throws InvocationTargetException if the property accessor method throws an exception 194 * @throws NoSuchMethodException if an accessor method for this property cannot be found 195 * @see PropertyUtilsBean#getMappedProperty(Object,String, String) 196 */ 197 public static Object getMappedProperty(final Object bean, final String name, final String key) 198 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 199 return PropertyUtilsBean.getInstance().getMappedProperty(bean, name, key); 200 } 201 202 /** 203 * <p> 204 * Return the mapped property descriptors for this bean class. 205 * </p> 206 * 207 * <p> 208 * For more details see {@code PropertyUtilsBean}. 209 * </p> 210 * 211 * @param beanClass Bean class to be introspected 212 * @return the mapped property descriptors 213 * @see PropertyUtilsBean#getMappedPropertyDescriptors(Class) 214 */ 215 static Map<Class<?>, Map> getMappedPropertyDescriptors(final Class<?> beanClass) { 216 return PropertyUtilsBean.getInstance().getMappedPropertyDescriptors(beanClass); 217 } 218 219 /** 220 * <p> 221 * Return the value of the (possibly nested) property of the specified name, for the specified bean, with no type conversions. 222 * </p> 223 * 224 * <p> 225 * For more details see {@code PropertyUtilsBean}. 226 * </p> 227 * 228 * @param bean Bean whose property is to be extracted 229 * @param name Possibly nested name of the property to be extracted 230 * @return the nested property value 231 * @throws IllegalAccessException if the caller does not have access to the property accessor method 232 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 233 * @throws NestedNullException if a nested reference to a property returns null 234 * @throws InvocationTargetException if the property accessor method throws an exception 235 * @throws NoSuchMethodException if an accessor method for this property cannot be found 236 * @see PropertyUtilsBean#getNestedProperty 237 */ 238 public static Object getNestedProperty(final Object bean, final String name) 239 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 240 return PropertyUtilsBean.getInstance().getNestedProperty(bean, name); 241 } 242 243 /** 244 * <p> 245 * Return the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions. 246 * </p> 247 * 248 * <p> 249 * For more details see {@code PropertyUtilsBean}. 250 * </p> 251 * 252 * @param bean Bean whose property is to be extracted 253 * @param name Possibly indexed and/or nested name of the property to be extracted 254 * @return the property value 255 * @throws IllegalAccessException if the caller does not have access to the property accessor method 256 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 257 * @throws InvocationTargetException if the property accessor method throws an exception 258 * @throws NoSuchMethodException if an accessor method for this property cannot be found 259 * @see PropertyUtilsBean#getProperty 260 */ 261 public static Object getProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 262 return PropertyUtilsBean.getInstance().getProperty(bean, name); 263 } 264 265 /** 266 * <p> 267 * Retrieve the property descriptor for the specified property of the specified bean, or return {@code null} if there is no such descriptor. 268 * </p> 269 * 270 * <p> 271 * For more details see {@code PropertyUtilsBean}. 272 * </p> 273 * 274 * @param bean Bean for which a property descriptor is requested 275 * @param name Possibly indexed and/or nested name of the property for which a property descriptor is requested 276 * @return the property descriptor 277 * @throws IllegalAccessException if the caller does not have access to the property accessor method 278 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 279 * @throws IllegalArgumentException if a nested reference to a property returns null 280 * @throws InvocationTargetException if the property accessor method throws an exception 281 * @throws NoSuchMethodException if an accessor method for this property cannot be found 282 * @see PropertyUtilsBean#getPropertyDescriptor 283 */ 284 public static PropertyDescriptor getPropertyDescriptor(final Object bean, final String name) 285 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 286 return PropertyUtilsBean.getInstance().getPropertyDescriptor(bean, name); 287 } 288 289 /** 290 * <p> 291 * Retrieve the property descriptors for the specified class, introspecting and caching them the first time a particular bean class is encountered. 292 * </p> 293 * 294 * <p> 295 * For more details see {@code PropertyUtilsBean}. 296 * </p> 297 * 298 * @param beanClass Bean class for which property descriptors are requested 299 * @return the property descriptors 300 * @throws IllegalArgumentException if {@code beanClass} is null 301 * @see PropertyUtilsBean#getPropertyDescriptors(Class) 302 */ 303 public static PropertyDescriptor[] getPropertyDescriptors(final Class<?> beanClass) { 304 return PropertyUtilsBean.getInstance().getPropertyDescriptors(beanClass); 305 } 306 307 /** 308 * <p> 309 * Retrieve the property descriptors for the specified bean, introspecting and caching them the first time a particular bean class is encountered. 310 * </p> 311 * 312 * <p> 313 * For more details see {@code PropertyUtilsBean}. 314 * </p> 315 * 316 * @param bean Bean for which property descriptors are requested 317 * @return the property descriptors 318 * @throws IllegalArgumentException if {@code bean} is null 319 * @see PropertyUtilsBean#getPropertyDescriptors(Object) 320 */ 321 public static PropertyDescriptor[] getPropertyDescriptors(final Object bean) { 322 return PropertyUtilsBean.getInstance().getPropertyDescriptors(bean); 323 } 324 325 /** 326 * <p> 327 * Return the Java Class representing the property editor class that has been registered for this property (if any). 328 * </p> 329 * 330 * <p> 331 * For more details see {@code PropertyUtilsBean}. 332 * </p> 333 * 334 * @param bean Bean for which a property descriptor is requested 335 * @param name Possibly indexed and/or nested name of the property for which a property descriptor is requested 336 * @return the property editor class 337 * @throws IllegalAccessException if the caller does not have access to the property accessor method 338 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 339 * @throws IllegalArgumentException if a nested reference to a property returns null 340 * @throws InvocationTargetException if the property accessor method throws an exception 341 * @throws NoSuchMethodException if an accessor method for this property cannot be found 342 * @see PropertyUtilsBean#getPropertyEditorClass(Object,String) 343 */ 344 public static Class<?> getPropertyEditorClass(final Object bean, final String name) 345 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 346 return PropertyUtilsBean.getInstance().getPropertyEditorClass(bean, name); 347 } 348 349 /** 350 * <p> 351 * Return the Java Class representing the property type of the specified property, or {@code null} if there is no such property for the specified bean. 352 * </p> 353 * 354 * <p> 355 * For more details see {@code PropertyUtilsBean}. 356 * </p> 357 * 358 * @param bean Bean for which a property descriptor is requested 359 * @param name Possibly indexed and/or nested name of the property for which a property descriptor is requested 360 * @return The property type 361 * @throws IllegalAccessException if the caller does not have access to the property accessor method 362 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 363 * @throws IllegalArgumentException if a nested reference to a property returns null 364 * @throws InvocationTargetException if the property accessor method throws an exception 365 * @throws NoSuchMethodException if an accessor method for this property cannot be found 366 * @see PropertyUtilsBean#getPropertyType(Object, String) 367 */ 368 public static Class<?> getPropertyType(final Object bean, final String name) 369 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 370 return PropertyUtilsBean.getInstance().getPropertyType(bean, name); 371 } 372 373 /** 374 * <p> 375 * Return an accessible property getter method for this property, if there is one; otherwise return {@code null}. 376 * </p> 377 * 378 * <p> 379 * For more details see {@code PropertyUtilsBean}. 380 * </p> 381 * 382 * @param descriptor Property descriptor to return a getter for 383 * @return The read method 384 * @see PropertyUtilsBean#getReadMethod(PropertyDescriptor) 385 */ 386 public static Method getReadMethod(final PropertyDescriptor descriptor) { 387 return PropertyUtilsBean.getInstance().getReadMethod(descriptor); 388 } 389 390 /** 391 * <p> 392 * Return the value of the specified simple property of the specified bean, with no type conversions. 393 * </p> 394 * 395 * <p> 396 * For more details see {@code PropertyUtilsBean}. 397 * </p> 398 * 399 * @param bean Bean whose property is to be extracted 400 * @param name Name of the property to be extracted 401 * @return The property value 402 * @throws IllegalAccessException if the caller does not have access to the property accessor method 403 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 404 * @throws IllegalArgumentException if the property name is nested or indexed 405 * @throws InvocationTargetException if the property accessor method throws an exception 406 * @throws NoSuchMethodException if an accessor method for this property cannot be found 407 * @see PropertyUtilsBean#getSimpleProperty 408 */ 409 public static Object getSimpleProperty(final Object bean, final String name) 410 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 411 return PropertyUtilsBean.getInstance().getSimpleProperty(bean, name); 412 } 413 414 /** 415 * <p> 416 * Return an accessible property setter method for this property, if there is one; otherwise return {@code null}. 417 * </p> 418 * 419 * <p> 420 * For more details see {@code PropertyUtilsBean}. 421 * </p> 422 * 423 * @param descriptor Property descriptor to return a setter for 424 * @return The write method 425 * @see PropertyUtilsBean#getWriteMethod(PropertyDescriptor) 426 */ 427 public static Method getWriteMethod(final PropertyDescriptor descriptor) { 428 return PropertyUtilsBean.getInstance().getWriteMethod(descriptor); 429 } 430 431 /** 432 * <p> 433 * Return {@code true} if the specified property name identifies a readable property on the specified bean; otherwise, return {@code false}. 434 * </p> 435 * 436 * <p> 437 * For more details see {@code PropertyUtilsBean}. 438 * </p> 439 * 440 * @param bean Bean to be examined (may be a {@link DynaBean} 441 * @param name Property name to be evaluated 442 * @return {@code true} if the property is readable, otherwise {@code false} 443 * @throws IllegalArgumentException if {@code bean} or {@code name</code> is <code>null} 444 * @see PropertyUtilsBean#isReadable 445 * @since 1.6 446 */ 447 public static boolean isReadable(final Object bean, final String name) { 448 return PropertyUtilsBean.getInstance().isReadable(bean, name); 449 } 450 451 /** 452 * <p> 453 * Return {@code true} if the specified property name identifies a writable property on the specified bean; otherwise, return {@code false}. 454 * </p> 455 * 456 * <p> 457 * For more details see {@code PropertyUtilsBean}. 458 * </p> 459 * 460 * @param bean Bean to be examined (may be a {@link DynaBean} 461 * @param name Property name to be evaluated 462 * @return {@code true} if the property is writable, otherwise {@code false} 463 * @throws IllegalArgumentException if {@code bean} or {@code name</code> is <code>null} 464 * @see PropertyUtilsBean#isWriteable 465 * @since 1.6 466 */ 467 public static boolean isWriteable(final Object bean, final String name) { 468 return PropertyUtilsBean.getInstance().isWriteable(bean, name); 469 } 470 471 /** 472 * Removes the specified {@code BeanIntrospector}. 473 * 474 * @param introspector the {@code BeanIntrospector} to be removed 475 * @return <strong>true</strong> if the {@code BeanIntrospector} existed and could be removed, <strong>false</strong> otherwise 476 * @since 1.9 477 */ 478 public static boolean removeBeanIntrospector(final BeanIntrospector introspector) { 479 return PropertyUtilsBean.getInstance().removeBeanIntrospector(introspector); 480 } 481 482 /** 483 * Resets the registered {@link BeanIntrospector} objects to the initial default state. 484 * 485 * @since 1.9 486 */ 487 public static void resetBeanIntrospectors() { 488 PropertyUtilsBean.getInstance().resetBeanIntrospectors(); 489 } 490 491 /** 492 * <p> 493 * Sets the value of the specified indexed property of the specified bean, with no type conversions. 494 * </p> 495 * 496 * <p> 497 * For more details see {@code PropertyUtilsBean}. 498 * </p> 499 * 500 * @param bean Bean whose property is to be set 501 * @param name Simple property name of the property value to be set 502 * @param index Index of the property value to be set 503 * @param value Value to which the indexed property element is to be set 504 * @throws IndexOutOfBoundsException if the specified index is outside the valid range for the underlying property 505 * @throws IllegalAccessException if the caller does not have access to the property accessor method 506 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 507 * @throws InvocationTargetException if the property accessor method throws an exception 508 * @throws NoSuchMethodException if an accessor method for this property cannot be found 509 * @see PropertyUtilsBean#setIndexedProperty(Object, String, Object) 510 */ 511 public static void setIndexedProperty(final Object bean, final String name, final int index, final Object value) 512 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 513 PropertyUtilsBean.getInstance().setIndexedProperty(bean, name, index, value); 514 } 515 516 /** 517 * <p> 518 * Sets the value of the specified indexed property of the specified bean, with no type conversions. 519 * </p> 520 * 521 * <p> 522 * For more details see {@code PropertyUtilsBean}. 523 * </p> 524 * 525 * @param bean Bean whose property is to be modified 526 * @param name {@code propertyname[index]} of the property value to be modified 527 * @param value Value to which the specified property element should be set 528 * @throws IndexOutOfBoundsException if the specified index is outside the valid range for the underlying property 529 * @throws IllegalAccessException if the caller does not have access to the property accessor method 530 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 531 * @throws InvocationTargetException if the property accessor method throws an exception 532 * @throws NoSuchMethodException if an accessor method for this property cannot be found 533 * @see PropertyUtilsBean#setIndexedProperty(Object, String, Object) 534 */ 535 public static void setIndexedProperty(final Object bean, final String name, final Object value) 536 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 537 PropertyUtilsBean.getInstance().setIndexedProperty(bean, name, value); 538 } 539 540 /** 541 * <p> 542 * Sets the value of the specified mapped property of the specified bean, with no type conversions. 543 * </p> 544 * 545 * <p> 546 * For more details see {@code PropertyUtilsBean}. 547 * </p> 548 * 549 * @param bean Bean whose property is to be set 550 * @param name {@code propertyname(key)} of the property value to be set 551 * @param value The property value to be set 552 * @throws IllegalAccessException if the caller does not have access to the property accessor method 553 * @throws InvocationTargetException if the property accessor method throws an exception 554 * @throws NoSuchMethodException if an accessor method for this property cannot be found 555 * @see PropertyUtilsBean#setMappedProperty(Object, String, Object) 556 */ 557 public static void setMappedProperty(final Object bean, final String name, final Object value) 558 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 559 PropertyUtilsBean.getInstance().setMappedProperty(bean, name, value); 560 } 561 562 /** 563 * <p> 564 * Sets the value of the specified mapped property of the specified bean, with no type conversions. 565 * </p> 566 * 567 * <p> 568 * For more details see {@code PropertyUtilsBean}. 569 * </p> 570 * 571 * @param bean Bean whose property is to be set 572 * @param name Mapped property name of the property value to be set 573 * @param key Key of the property value to be set 574 * @param value The property value to be set 575 * @throws IllegalAccessException if the caller does not have access to the property accessor method 576 * @throws InvocationTargetException if the property accessor method throws an exception 577 * @throws NoSuchMethodException if an accessor method for this property cannot be found 578 * @see PropertyUtilsBean#setMappedProperty(Object, String, String, Object) 579 */ 580 public static void setMappedProperty(final Object bean, final String name, final String key, final Object value) 581 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 582 PropertyUtilsBean.getInstance().setMappedProperty(bean, name, key, value); 583 } 584 585 /** 586 * <p> 587 * Sets the value of the (possibly nested) property of the specified name, for the specified bean, with no type conversions. 588 * </p> 589 * 590 * <p> 591 * For more details see {@code PropertyUtilsBean}. 592 * </p> 593 * 594 * @param bean Bean whose property is to be modified 595 * @param name Possibly nested name of the property to be modified 596 * @param value Value to which the property is to be set 597 * @throws IllegalAccessException if the caller does not have access to the property accessor method 598 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 599 * @throws IllegalArgumentException if a nested reference to a property returns null 600 * @throws InvocationTargetException if the property accessor method throws an exception 601 * @throws NoSuchMethodException if an accessor method for this property cannot be found 602 * @see PropertyUtilsBean#setNestedProperty 603 */ 604 public static void setNestedProperty(final Object bean, final String name, final Object value) 605 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 606 PropertyUtilsBean.getInstance().setNestedProperty(bean, name, value); 607 } 608 609 /** 610 * <p> 611 * Set the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions. 612 * </p> 613 * 614 * <p> 615 * For more details see {@code PropertyUtilsBean}. 616 * </p> 617 * 618 * @param bean Bean whose property is to be modified 619 * @param name Possibly indexed and/or nested name of the property to be modified 620 * @param value Value to which this property is to be set 621 * @throws IllegalAccessException if the caller does not have access to the property accessor method 622 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 623 * @throws InvocationTargetException if the property accessor method throws an exception 624 * @throws NoSuchMethodException if an accessor method for this property cannot be found 625 * @see PropertyUtilsBean#setProperty 626 */ 627 public static void setProperty(final Object bean, final String name, final Object value) 628 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 629 PropertyUtilsBean.getInstance().setProperty(bean, name, value); 630 } 631 632 /** 633 * <p> 634 * Set the value of the specified simple property of the specified bean, with no type conversions. 635 * </p> 636 * 637 * <p> 638 * For more details see {@code PropertyUtilsBean}. 639 * </p> 640 * 641 * @param bean Bean whose property is to be modified 642 * @param name Name of the property to be modified 643 * @param value Value to which the property should be set 644 * @throws IllegalAccessException if the caller does not have access to the property accessor method 645 * @throws IllegalArgumentException if {@code bean} or {@code name} is null 646 * @throws IllegalArgumentException if the property name is nested or indexed 647 * @throws InvocationTargetException if the property accessor method throws an exception 648 * @throws NoSuchMethodException if an accessor method for this property cannot be found 649 * @see PropertyUtilsBean#setSimpleProperty 650 */ 651 public static void setSimpleProperty(final Object bean, final String name, final Object value) 652 throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { 653 PropertyUtilsBean.getInstance().setSimpleProperty(bean, name, value); 654 } 655 656}