1717
1818import io .jooby .Err ;
1919import io .jooby .FileUpload ;
20+ import io .jooby .Formdata ;
21+ import io .jooby .Multipart ;
2022import io .jooby .Value ;
2123
2224import javax .annotation .Nonnull ;
3032import java .util .TreeMap ;
3133import java .util .function .BiConsumer ;
3234
33- public class HashValue implements Value {
35+ public class HashValue implements Value , Multipart {
3436 private static final Map <String , Value > EMPTY = Collections .emptyMap ();
3537
3638 private Map <String , Value > hash = EMPTY ;
3739
3840 private final String name ;
3941
42+ private String objectType ;
43+
4044 public HashValue (String name ) {
4145 this .name = name ;
4246 }
@@ -49,11 +53,11 @@ protected HashValue() {
4953 return name ;
5054 }
5155
52- public HashValue put (String path , String value ) {
56+ public Formdata put (String path , String value ) {
5357 return put (path , Collections .singletonList (value ));
5458 }
5559
56- public HashValue put (String path , FileUpload upload ) {
60+ public HashValue put (String path , Value upload ) {
5761 put (path , (name , scope ) -> {
5862 Value existing = scope .get (name );
5963 if (existing == null ) {
@@ -180,7 +184,12 @@ public int size() {
180184
181185 @ Override public String value () {
182186 String name = name ();
183- throw new Err .TypeMismatch (name == null ? getClass ().getSimpleName () : name , String .class );
187+ throw new Err .TypeMismatch (name == null ? objectType : name , String .class );
188+ }
189+
190+ public HashValue setObjectType (String type ) {
191+ this .objectType = type ;
192+ return this ;
184193 }
185194
186195 @ Override public Iterator <Value > iterator () {
0 commit comments