66import java .math .BigDecimal ;
77import java .nio .file .Files ;
88import java .nio .file .Path ;
9+ import java .util .ArrayList ;
10+ import java .util .List ;
911import java .util .concurrent .CompletableFuture ;
1012import java .util .concurrent .ExecutionException ;
1113
1214public class Param {
1315 private String name ;
14- private CompletableFuture <String > value ;
15- private Config config = Config .defaults ();
16+ private CompletableFuture <List <String >> value ;
1617
1718 public Param (String name , String value ) {
1819 this .name = name .toLowerCase ();
19- this .value = CompletableFuture .completedFuture (value );
20+ List <String > valueList = new ArrayList ();
21+ valueList .add (value );
22+ this .value = CompletableFuture .completedFuture (valueList );
2023 }
2124
2225 public Param (String name , int value ) {
@@ -50,28 +53,27 @@ public Param(String name, Path value, Config config) throws IOException {
5053
5154 public Param (String name , ConversionResult value ) throws ExecutionException , InterruptedException {
5255 this (name , value , 0 );
56+ this .value = value .urls ();
5357 }
5458
5559 public Param (String name , ConversionResult value , int fileIndex ) throws ExecutionException , InterruptedException {
5660 this (name , "" );
57- this .value = value .getFile (fileIndex ).thenApplyAsync (f -> f .
58- getUrl ());
61+ this .value = value .getFile (fileIndex ).thenApplyAsync (f -> {
62+ List <String > valueList = new ArrayList ();
63+ valueList .add (f .getUrl ());
64+ return valueList ;
65+ });
5966 }
6067
6168 public String getName () {
6269 return name ;
6370 }
6471
65- public Param setConfig (Config config ) {
66- this .config = config ;
67- return this ;
68- }
69-
70- public String getValue () throws ExecutionException , InterruptedException {
72+ public List <String > getValue () throws ExecutionException , InterruptedException {
7173 return this .value .get ();
7274 }
7375
74- private static CompletableFuture <String > upload (byte [] data , String fileName , MediaType fileContentType , Config config ) {
76+ private static CompletableFuture <List < String > > upload (byte [] data , String fileName , MediaType fileContentType , Config config ) {
7577 return CompletableFuture .supplyAsync (() -> {
7678 Request request = new Request .Builder ()
7779 .url (Http .getUrlBuilder (config ).addPathSegment ("upload" )
@@ -80,7 +82,9 @@ private static CompletableFuture<String> upload(byte[] data, String fileName, Me
8082 .post (RequestBody .create (fileContentType , data ))
8183 .build ();
8284 try {
83- return Http .getClient ().newCall (request ).execute ().body ().string ();
85+ List <String > valueList = new ArrayList <String >();
86+ valueList .add (Http .getClient ().newCall (request ).execute ().body ().string ());
87+ return valueList ;
8488 } catch (IOException e ) {
8589 throw new RuntimeException (e );
8690 }
0 commit comments