File tree 2 files changed +43
-0
lines changed
main/java/org/springframework/data/gemfire/util
test/java/org/springframework/data/gemfire/util
2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 68
68
@ SuppressWarnings ("unused" )
69
69
public abstract class SpringUtils {
70
70
71
+ /**
72
+ * Determines whether all the {@link Object} values in the array are {@literal non-null}
73
+ *
74
+ * @param values array of {@link Object Objects} to evaluate.
75
+ * @return a boolean value indicating whether all of the {@link Object} values
76
+ * in the array are {@literal non-null}.
77
+ */
78
+ public static boolean areNotNull (Object ... values ) {
79
+
80
+ if (values != null ) {
81
+ for (Object value : values ) {
82
+ if (value == null ) {
83
+ return false ;
84
+ }
85
+ }
86
+ }
87
+
88
+ return true ;
89
+ }
90
+
71
91
/**
72
92
* Determines whether a given bean registered in the {@link BeanFactory Spring container} matches by
73
93
* both {@link String name} and {@link Class type}.
Original file line number Diff line number Diff line change @@ -77,6 +77,29 @@ public class SpringUtilsUnitTests {
77
77
@ Mock
78
78
private BeanDefinition mockBeanDefinition ;
79
79
80
+ @ Test
81
+ public void areNotNullIsNullSafe () {
82
+ assertThat (SpringUtils .areNotNull ((Object []) null )).isTrue ();
83
+ }
84
+
85
+ @ Test
86
+ public void areNotNullWithAllNullValuesReturnsFalse () {
87
+ assertThat (SpringUtils .areNotNull (null , null , null )).isFalse ();
88
+ }
89
+
90
+ @ Test
91
+ public void areNotNullWithNoNullValuesReturnsTrue () {
92
+ assertThat (SpringUtils .areNotNull (1 , 2 , 3 )).isTrue ();
93
+ }
94
+
95
+ @ Test
96
+ public void areNotNullWithOneNullValueIsFalse () {
97
+
98
+ assertThat (SpringUtils .areNotNull (null , 2 , 3 )).isFalse ();
99
+ assertThat (SpringUtils .areNotNull (1 , null , 3 )).isFalse ();
100
+ assertThat (SpringUtils .areNotNull (1 , 2 , null )).isFalse ();
101
+ }
102
+
80
103
@ Test
81
104
public void isMatchingBeanReturnsTrue () {
82
105
You can’t perform that action at this time.
0 commit comments