File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
main/java/dev/openfeature/sdk
test/java/dev/openfeature/sdk Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -125,14 +125,27 @@ public boolean isStructure() {
125125 }
126126
127127 /**
128- * Check if this Value represents a List.
128+ * Check if this Value represents a List of Values .
129129 *
130130 * @return boolean
131131 */
132132 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 ;
136149 }
137150
138151 /**
Original file line number Diff line number Diff line change @@ -134,4 +134,12 @@ class Something {}
134134 fail ("Unexpected exception occurred." , e );
135135 }
136136 }
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+ }
137145}
You can’t perform that action at this time.
0 commit comments