|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ObjectUtils.java | 0% | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* Joey and its relative products are published under the terms
|
|
3 |
* of the Apache Software License.
|
|
4 |
*/
|
|
5 |
package org.asyrinx.brownie.core.lang;
|
|
6 |
|
|
7 |
import org.apache.commons.beanutils.PropertyUtils;
|
|
8 |
|
|
9 |
/**
|
|
10 |
* @author Akima
|
|
11 |
*/
|
|
12 |
public final class ObjectUtils extends org.apache.commons.lang.ObjectUtils { |
|
13 |
|
|
14 |
/**
|
|
15 |
* 両方ともnullならfalse 両方ともnull以外ならfalse どちらかだけがnullならtrue
|
|
16 |
*/
|
|
17 | 0 |
static public boolean eitherIsNull(Object obj1, Object obj2) { |
18 | 0 |
if ((obj1 == null) && (obj2 == null)) |
19 | 0 |
return false; |
20 | 0 |
if ((obj1 != null) && (obj2 != null)) |
21 | 0 |
return false; |
22 | 0 |
return true; |
23 |
} |
|
24 |
|
|
25 |
/**
|
|
26 |
* PropertyUtilsクラス(reflection)を使用してプロパティの 文字列表現を取得します。
|
|
27 |
*/
|
|
28 | 0 |
public static String describeProperties(Object bean) { |
29 | 0 |
if (bean == null) |
30 | 0 |
return ""; |
31 | 0 |
try {
|
32 | 0 |
return String.valueOf(PropertyUtils.describe(bean));
|
33 |
} catch (Exception e) {
|
|
34 | 0 |
return ""; |
35 |
} |
|
36 |
} |
|
37 |
|
|
38 |
/**
|
|
39 |
* PropertyUtilsクラス(reflection)を使用してプロパティの 文字列表現を含む、オブジェクトの情報を文字列として取得します。
|
|
40 |
*/
|
|
41 | 0 |
public static String toString(Object bean) { |
42 | 0 |
if (bean == null) |
43 | 0 |
return ""; |
44 | 0 |
StringBuffer result = new StringBuffer();
|
45 | 0 |
result.append(bean.getClass().getName()); |
46 | 0 |
result.append("@");
|
47 | 0 |
result.append(bean.hashCode()); |
48 | 0 |
result.append(" ");
|
49 | 0 |
try {
|
50 | 0 |
result.append(String.valueOf(PropertyUtils.describe(bean))); |
51 |
} catch (Exception e) {
|
|
52 |
//ignore intensionally
|
|
53 |
} |
|
54 | 0 |
return result.toString();
|
55 |
} |
|
56 |
} |
|