mirror of
https://github.com/bbasaran/kessel-run.git
synced 2026-10-16 11:29:18 -04:00
Add equipment to pojo generation.
This commit is contained in:
@@ -1,16 +1,22 @@
|
|||||||
package org.misoenergy.hackday.kessel_run.service;
|
package org.misoenergy.hackday.kessel_run.service;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.misoenergy.hackday.kessel_run.model.StarWarsPojo;
|
import org.misoenergy.hackday.kessel_run.model.StarWarsPojo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import reactor.util.function.Tuple2;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -64,20 +70,28 @@ public class StarWarsApiService {
|
|||||||
|
|
||||||
String packageName = "org.misoenergy.hackday.kessel_run.model";
|
String packageName = "org.misoenergy.hackday.kessel_run.model";
|
||||||
|
|
||||||
|
Map<String, File> pojoList = new HashMap<>();
|
||||||
|
|
||||||
String jsonPath = "src/main/resources/";
|
String jsonPath = "src/main/resources/";
|
||||||
File inputJson = new File(jsonPath + "starwarsjsonresponse.json");
|
File classJson = new File(jsonPath + "starwarsjsonresponse.json");
|
||||||
|
File equipmentJson = new File(jsonPath + "equipment.json");
|
||||||
|
String classClassName = "StarWarsPojo";
|
||||||
|
String equipmentClassName = "EquipmentPojo";
|
||||||
|
|
||||||
|
pojoList.put(classClassName, classJson);
|
||||||
|
pojoList.put(equipmentClassName, equipmentJson);
|
||||||
|
|
||||||
String outputPath = "src/main/resources/";
|
String outputPath = "src/main/resources/";
|
||||||
File outputJavaClassDirectory = new File(outputPath);
|
File outputJavaClassDirectory = new File(outputPath);
|
||||||
|
|
||||||
String javaClassName = "StarWarsPojo";
|
|
||||||
|
|
||||||
|
pojoList.forEach((className, pojoJson) -> {
|
||||||
try {
|
try {
|
||||||
jsonToPojoConcerterService.convertJsonToJavaClass(inputJson.toURI()
|
jsonToPojoConcerterService.convertJsonToJavaClass(pojoJson.toURI()
|
||||||
.toURL(), outputJavaClassDirectory, packageName, javaClassName ) ;
|
.toURL(), outputJavaClassDirectory, packageName, className);
|
||||||
|
} catch (Exception e) {
|
||||||
}catch (Exception ex) {
|
log.info("exception : {}", e.getMessage());
|
||||||
log.info("exception : {}" , ex.getMessage() );
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user