GenuineSounds

LinkedProperties

Jun 21st, 2012
277
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. package ltd.genuine.util;
  2.  
  3. import java.util.Collections;
  4. import java.util.Enumeration;
  5. import java.util.LinkedHashSet;
  6. import java.util.Properties;
  7.  
  8. /**
  9.  * LinkedProperties retains the put order (field order) of the Properties input,
  10.  * the output of the properties file is the exact same as in the source fields order.
  11.  * <p>
  12.  * Also has the added benefit of keeping the order the same as the files order after
  13.  * the config is written and then edited. Players can now keep track of modifications,
  14.  * and make changes that are much more permanent.
  15.  */
  16. public class LinkedProperties extends Properties {
  17.  
  18.     private final LinkedHashSet<Object> keys = new LinkedHashSet<Object>();
  19.  
  20.     public Enumeration<Object> keys() {
  21.         return Collections.<Object> enumeration(keys);
  22.     }
  23.  
  24.     public Object put(Object key, Object value) {
  25.         keys.add(key);
  26.         return super.put(key, value);
  27.     }
  28. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment