001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.bean;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import javax.servlet.http.HttpServletRequest;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     */
024    public class BeanPropertiesUtil {
025    
026            public static void copyProperties(Object source, Object target) {
027                    getBeanProperties().copyProperties(source, target);
028            }
029    
030            public static void copyProperties(
031                    Object source, Object target, Class<?> editable) {
032    
033                    getBeanProperties().copyProperties(source, target, editable);
034            }
035    
036            public static void copyProperties(
037                    Object source, Object target, String[] ignoreProperties) {
038    
039                    getBeanProperties().copyProperties(source, target, ignoreProperties);
040            }
041    
042            public static <T> T deepCopyProperties(Object source) throws Exception {
043                    return getBeanProperties().deepCopyProperties(source);
044            }
045    
046            public static BeanProperties getBeanProperties() {
047                    PortalRuntimePermission.checkGetBeanProperty(BeanPropertiesUtil.class);
048    
049                    return _beanProperties;
050            }
051    
052            public static boolean getBoolean(Object bean, String param) {
053                    return getBeanProperties().getBoolean(bean, param);
054            }
055    
056            public static boolean getBoolean(
057                    Object bean, String param, boolean defaultValue) {
058    
059                    return getBeanProperties().getBoolean(bean, param, defaultValue);
060            }
061    
062            public static boolean getBooleanSilent(Object bean, String param) {
063                    return getBeanProperties().getBooleanSilent(bean, param);
064            }
065    
066            public static boolean getBooleanSilent(
067                    Object bean, String param, boolean defaultValue) {
068    
069                    return getBeanProperties().getBooleanSilent(bean, param, defaultValue);
070            }
071    
072            public static byte getByte(Object bean, String param) {
073                    return getBeanProperties().getByte(bean, param);
074            }
075    
076            public static byte getByte(Object bean, String param, byte defaultValue) {
077                    return getBeanProperties().getByte(bean, param, defaultValue);
078            }
079    
080            public static byte getByteSilent(Object bean, String param) {
081                    return getBeanProperties().getByteSilent(bean, param);
082            }
083    
084            public static byte getByteSilent(
085                    Object bean, String param, byte defaultValue) {
086    
087                    return getBeanProperties().getByteSilent(bean, param, defaultValue);
088            }
089    
090            public static double getDouble(Object bean, String param) {
091                    return getBeanProperties().getDouble(bean, param);
092            }
093    
094            public static double getDouble(
095                    Object bean, String param, double defaultValue) {
096    
097                    return getBeanProperties().getDouble(bean, param, defaultValue);
098            }
099    
100            public static double getDoubleSilent(Object bean, String param) {
101                    return getBeanProperties().getDoubleSilent(bean, param);
102            }
103    
104            public static double getDoubleSilent(
105                    Object bean, String param, double defaultValue) {
106    
107                    return getBeanProperties().getDoubleSilent(bean, param, defaultValue);
108            }
109    
110            public static float getFloat(Object bean, String param) {
111                    return getBeanProperties().getFloat(bean, param);
112            }
113    
114            public static float getFloat(
115                    Object bean, String param, float defaultValue) {
116    
117                    return getBeanProperties().getFloat(bean, param, defaultValue);
118            }
119    
120            public static float getFloatSilent(Object bean, String param) {
121                    return getBeanProperties().getFloatSilent(bean, param);
122            }
123    
124            public static float getFloatSilent(
125                    Object bean, String param, float defaultValue) {
126    
127                    return getBeanProperties().getFloatSilent(bean, param, defaultValue);
128            }
129    
130            public static int getInteger(Object bean, String param) {
131                    return getBeanProperties().getInteger(bean, param);
132            }
133    
134            public static int getInteger(Object bean, String param, int defaultValue) {
135                    return getBeanProperties().getInteger(bean, param, defaultValue);
136            }
137    
138            public static int getIntegerSilent(Object bean, String param) {
139                    return getBeanProperties().getIntegerSilent(bean, param);
140            }
141    
142            public static int getIntegerSilent(
143                    Object bean, String param, int defaultValue) {
144    
145                    return getBeanProperties().getIntegerSilent(bean, param, defaultValue);
146            }
147    
148            public static long getLong(Object bean, String param) {
149                    return getBeanProperties().getLong(bean, param);
150            }
151    
152            public static long getLong(Object bean, String param, long defaultValue) {
153                    return getBeanProperties().getLong(bean, param, defaultValue);
154            }
155    
156            public static long getLongSilent(Object bean, String param) {
157                    return getBeanProperties().getLongSilent(bean, param);
158            }
159    
160            public static long getLongSilent(
161                    Object bean, String param, long defaultValue) {
162    
163                    return getBeanProperties().getLongSilent(bean, param, defaultValue);
164            }
165    
166            public static Object getObject(Object bean, String param) {
167                    return getBeanProperties().getObject(bean, param);
168            }
169    
170            public static Object getObject(
171                    Object bean, String param, Object defaultValue) {
172    
173                    return getBeanProperties().getObject(bean, param, defaultValue);
174            }
175    
176            public static Object getObjectSilent(Object bean, String param) {
177                    return getBeanProperties().getObjectSilent(bean, param);
178            }
179    
180            public static Object getObjectSilent(
181                    Object bean, String param, Object defaultValue) {
182    
183                    return getBeanProperties().getObjectSilent(bean, param, defaultValue);
184            }
185    
186            public static Class<?> getObjectType(Object bean, String param) {
187                    return getBeanProperties().getObjectType(bean, param);
188            }
189    
190            public static Class<?> getObjectType(
191                    Object bean, String param, Class<?> defaultValue) {
192    
193                    return getBeanProperties().getObjectType(bean, param, defaultValue);
194            }
195    
196            public static Class<?> getObjectTypeSilent(Object bean, String param) {
197                    return getBeanProperties().getObjectType(bean, param);
198            }
199    
200            public static Class<?> getObjectTypeSilent(
201                    Object bean, String param, Class<?> defaultValue) {
202    
203                    return getBeanProperties().getObjectType(bean, param, defaultValue);
204            }
205    
206            public static short getShort(Object bean, String param) {
207                    return getBeanProperties().getShort(bean, param);
208            }
209    
210            public static short getShort(
211                    Object bean, String param, short defaultValue) {
212    
213                    return getBeanProperties().getShort(bean, param, defaultValue);
214            }
215    
216            public static short getShortSilent(Object bean, String param) {
217                    return getBeanProperties().getShortSilent(bean, param);
218            }
219    
220            public static short getShortSilent(
221                    Object bean, String param, short defaultValue) {
222    
223                    return getBeanProperties().getShortSilent(bean, param, defaultValue);
224            }
225    
226            public static String getString(Object bean, String param) {
227                    return getBeanProperties().getString(bean, param);
228            }
229    
230            public static String getString(
231                    Object bean, String param, String defaultValue) {
232    
233                    return getBeanProperties().getString(bean, param, defaultValue);
234            }
235    
236            public static String getStringSilent(Object bean, String param) {
237                    return getBeanProperties().getStringSilent(bean, param);
238            }
239    
240            public static String getStringSilent(
241                    Object bean, String param, String defaultValue) {
242    
243                    return getBeanProperties().getStringSilent(bean, param, defaultValue);
244            }
245    
246            public static void setProperties(Object bean, HttpServletRequest request) {
247                    getBeanProperties().setProperties(bean, request);
248            }
249    
250            public static void setProperty(Object bean, String param, Object value) {
251                    getBeanProperties().setProperty(bean, param, value);
252            }
253    
254            public static void setPropertySilent(
255                    Object bean, String param, Object value) {
256    
257                    getBeanProperties().setPropertySilent(bean, param, value);
258            }
259    
260            public void setBeanProperties(BeanProperties beanProperties) {
261                    PortalRuntimePermission.checkSetBeanProperty(getClass());
262    
263                    _beanProperties = beanProperties;
264            }
265    
266            private static BeanProperties _beanProperties;
267    
268    }