PropertyUtils.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */

  17. package org.apache.commons.beanutils2;

  18. import java.beans.PropertyDescriptor;
  19. import java.lang.reflect.InvocationTargetException;
  20. import java.lang.reflect.Method;
  21. import java.util.Map;

  22. /**
  23.  * <p>
  24.  * Utility methods for using Java Reflection APIs to facilitate generic property getter and setter operations on Java objects.
  25.  * </p>
  26.  *
  27.  * <p>
  28.  * The implementations for these methods are provided by {@code PropertyUtilsBean}. For more details see {@link PropertyUtilsBean}.
  29.  * </p>
  30.  *
  31.  * @see PropertyUtilsBean
  32.  * @see org.apache.commons.beanutils2.expression.Resolver
  33.  */

  34. public final class PropertyUtils {

  35.     /**
  36.      * Adds a {@code BeanIntrospector}. This object is invoked when the property descriptors of a class need to be obtained.
  37.      *
  38.      * @param introspector the {@code BeanIntrospector} to be added (must not be <strong>null</strong>
  39.      * @throws IllegalArgumentException if the argument is <strong>null</strong>
  40.      * @since 1.9
  41.      */
  42.     public static void addBeanIntrospector(final BeanIntrospector introspector) {
  43.         PropertyUtilsBean.getInstance().addBeanIntrospector(introspector);
  44.     }

  45.     /**
  46.      * Clear any cached property descriptors information for all classes loaded by any class loaders. This is useful in cases where class loaders are thrown
  47.      * away to implement class reloading.
  48.      *
  49.      * <p>
  50.      * For more details see {@code PropertyUtilsBean}.
  51.      * </p>
  52.      *
  53.      * @see PropertyUtilsBean#clearDescriptors
  54.      */
  55.     public static void clearDescriptors() {
  56.         PropertyUtilsBean.getInstance().clearDescriptors();
  57.     }

  58.     /**
  59.      * <p>
  60.      * 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
  61.      * and setter methods might have been customized via {@code BeanInfo} classes).
  62.      * </p>
  63.      *
  64.      * <p>
  65.      * For more details see {@code PropertyUtilsBean}.
  66.      * </p>
  67.      *
  68.      * @param dest Destination bean whose properties are modified
  69.      * @param orig Origin bean whose properties are retrieved
  70.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  71.      * @throws IllegalArgumentException  if the {@code dest} or {@code orig} argument is null
  72.      * @throws InvocationTargetException if the property accessor method throws an exception
  73.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  74.      * @see PropertyUtilsBean#copyProperties
  75.      */
  76.     public static void copyProperties(final Object dest, final Object orig) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  77.         PropertyUtilsBean.getInstance().copyProperties(dest, orig);
  78.     }

  79.     /**
  80.      * <p>
  81.      * Return the entire set of properties for which the specified bean provides a read method.
  82.      * </p>
  83.      *
  84.      * <p>
  85.      * For more details see {@code PropertyUtilsBean}.
  86.      * </p>
  87.      *
  88.      * @param bean Bean whose properties are to be extracted
  89.      * @return The set of properties for the bean
  90.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  91.      * @throws IllegalArgumentException  if {@code bean} is null
  92.      * @throws InvocationTargetException if the property accessor method throws an exception
  93.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  94.      * @see PropertyUtilsBean#describe
  95.      */
  96.     public static Map<String, Object> describe(final Object bean) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  97.         return PropertyUtilsBean.getInstance().describe(bean);
  98.     }

  99.     /**
  100.      * <p>
  101.      * Return the value of the specified indexed property of the specified bean, with no type conversions.
  102.      * </p>
  103.      *
  104.      * <p>
  105.      * For more details see {@code PropertyUtilsBean}.
  106.      * </p>
  107.      *
  108.      * @param bean Bean whose property is to be extracted
  109.      * @param name {@code propertyname[index]} of the property value to be extracted
  110.      * @return the indexed property value
  111.      * @throws IndexOutOfBoundsException if the specified index is outside the valid range for the underlying property
  112.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  113.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  114.      * @throws InvocationTargetException if the property accessor method throws an exception
  115.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  116.      * @see PropertyUtilsBean#getIndexedProperty(Object,String)
  117.      */
  118.     public static Object getIndexedProperty(final Object bean, final String name)
  119.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  120.         return PropertyUtilsBean.getInstance().getIndexedProperty(bean, name);
  121.     }

  122.     /**
  123.      * <p>
  124.      * Return the value of the specified indexed property of the specified bean, with no type conversions.
  125.      * </p>
  126.      *
  127.      * <p>
  128.      * For more details see {@code PropertyUtilsBean}.
  129.      * </p>
  130.      *
  131.      * @param bean  Bean whose property is to be extracted
  132.      * @param name  Simple property name of the property value to be extracted
  133.      * @param index Index of the property value to be extracted
  134.      * @return the indexed property value
  135.      * @throws IndexOutOfBoundsException if the specified index is outside the valid range for the underlying property
  136.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  137.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  138.      * @throws InvocationTargetException if the property accessor method throws an exception
  139.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  140.      * @see PropertyUtilsBean#getIndexedProperty(Object,String, int)
  141.      */
  142.     public static Object getIndexedProperty(final Object bean, final String name, final int index)
  143.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  144.         return PropertyUtilsBean.getInstance().getIndexedProperty(bean, name, index);
  145.     }

  146.     /**
  147.      * <p>
  148.      * Return the value of the specified mapped property of the specified bean, with no type conversions.
  149.      * </p>
  150.      *
  151.      * <p>
  152.      * For more details see {@code PropertyUtilsBean}.
  153.      * </p>
  154.      *
  155.      * @param bean Bean whose property is to be extracted
  156.      * @param name {@code propertyname(key)} of the property value to be extracted
  157.      * @return the mapped property value
  158.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  159.      * @throws InvocationTargetException if the property accessor method throws an exception
  160.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  161.      * @see PropertyUtilsBean#getMappedProperty(Object,String)
  162.      */
  163.     public static Object getMappedProperty(final Object bean, final String name)
  164.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  165.         return PropertyUtilsBean.getInstance().getMappedProperty(bean, name);
  166.     }

  167.     /**
  168.      * <p>
  169.      * Return the value of the specified mapped property of the specified bean, with no type conversions.
  170.      * </p>
  171.      *
  172.      * <p>
  173.      * For more details see {@code PropertyUtilsBean}.
  174.      * </p>
  175.      *
  176.      * @param bean Bean whose property is to be extracted
  177.      * @param name Mapped property name of the property value to be extracted
  178.      * @param key  Key of the property value to be extracted
  179.      * @return the mapped property value
  180.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  181.      * @throws InvocationTargetException if the property accessor method throws an exception
  182.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  183.      * @see PropertyUtilsBean#getMappedProperty(Object,String, String)
  184.      */
  185.     public static Object getMappedProperty(final Object bean, final String name, final String key)
  186.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  187.         return PropertyUtilsBean.getInstance().getMappedProperty(bean, name, key);
  188.     }

  189.     /**
  190.      * <p>
  191.      * Return the mapped property descriptors for this bean class.
  192.      * </p>
  193.      *
  194.      * <p>
  195.      * For more details see {@code PropertyUtilsBean}.
  196.      * </p>
  197.      *
  198.      * @param beanClass Bean class to be introspected
  199.      * @return the mapped property descriptors
  200.      * @see PropertyUtilsBean#getMappedPropertyDescriptors(Class)
  201.      */
  202.     static Map<Class<?>, Map> getMappedPropertyDescriptors(final Class<?> beanClass) {
  203.         return PropertyUtilsBean.getInstance().getMappedPropertyDescriptors(beanClass);
  204.     }

  205.     /**
  206.      * <p>
  207.      * Return the value of the (possibly nested) property of the specified name, for the specified bean, with no type conversions.
  208.      * </p>
  209.      *
  210.      * <p>
  211.      * For more details see {@code PropertyUtilsBean}.
  212.      * </p>
  213.      *
  214.      * @param bean Bean whose property is to be extracted
  215.      * @param name Possibly nested name of the property to be extracted
  216.      * @return the nested property value
  217.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  218.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  219.      * @throws NestedNullException       if a nested reference to a property returns null
  220.      * @throws InvocationTargetException if the property accessor method throws an exception
  221.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  222.      * @see PropertyUtilsBean#getNestedProperty
  223.      */
  224.     public static Object getNestedProperty(final Object bean, final String name)
  225.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  226.         return PropertyUtilsBean.getInstance().getNestedProperty(bean, name);
  227.     }

  228.     /**
  229.      * <p>
  230.      * Return the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions.
  231.      * </p>
  232.      *
  233.      * <p>
  234.      * For more details see {@code PropertyUtilsBean}.
  235.      * </p>
  236.      *
  237.      * @param bean Bean whose property is to be extracted
  238.      * @param name Possibly indexed and/or nested name of the property to be extracted
  239.      * @return the property value
  240.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  241.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  242.      * @throws InvocationTargetException if the property accessor method throws an exception
  243.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  244.      * @see PropertyUtilsBean#getProperty
  245.      */
  246.     public static Object getProperty(final Object bean, final String name) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  247.         return PropertyUtilsBean.getInstance().getProperty(bean, name);
  248.     }

  249.     /**
  250.      * <p>
  251.      * Retrieve the property descriptor for the specified property of the specified bean, or return {@code null} if there is no such descriptor.
  252.      * </p>
  253.      *
  254.      * <p>
  255.      * For more details see {@code PropertyUtilsBean}.
  256.      * </p>
  257.      *
  258.      * @param bean Bean for which a property descriptor is requested
  259.      * @param name Possibly indexed and/or nested name of the property for which a property descriptor is requested
  260.      * @return the property descriptor
  261.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  262.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  263.      * @throws IllegalArgumentException  if a nested reference to a property returns null
  264.      * @throws InvocationTargetException if the property accessor method throws an exception
  265.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  266.      * @see PropertyUtilsBean#getPropertyDescriptor
  267.      */
  268.     public static PropertyDescriptor getPropertyDescriptor(final Object bean, final String name)
  269.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  270.         return PropertyUtilsBean.getInstance().getPropertyDescriptor(bean, name);
  271.     }

  272.     /**
  273.      * <p>
  274.      * Retrieve the property descriptors for the specified class, introspecting and caching them the first time a particular bean class is encountered.
  275.      * </p>
  276.      *
  277.      * <p>
  278.      * For more details see {@code PropertyUtilsBean}.
  279.      * </p>
  280.      *
  281.      * @param beanClass Bean class for which property descriptors are requested
  282.      * @return the property descriptors
  283.      * @throws IllegalArgumentException if {@code beanClass} is null
  284.      * @see PropertyUtilsBean#getPropertyDescriptors(Class)
  285.      */
  286.     public static PropertyDescriptor[] getPropertyDescriptors(final Class<?> beanClass) {
  287.         return PropertyUtilsBean.getInstance().getPropertyDescriptors(beanClass);
  288.     }

  289.     /**
  290.      * <p>
  291.      * Retrieve the property descriptors for the specified bean, 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 bean Bean for which property descriptors are requested
  299.      * @return the property descriptors
  300.      * @throws IllegalArgumentException if {@code bean} is null
  301.      * @see PropertyUtilsBean#getPropertyDescriptors(Object)
  302.      */
  303.     public static PropertyDescriptor[] getPropertyDescriptors(final Object bean) {
  304.         return PropertyUtilsBean.getInstance().getPropertyDescriptors(bean);
  305.     }

  306.     /**
  307.      * <p>
  308.      * Return the Java Class representing the property editor class that has been registered for this property (if any).
  309.      * </p>
  310.      *
  311.      * <p>
  312.      * For more details see {@code PropertyUtilsBean}.
  313.      * </p>
  314.      *
  315.      * @param bean Bean for which a property descriptor is requested
  316.      * @param name Possibly indexed and/or nested name of the property for which a property descriptor is requested
  317.      * @return the property editor class
  318.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  319.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  320.      * @throws IllegalArgumentException  if a nested reference to a property returns null
  321.      * @throws InvocationTargetException if the property accessor method throws an exception
  322.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  323.      * @see PropertyUtilsBean#getPropertyEditorClass(Object,String)
  324.      */
  325.     public static Class<?> getPropertyEditorClass(final Object bean, final String name)
  326.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  327.         return PropertyUtilsBean.getInstance().getPropertyEditorClass(bean, name);
  328.     }

  329.     /**
  330.      * <p>
  331.      * 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.
  332.      * </p>
  333.      *
  334.      * <p>
  335.      * For more details see {@code PropertyUtilsBean}.
  336.      * </p>
  337.      *
  338.      * @param bean Bean for which a property descriptor is requested
  339.      * @param name Possibly indexed and/or nested name of the property for which a property descriptor is requested
  340.      * @return The property type
  341.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  342.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  343.      * @throws IllegalArgumentException  if a nested reference to a property returns null
  344.      * @throws InvocationTargetException if the property accessor method throws an exception
  345.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  346.      * @see PropertyUtilsBean#getPropertyType(Object, String)
  347.      */
  348.     public static Class<?> getPropertyType(final Object bean, final String name)
  349.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  350.         return PropertyUtilsBean.getInstance().getPropertyType(bean, name);
  351.     }

  352.     /**
  353.      * <p>
  354.      * Return an accessible property getter method for this property, if there is one; otherwise return {@code null}.
  355.      * </p>
  356.      *
  357.      * <p>
  358.      * For more details see {@code PropertyUtilsBean}.
  359.      * </p>
  360.      *
  361.      * @param descriptor Property descriptor to return a getter for
  362.      * @return The read method
  363.      * @see PropertyUtilsBean#getReadMethod(PropertyDescriptor)
  364.      */
  365.     public static Method getReadMethod(final PropertyDescriptor descriptor) {
  366.         return PropertyUtilsBean.getInstance().getReadMethod(descriptor);
  367.     }

  368.     /**
  369.      * <p>
  370.      * Return the value of the specified simple property of the specified bean, with no type conversions.
  371.      * </p>
  372.      *
  373.      * <p>
  374.      * For more details see {@code PropertyUtilsBean}.
  375.      * </p>
  376.      *
  377.      * @param bean Bean whose property is to be extracted
  378.      * @param name Name of the property to be extracted
  379.      * @return The property value
  380.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  381.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  382.      * @throws IllegalArgumentException  if the property name is nested or indexed
  383.      * @throws InvocationTargetException if the property accessor method throws an exception
  384.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  385.      * @see PropertyUtilsBean#getSimpleProperty
  386.      */
  387.     public static Object getSimpleProperty(final Object bean, final String name)
  388.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  389.         return PropertyUtilsBean.getInstance().getSimpleProperty(bean, name);
  390.     }

  391.     /**
  392.      * <p>
  393.      * Return an accessible property setter method for this property, if there is one; otherwise return {@code null}.
  394.      * </p>
  395.      *
  396.      * <p>
  397.      * For more details see {@code PropertyUtilsBean}.
  398.      * </p>
  399.      *
  400.      * @param descriptor Property descriptor to return a setter for
  401.      * @return The write method
  402.      * @see PropertyUtilsBean#getWriteMethod(PropertyDescriptor)
  403.      */
  404.     public static Method getWriteMethod(final PropertyDescriptor descriptor) {
  405.         return PropertyUtilsBean.getInstance().getWriteMethod(descriptor);
  406.     }

  407.     /**
  408.      * <p>
  409.      * Return {@code true} if the specified property name identifies a readable property on the specified bean; otherwise, return {@code false}.
  410.      * </p>
  411.      *
  412.      * <p>
  413.      * For more details see {@code PropertyUtilsBean}.
  414.      * </p>
  415.      *
  416.      * @param bean Bean to be examined (may be a {@link DynaBean}
  417.      * @param name Property name to be evaluated
  418.      * @return {@code true} if the property is readable, otherwise {@code false}
  419.      * @throws IllegalArgumentException if {@code bean} or {@code name</code> is <code>null}
  420.      * @see PropertyUtilsBean#isReadable
  421.      * @since 1.6
  422.      */
  423.     public static boolean isReadable(final Object bean, final String name) {
  424.         return PropertyUtilsBean.getInstance().isReadable(bean, name);
  425.     }

  426.     /**
  427.      * <p>
  428.      * Return {@code true} if the specified property name identifies a writable property on the specified bean; otherwise, return {@code false}.
  429.      * </p>
  430.      *
  431.      * <p>
  432.      * For more details see {@code PropertyUtilsBean}.
  433.      * </p>
  434.      *
  435.      * @param bean Bean to be examined (may be a {@link DynaBean}
  436.      * @param name Property name to be evaluated
  437.      * @return {@code true} if the property is writable, otherwise {@code false}
  438.      * @throws IllegalArgumentException if {@code bean} or {@code name</code> is <code>null}
  439.      * @see PropertyUtilsBean#isWriteable
  440.      * @since 1.6
  441.      */
  442.     public static boolean isWriteable(final Object bean, final String name) {
  443.         return PropertyUtilsBean.getInstance().isWriteable(bean, name);
  444.     }

  445.     /**
  446.      * Removes the specified {@code BeanIntrospector}.
  447.      *
  448.      * @param introspector the {@code BeanIntrospector} to be removed
  449.      * @return <strong>true</strong> if the {@code BeanIntrospector} existed and could be removed, <strong>false</strong> otherwise
  450.      * @since 1.9
  451.      */
  452.     public static boolean removeBeanIntrospector(final BeanIntrospector introspector) {
  453.         return PropertyUtilsBean.getInstance().removeBeanIntrospector(introspector);
  454.     }

  455.     /**
  456.      * Resets the registered {@link BeanIntrospector} objects to the initial default state.
  457.      *
  458.      * @since 1.9
  459.      */
  460.     public static void resetBeanIntrospectors() {
  461.         PropertyUtilsBean.getInstance().resetBeanIntrospectors();
  462.     }

  463.     /**
  464.      * <p>
  465.      * Sets the value of the specified indexed property of the specified bean, with no type conversions.
  466.      * </p>
  467.      *
  468.      * <p>
  469.      * For more details see {@code PropertyUtilsBean}.
  470.      * </p>
  471.      *
  472.      * @param bean  Bean whose property is to be set
  473.      * @param name  Simple property name of the property value to be set
  474.      * @param index Index of the property value to be set
  475.      * @param value Value to which the indexed property element is to be set
  476.      * @throws IndexOutOfBoundsException if the specified index is outside the valid range for the underlying property
  477.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  478.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  479.      * @throws InvocationTargetException if the property accessor method throws an exception
  480.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  481.      * @see PropertyUtilsBean#setIndexedProperty(Object, String, Object)
  482.      */
  483.     public static void setIndexedProperty(final Object bean, final String name, final int index, final Object value)
  484.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  485.         PropertyUtilsBean.getInstance().setIndexedProperty(bean, name, index, value);
  486.     }

  487.     /**
  488.      * <p>
  489.      * Sets the value of the specified indexed property of the specified bean, with no type conversions.
  490.      * </p>
  491.      *
  492.      * <p>
  493.      * For more details see {@code PropertyUtilsBean}.
  494.      * </p>
  495.      *
  496.      * @param bean  Bean whose property is to be modified
  497.      * @param name  {@code propertyname[index]} of the property value to be modified
  498.      * @param value Value to which the specified property element should be set
  499.      * @throws IndexOutOfBoundsException if the specified index is outside the valid range for the underlying property
  500.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  501.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  502.      * @throws InvocationTargetException if the property accessor method throws an exception
  503.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  504.      * @see PropertyUtilsBean#setIndexedProperty(Object, String, Object)
  505.      */
  506.     public static void setIndexedProperty(final Object bean, final String name, final Object value)
  507.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  508.         PropertyUtilsBean.getInstance().setIndexedProperty(bean, name, value);
  509.     }

  510.     /**
  511.      * <p>
  512.      * Sets the value of the specified mapped property of the specified bean, with no type conversions.
  513.      * </p>
  514.      *
  515.      * <p>
  516.      * For more details see {@code PropertyUtilsBean}.
  517.      * </p>
  518.      *
  519.      * @param bean  Bean whose property is to be set
  520.      * @param name  {@code propertyname(key)} of the property value to be set
  521.      * @param value The property value to be set
  522.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  523.      * @throws InvocationTargetException if the property accessor method throws an exception
  524.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  525.      * @see PropertyUtilsBean#setMappedProperty(Object, String, Object)
  526.      */
  527.     public static void setMappedProperty(final Object bean, final String name, final Object value)
  528.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  529.         PropertyUtilsBean.getInstance().setMappedProperty(bean, name, value);
  530.     }

  531.     /**
  532.      * <p>
  533.      * Sets the value of the specified mapped property of the specified bean, with no type conversions.
  534.      * </p>
  535.      *
  536.      * <p>
  537.      * For more details see {@code PropertyUtilsBean}.
  538.      * </p>
  539.      *
  540.      * @param bean  Bean whose property is to be set
  541.      * @param name  Mapped property name of the property value to be set
  542.      * @param key   Key of the property value to be set
  543.      * @param value The property value to be set
  544.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  545.      * @throws InvocationTargetException if the property accessor method throws an exception
  546.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  547.      * @see PropertyUtilsBean#setMappedProperty(Object, String, String, Object)
  548.      */
  549.     public static void setMappedProperty(final Object bean, final String name, final String key, final Object value)
  550.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  551.         PropertyUtilsBean.getInstance().setMappedProperty(bean, name, key, value);
  552.     }

  553.     /**
  554.      * <p>
  555.      * Sets the value of the (possibly nested) property of the specified name, for the specified bean, with no type conversions.
  556.      * </p>
  557.      *
  558.      * <p>
  559.      * For more details see {@code PropertyUtilsBean}.
  560.      * </p>
  561.      *
  562.      * @param bean  Bean whose property is to be modified
  563.      * @param name  Possibly nested name of the property to be modified
  564.      * @param value Value to which the property is to be set
  565.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  566.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  567.      * @throws IllegalArgumentException  if a nested reference to a property returns null
  568.      * @throws InvocationTargetException if the property accessor method throws an exception
  569.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  570.      * @see PropertyUtilsBean#setNestedProperty
  571.      */
  572.     public static void setNestedProperty(final Object bean, final String name, final Object value)
  573.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  574.         PropertyUtilsBean.getInstance().setNestedProperty(bean, name, value);
  575.     }

  576.     /**
  577.      * <p>
  578.      * Set the value of the specified property of the specified bean, no matter which property reference format is used, with no type conversions.
  579.      * </p>
  580.      *
  581.      * <p>
  582.      * For more details see {@code PropertyUtilsBean}.
  583.      * </p>
  584.      *
  585.      * @param bean  Bean whose property is to be modified
  586.      * @param name  Possibly indexed and/or nested name of the property to be modified
  587.      * @param value Value to which this property is to be set
  588.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  589.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  590.      * @throws InvocationTargetException if the property accessor method throws an exception
  591.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  592.      * @see PropertyUtilsBean#setProperty
  593.      */
  594.     public static void setProperty(final Object bean, final String name, final Object value)
  595.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  596.         PropertyUtilsBean.getInstance().setProperty(bean, name, value);
  597.     }

  598.     /**
  599.      * <p>
  600.      * Set the value of the specified simple property of the specified bean, with no type conversions.
  601.      * </p>
  602.      *
  603.      * <p>
  604.      * For more details see {@code PropertyUtilsBean}.
  605.      * </p>
  606.      *
  607.      * @param bean  Bean whose property is to be modified
  608.      * @param name  Name of the property to be modified
  609.      * @param value Value to which the property should be set
  610.      * @throws IllegalAccessException    if the caller does not have access to the property accessor method
  611.      * @throws IllegalArgumentException  if {@code bean} or {@code name} is null
  612.      * @throws IllegalArgumentException  if the property name is nested or indexed
  613.      * @throws InvocationTargetException if the property accessor method throws an exception
  614.      * @throws NoSuchMethodException     if an accessor method for this property cannot be found
  615.      * @see PropertyUtilsBean#setSimpleProperty
  616.      */
  617.     public static void setSimpleProperty(final Object bean, final String name, final Object value)
  618.             throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  619.         PropertyUtilsBean.getInstance().setSimpleProperty(bean, name, value);
  620.     }

  621.     private PropertyUtils() {
  622.         // empty
  623.     }
  624. }