[Bleeding] Cleaned up unsafe casts. Addresses BUKKIT-844

Removed internal collection leaks from PluginDescriptionFile
BREAKING: PluginDescriptionFile.getAuthors() now returns List instead of
ArrayList

Various places with unsafe generics, notably List<Object> getList() in
Configurations are now referenced as <?>. This is nonbreaking, but
sourcecode will need to be revised when compiled.
This commit is contained in:
Wesley Wolfe
2012-02-29 08:32:25 -06:00
committed by EvilSeph
parent 145be1538d
commit 7db0e50da7
14 changed files with 174 additions and 183 deletions

View File

@@ -42,16 +42,15 @@ public class YamlConfiguration extends FileConfiguration {
return header + dump;
}
@SuppressWarnings("unchecked")
@Override
public void loadFromString(String contents) throws InvalidConfigurationException {
if (contents == null) {
throw new IllegalArgumentException("Contents cannot be null");
}
Map<Object, Object> input;
Map<?, ?> input;
try {
input = (Map<Object, Object>) yaml.load(contents);
input = (Map<?, ?>) yaml.load(contents);
} catch (YAMLException e) {
throw new InvalidConfigurationException(e);
} catch (ClassCastException e) {
@@ -68,14 +67,13 @@ public class YamlConfiguration extends FileConfiguration {
}
}
@SuppressWarnings("unchecked")
protected void convertMapsToSections(Map<Object, Object> input, ConfigurationSection section) {
for (Map.Entry<Object, Object> entry : input.entrySet()) {
protected void convertMapsToSections(Map<?, ?> input, ConfigurationSection section) {
for (Map.Entry<?, ?> entry : input.entrySet()) {
String key = entry.getKey().toString();
Object value = entry.getValue();
if (value instanceof Map<?, ?>) {
convertMapsToSections((Map<Object, Object>) value, section.createSection(key));
if (value instanceof Map) {
convertMapsToSections((Map<?, ?>) value, section.createSection(key));
} else {
section.set(key, value);
}