af174fd8f805e694d91de2fd491138a444ddf9ce
[externalapi/nbi.git] / src / main / java / org / onap / nbi / commons / BeanUtils.java
1 /**
2  *
3  *     Copyright (c) 2017 Orange.  All rights reserved.
4  *
5  *     Licensed under the Apache License, Version 2.0 (the "License");
6  *     you may not use this file except in compliance with the License.
7  *     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.onap.nbi.commons;
18
19 import org.apache.commons.beanutils.PropertyUtilsBean;
20
21 /**
22  *
23  */
24 public class BeanUtils {
25
26     private static final PropertyUtilsBean PUB = new PropertyUtilsBean();
27
28     /**
29      *
30      * @param bean
31      * @param name
32      * @return
33      */
34     public static Object getNestedProperty(Object bean, String name) {
35         try {
36             return BeanUtils.PUB.getNestedProperty(bean, name);
37         } catch (Exception e) {
38             return null;
39         }
40     }
41
42     /**
43      *
44      * @param bean
45      * @param name
46      * @param value
47      */
48     public static void setNestedProperty(Object bean, String name, Object value) {
49         try {
50             BeanUtils.PUB.setNestedProperty(bean, name, value);
51         } catch (Exception ex) {
52         }
53     }
54
55 }