feat: characterConfig now has a HashMap for values
This commit is contained in:
parent
9a9fe4ae97
commit
fa6207e47d
@ -1,8 +1,34 @@
|
||||
package uulm.teamname.marvelous.gamelibrary.json.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* POJO describing the CharacterConfig as defined by the standard document.
|
||||
*/
|
||||
public class CharacterConfig {
|
||||
public CharacterProperties[] characters;
|
||||
|
||||
@JsonIgnore private Map<String, CharacterProperties> propertyMap;
|
||||
@JsonIgnore private Map<String, CharacterProperties> unmodifiablePropertyMap;
|
||||
|
||||
/**
|
||||
* @return a unmodifiable {@link Map}<{@link String}, {@link CharacterProperties}> containing all properties.
|
||||
* If not yet existent, initialize the Map
|
||||
*/
|
||||
public Map<String, CharacterProperties> getMap() {
|
||||
// lazy initialization
|
||||
if (propertyMap == null) {
|
||||
propertyMap = new HashMap<>();
|
||||
for (CharacterProperties property: characters) {
|
||||
propertyMap.put(property.name, property);
|
||||
}
|
||||
unmodifiablePropertyMap = Collections.unmodifiableMap(propertyMap);
|
||||
}
|
||||
|
||||
return unmodifiablePropertyMap;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user