File tree 2 files changed +25
-4
lines changed
main/java/dev/openfeature/sdk
test/java/dev/openfeature/sdk
2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -125,14 +125,27 @@ public boolean isStructure() {
125
125
}
126
126
127
127
/**
128
- * Check if this Value represents a List.
128
+ * Check if this Value represents a List of Values .
129
129
*
130
130
* @return boolean
131
131
*/
132
132
public boolean isList () {
133
- return this .innerObject instanceof List
134
- && (((List ) this .innerObject ).isEmpty ()
135
- || ((List ) this .innerObject ).get (0 ) instanceof Value );
133
+ if (!(this .innerObject instanceof List )) {
134
+ return false ;
135
+ }
136
+
137
+ List <?> list = (List <?>) this .innerObject ;
138
+ if (list .isEmpty ()) {
139
+ return true ;
140
+ }
141
+
142
+ for (Object obj : list ) {
143
+ if (!(obj instanceof Value )) {
144
+ return false ;
145
+ }
146
+ }
147
+
148
+ return true ;
136
149
}
137
150
138
151
/**
Original file line number Diff line number Diff line change @@ -134,4 +134,12 @@ class Something {}
134
134
fail ("Unexpected exception occurred." , e );
135
135
}
136
136
}
137
+
138
+ @ Test public void valueConstructorValidateListInternals () {
139
+ List <Object > list = new ArrayList <>();
140
+ list .add (new Value ("item" ));
141
+ list .add ("item" );
142
+
143
+ assertThrows (InstantiationException .class , ()-> new Value (list ));
144
+ }
137
145
}
You can’t perform that action at this time.
0 commit comments