Soo, there is a guy I know wtill working on one of my old projects. It was a unicorn project for that customer, since it was deployed on time (well, 2 weeks late) and "it actually worked!" when deployed.
It weighs in at about 1.5 MLOC, so it's fairly hefty. There are some fairly complex business rules to it. and it handles graphs of stuff.
The whole thing is (or rather used to be) written in JavaEE, using JAX-RS and all that fancy stuff for marshalling XML from REST resources.
Apparently, the new Indian consultant team that have taken over and found that it was too complex, and are rewriting it in SpringBoot, using none of that strange magic marshalling/serializing.
These same indians told me when they started that recursive is too hard, and they don't want to learn.
They said the same about the then new Java Streams API.
public class StoreJsonParser {
public static final String NAME = "StoreJsonParser";
@Autowired
@Qualifier(StoreOrderConfiguration.NAME)
private StoreOrderConfiguration configuration;
/**
* parse response from store to fetch the item name
*
* @param storeResponse
* @param itemNumber
* @return itemData
*/
public ItemData retrieveItemResponse(String storeResponse, final String itemNumber) {
JsonParser parser = JsonParserFactory.getJsonParser();
Map<String, Object> map = parser.parseMap(storeResponse);
ItemData itemData = new ItemData();
itemData.setItemNumber(itemNumber);
for (Map.Entry<String, Object> entry : map.entrySet()) {
if ("content" == entry.getKey()) {
Object content = entry.getValue();
List<Object> ja = (List<Object>) entry.getValue();
Object jb = ja.get(0);
Map<String, Object> jc = (Map<String, Object>) jb;
for (Map.Entry<String, Object> entry1 : jc.entrySet()) {
if ("objects" == entry1.getKey()) {
Object content1 = entry.getValue();
List<Object> ja1 = (List<Object>) entry.getValue();
Object jb1 = ja1.get(0);
Map<String, Object> jc1 = (Map<String, Object>) jb1;
for (Map.Entry<String, Object> entry2 : jc1.entrySet()) {
if ("objects" == entry2.getKey()) {
Object content2 = entry2.getValue();
List<Object> ja2 = (List<Object>) entry2.getValue();
Object jb2 = ja2.get(5);
Map<String, Object> jc2 = (Map<String, Object>) jb2;
for (Map.Entry<String, Object> entry3 : jc2.entrySet()) {
if ("type" == entry3.getKey()) {
if ("item_full_name".equalsIgnoreCase(entry3.getValue().toString())) {
continue;
} else {
break;
}
}
if ("values" == entry3.getKey()) {
List<Object> ja3 = (List<Object>) entry3.getValue();
Object jb3 = ja3.get(0);
Map<String, Object> jc3 = (Map<String, Object>) jb3;
for (Map.Entry<String, Object> entry4 : jc3.entrySet()) {
if ("value" == entry4.getKey()) {
itemData.setPartName(entry4.getValue().toString());
}
}
}
}
}
}
}
}
}
}
return itemData;
}
}
Just from memory I can say that this code is broken, and will fail edge cases. But, fuck if it doesn't feel good that I bowed out of that gig when those idiots joined. But apart from that, 5 nested for loops? For/ifs? I feel dirty just reading it.