Trivial code cleanup
This commit is contained in:
parent
9b34c5119f
commit
f9680d4cda
2 changed files with 17 additions and 16 deletions
|
@ -2,6 +2,7 @@ package net.vhati.modmanager.core;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.vhati.modmanager.core.ModInfo;
|
||||
|
||||
|
@ -11,7 +12,7 @@ public class ModDB {
|
|||
// Accociates Forum thread urls with hashes of their forst post's content.
|
||||
private HashMap<String,String> threadHashMap = new HashMap<String,String>();
|
||||
|
||||
private ArrayList<ModInfo> catalog = new ArrayList<ModInfo>();
|
||||
private List<ModInfo> catalog = new ArrayList<ModInfo>();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -55,7 +56,7 @@ public class ModDB {
|
|||
/**
|
||||
* Returns the internal ArrayList of mod info.
|
||||
*/
|
||||
public ArrayList<ModInfo> getCatalog() {
|
||||
public List<ModInfo> getCatalog() {
|
||||
return catalog;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,28 +30,28 @@ public class JacksonGrognakCatalogReader {
|
|||
Exception exception = null;
|
||||
try {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
|
||||
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
|
||||
mapper.configure( JsonParser.Feature.ALLOW_SINGLE_QUOTES, true );
|
||||
mapper.setVisibility( PropertyAccessor.FIELD, Visibility.ANY );
|
||||
|
||||
JsonNode rootNode = mapper.readTree(jsonFile);
|
||||
JsonNode catalogsNode = rootNode.get("catalog_versions");
|
||||
JsonNode catalogNode = catalogsNode.get("1");
|
||||
JsonNode rootNode = mapper.readTree( jsonFile );
|
||||
JsonNode catalogsNode = rootNode.get( "catalog_versions" );
|
||||
JsonNode catalogNode = catalogsNode.get( "1" );
|
||||
|
||||
for ( JsonNode infoNode : catalogNode ) {
|
||||
String threadURL = infoNode.get("url").textValue();
|
||||
String threadHash = infoNode.get("thread_hash").textValue();
|
||||
String threadURL = infoNode.get( "url" ).textValue();
|
||||
String threadHash = infoNode.get( "thread_hash" ).textValue();
|
||||
if ( !threadURL.equals("???") && !threadHash.equals("???") )
|
||||
modDB.putThreadHash( threadURL, threadHash );
|
||||
|
||||
JsonNode versionsNode = infoNode.get("versions");
|
||||
JsonNode versionsNode = infoNode.get( "versions" );
|
||||
for ( JsonNode versionNode : versionsNode ) {
|
||||
ModInfo modInfo = new ModInfo();
|
||||
modInfo.setTitle( infoNode.get("title").textValue() );
|
||||
modInfo.setAuthor( infoNode.get("author").textValue() );
|
||||
modInfo.setURL( infoNode.get("url").textValue() );
|
||||
modInfo.setDescription( infoNode.get("desc").textValue() );
|
||||
modInfo.setFileHash( versionNode.get("hash").textValue() );
|
||||
modInfo.setVersion( versionNode.get("version").textValue() );
|
||||
modInfo.setTitle( infoNode.get( "title" ).textValue() );
|
||||
modInfo.setAuthor( infoNode.get( "author" ).textValue() );
|
||||
modInfo.setURL( infoNode.get( "url" ).textValue() );
|
||||
modInfo.setDescription( infoNode.get( "desc" ).textValue() );
|
||||
modInfo.setFileHash( versionNode.get( "hash" ).textValue() );
|
||||
modInfo.setVersion( versionNode.get( "version" ).textValue() );
|
||||
modDB.addMod( modInfo );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue