mmb.engine.MutableResourceBundle Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multimachinebuilder Show documentation
Show all versions of multimachinebuilder Show documentation
Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world.
THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<
The newest version!
/**
*
*/
package mmb.engine;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
import com.google.common.collect.Iterators;
import mmb.NN;
import mmb.Nil;
import monniasza.collects.Collects;
/**
* A resource bundle whose contents may change
* @author oskar
*/
public class MutableResourceBundle extends ResourceBundle {
/** Creates an empty mutable resource bundle*/
public MutableResourceBundle() {}
/**
* Creates a mutable resource bundle with contents of the input bundle
* @param rb source bundle
*/
public MutableResourceBundle(ResourceBundle rb) {add(rb);}
/** The data array used by this bundle */
public final Map map = new HashMap<>();
/**
* Adds contents of the resource bundle to this bundle
* @param rb source bundle
*/
public void add(ResourceBundle rb) {
for(String key: Collects.iter(rb.getKeys())) {
map.put(key, rb.getObject(key));
}
}
@Override
protected Object handleGetObject(@Nil String key) {
return map.get(key);
}
@SuppressWarnings("null")
@Override
public Enumeration getKeys() {
return Iterators.asEnumeration(map.keySet().iterator());
}
@Override
public boolean containsKey(@Nil String key) {
return map.containsKey(key);
}
@Override
protected Set handleKeySet() {
return map.keySet();
}
@Override
public @NN Set keySet() {
return map.keySet();
}
}