Skip to content

Commit 079fffe

Browse files
committed
Added ObjectUtils.objectWithDefault() function
1 parent a63fe9c commit 079fffe

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fj-core/src/main/java/org/fugerit/java/core/util/ObjectUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
public class ObjectUtils {
44

5+
public static <T> T objectWithDefault( T value, T def ) {
6+
T res = def;
7+
if ( value != null ) {
8+
res = value;
9+
}
10+
return res;
11+
}
12+
513
public static String toDefaultString( Object obj, PropertyEntry ...entries ) {
614
StringBuilder b = new StringBuilder();
715
if ( obj != null ) {

0 commit comments

Comments
 (0)