From 7fb7128756b812e3963f32d3b61c642115fb1257 Mon Sep 17 00:00:00 2001 From: MightyPork Date: Sat, 26 Jul 2014 19:46:12 +0200 Subject: [PATCH] Big refactoring and rewrite of PropertyManager (using store backned) --- src/mightypork/utils/MapSort.java | 9 +- src/mightypork/utils/Support.java | 4 +- src/mightypork/utils/annotations/Alias.java | 7 +- .../{files => }/config/SimpleConfig.java | 2 +- .../utils/config/propmgr/Property.java | 121 ++++++++++++ .../propmgr}/PropertyManager.java | 176 ++++-------------- .../utils/config/propmgr/PropertyStore.java | 79 ++++++++ .../propmgr/properties/BooleanProperty.java | 30 +++ .../propmgr/properties/DoubleProperty.java | 30 +++ .../propmgr/properties/IntegerProperty.java | 30 +++ .../propmgr/properties/StringProperty.java | 30 +++ .../config/propmgr/store/PropertyFile.java | 119 ++++++++++++ .../propmgr/store}/SortedProperties.java | 32 ++-- src/mightypork/utils/eventbus/EventBus.java | 9 +- .../utils/eventbus/EventChannel.java | 3 +- .../utils/eventbus/clients/ClientList.java | 3 +- .../utils/eventbus/events/UpdateEvent.java | 3 +- .../eventbus/events/flags/DelayedEvent.java | 7 +- .../eventbus/events/flags/DirectEvent.java | 7 +- .../eventbus/events/flags/NotLoggedEvent.java | 7 +- .../events/flags/SingleReceiverEvent.java | 7 +- .../exceptions/CorruptDataException.java | 12 +- .../exceptions/IllegalValueException.java | 12 +- .../exceptions/KeyAlreadyExistsException.java | 12 +- .../utils/files/FileSuffixFilter.java | 3 +- src/mightypork/utils/files/FileTreeDiff.java | 12 +- src/mightypork/utils/files/FileUtils.java | 26 +-- .../utils/files/config/Property.java | 71 ------- .../utils/files/zip/ZipBuilder.java | 7 +- src/mightypork/utils/files/zip/ZipUtils.java | 18 +- src/mightypork/utils/ion/Ion.java | 17 +- src/mightypork/utils/ion/IonInput.java | 17 +- src/mightypork/utils/ion/IonMapWrapper.java | 6 +- src/mightypork/utils/ion/IonOutput.java | 16 +- .../utils/ion/IonSequenceWrapper.java | 6 +- src/mightypork/utils/ion/IonizerBinary.java | 9 +- src/mightypork/utils/ion/IonizerBundled.java | 6 +- .../utils/logging/writers/ArchivingLog.java | 10 +- .../utils/logging/writers/SimpleLog.java | 3 +- src/mightypork/utils/math/Calc.java | 3 +- src/mightypork/utils/math/Polar.java | 6 +- src/mightypork/utils/math/Range.java | 9 +- src/mightypork/utils/math/algo/Coord.java | 9 +- src/mightypork/utils/math/algo/Move.java | 5 +- .../math/algo/pathfinding/PathFinder.java | 4 +- .../algo/pathfinding/PathFinderProxy.java | 3 +- .../utils/math/animation/Animator.java | 12 +- .../utils/math/animation/AnimatorBounce.java | 12 +- .../utils/math/animation/AnimatorRewind.java | 12 +- .../utils/math/animation/Easing.java | 6 +- .../utils/math/animation/NumAnimated.java | 18 +- .../utils/math/animation/NumAnimatedDeg.java | 9 +- .../utils/math/animation/NumAnimatedRad.java | 9 +- .../utils/math/animation/VectAnimated.java | 6 +- .../utils/math/color/ColorAlphaAdjuster.java | 3 +- src/mightypork/utils/math/color/ColorHsb.java | 3 +- src/mightypork/utils/math/color/ColorRgb.java | 3 +- src/mightypork/utils/math/color/pal/RGB.java | 1 - .../utils/math/constraints/num/NumConst.java | 6 +- .../num/caching/AbstractNumCache.java | 3 +- .../constraints/num/caching/NumCache.java | 3 +- .../constraints/num/caching/NumDigest.java | 3 +- .../math/constraints/num/proxy/NumProxy.java | 6 +- .../math/constraints/num/var/NumVar.java | 6 +- .../utils/math/constraints/rect/Rect.java | 1 - .../math/constraints/rect/RectConst.java | 9 +- .../constraints/rect/builders/TiledRect.java | 3 +- .../rect/caching/AbstractRectCache.java | 3 +- .../constraints/rect/caching/RectCache.java | 3 +- .../constraints/rect/caching/RectDigest.java | 6 +- .../constraints/rect/proxy/RectProxy.java | 6 +- .../rect/proxy/RectVectAdapter.java | 3 +- .../math/constraints/rect/var/RectVar.java | 3 +- .../math/constraints/vect/VectConst.java | 6 +- .../vect/caching/AbstractVectCache.java | 3 +- .../constraints/vect/caching/VectCache.java | 3 +- .../constraints/vect/caching/VectDigest.java | 3 +- .../vect/proxy/VectNumAdapter.java | 6 +- .../constraints/vect/proxy/VectProxy.java | 6 +- .../math/constraints/vect/var/VectVar.java | 3 +- src/mightypork/utils/math/noise/NoiseGen.java | 6 +- .../math/noise/PerlinNoiseGenerator.java | 11 +- .../utils/math/timing/Profiler.java | 1 + .../utils/math/timing/TaskRepeater.java | 3 +- .../utils/math/timing/TimerDelta.java | 3 +- .../utils/math/timing/TimerFps.java | 3 +- .../utils/string/StringWrapper.java | 3 +- .../string/validation/CharFilterRegex.java | 3 +- .../validation/CharFilterWhitelist.java | 3 +- src/mightypork/utils/struct/Mutable.java | 3 +- src/mightypork/utils/struct/Pair.java | 3 +- src/mightypork/utils/struct/Triad.java | 3 +- 92 files changed, 652 insertions(+), 598 deletions(-) rename src/mightypork/utils/{files => }/config/SimpleConfig.java (99%) create mode 100644 src/mightypork/utils/config/propmgr/Property.java rename src/mightypork/utils/{files/config => config/propmgr}/PropertyManager.java (51%) create mode 100644 src/mightypork/utils/config/propmgr/PropertyStore.java create mode 100644 src/mightypork/utils/config/propmgr/properties/BooleanProperty.java create mode 100644 src/mightypork/utils/config/propmgr/properties/DoubleProperty.java create mode 100644 src/mightypork/utils/config/propmgr/properties/IntegerProperty.java create mode 100644 src/mightypork/utils/config/propmgr/properties/StringProperty.java create mode 100644 src/mightypork/utils/config/propmgr/store/PropertyFile.java rename src/mightypork/utils/{files/config => config/propmgr/store}/SortedProperties.java (89%) delete mode 100644 src/mightypork/utils/files/config/Property.java diff --git a/src/mightypork/utils/MapSort.java b/src/mightypork/utils/MapSort.java index 9edfe66..ca94859 100644 --- a/src/mightypork/utils/MapSort.java +++ b/src/mightypork/utils/MapSort.java @@ -1,12 +1,7 @@ package mightypork.utils; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; @@ -49,7 +44,7 @@ public class MapSort { public int compare(K arg0, K arg1) { return ((Comparable) arg0).compareTo(arg1); - } + } }; } diff --git a/src/mightypork/utils/Support.java b/src/mightypork/utils/Support.java index 20d5904..8bf4b92 100644 --- a/src/mightypork/utils/Support.java +++ b/src/mightypork/utils/Support.java @@ -153,7 +153,6 @@ public final class Support { return new IterableEnumerationWrapper<>(enumeration); } - /** * Helper class for iterationg over an {@link Enumeration} * @@ -168,8 +167,7 @@ public final class Support { /** * @param enumeration the iterated enumeration */ - public IterableEnumerationWrapper(Enumeration enumeration) - { + public IterableEnumerationWrapper(Enumeration enumeration) { this.enumeration = enumeration; } diff --git a/src/mightypork/utils/annotations/Alias.java b/src/mightypork/utils/annotations/Alias.java index 48a7750..7ffd1ad 100644 --- a/src/mightypork/utils/annotations/Alias.java +++ b/src/mightypork/utils/annotations/Alias.java @@ -1,12 +1,7 @@ package mightypork.utils.annotations; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** diff --git a/src/mightypork/utils/files/config/SimpleConfig.java b/src/mightypork/utils/config/SimpleConfig.java similarity index 99% rename from src/mightypork/utils/files/config/SimpleConfig.java rename to src/mightypork/utils/config/SimpleConfig.java index 531d9ac..f79282f 100644 --- a/src/mightypork/utils/files/config/SimpleConfig.java +++ b/src/mightypork/utils/config/SimpleConfig.java @@ -1,4 +1,4 @@ -package mightypork.utils.files.config; +package mightypork.utils.config; import java.io.File; diff --git a/src/mightypork/utils/config/propmgr/Property.java b/src/mightypork/utils/config/propmgr/Property.java new file mode 100644 index 0000000..20b1c59 --- /dev/null +++ b/src/mightypork/utils/config/propmgr/Property.java @@ -0,0 +1,121 @@ +package mightypork.utils.config.propmgr; + + +import mightypork.utils.Convert; +import mightypork.utils.annotations.Stub; + + +/** + * Property entry for the {@link PropertyManager}.
+ * Extending this class can be used to add custom property types that are not + * supported by default. + * + * @author Ondřej Hruška (MightyPork) + * @param property type + */ +public abstract class Property { + + protected final String comment; + protected final String key; + + protected T value; + protected final T defaultValue; + + + /** + * Create a property without comment + * + * @param key key in the config file + * @param defaultValue defualt property value (used as fallback when + * parsing) + */ + public Property(String key, T defaultValue) { + this(key, defaultValue, null); + } + + + /** + * Create a property with a comment + * + * @param key key in the config file + * @param defaultValue defualt property value (used as fallback when + * parsing) + * @param comment optional property comment included above the property in + * the config file. Can be null. + */ + public Property(String key, T defaultValue, String comment) { + this.comment = comment; + this.key = key; + this.value = defaultValue; + this.defaultValue = defaultValue; + } + + + /** + * Parse a string representation of the value into this property. If the + * value cannot be decoded, use the default value instead. + * + * @param string property value as string + */ + public abstract void fromString(String string); + + + /** + * Get property value as string (compatible with `fromString()) + * + * @return property value as string + */ + @Override + @Stub + public String toString() + { + return Convert.toString(value, Convert.toString(defaultValue)); + } + + + /** + * Get the current property value + * + * @return the value + */ + public final T getValue() + { + return value; + } + + + /** + * Set property value.
+ * Uses Object to allow setValue(Object) method in {@link PropertyManager} + * + * @param value value to set. + * @throws ClassCastException in case of incompatible type. + */ + @SuppressWarnings("unchecked") + public final void setValue(Object value) + { + this.value = (T) value; + } + + + /** + * Get property comment. + * + * @return the comment text (can be null if no comment is defined) + */ + public final String getComment() + { + return comment; + } + + + /** + * Get property key + * + * @return property key + */ + public final String getKey() + { + return key; + } +} diff --git a/src/mightypork/utils/files/config/PropertyManager.java b/src/mightypork/utils/config/propmgr/PropertyManager.java similarity index 51% rename from src/mightypork/utils/files/config/PropertyManager.java rename to src/mightypork/utils/config/propmgr/PropertyManager.java index f3af075..3d566ad 100644 --- a/src/mightypork/utils/files/config/PropertyManager.java +++ b/src/mightypork/utils/config/propmgr/PropertyManager.java @@ -1,15 +1,16 @@ -package mightypork.utils.files.config; +package mightypork.utils.config.propmgr; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Map.Entry; import java.util.TreeMap; import mightypork.utils.Convert; +import mightypork.utils.config.propmgr.properties.BooleanProperty; +import mightypork.utils.config.propmgr.properties.DoubleProperty; +import mightypork.utils.config.propmgr.properties.IntegerProperty; +import mightypork.utils.config.propmgr.properties.StringProperty; import mightypork.utils.logging.Log; @@ -20,131 +21,46 @@ import mightypork.utils.logging.Log; */ public class PropertyManager { - private class BooleanProperty extends Property { - - public BooleanProperty(String key, Boolean defaultValue, String comment) - { - super(key, defaultValue, comment); - } - - - @Override - public Boolean decode(String string, Boolean defval) - { - return Convert.toBoolean(string, defval); - } - } - - private class IntegerProperty extends Property { - - public IntegerProperty(String key, Integer defaultValue, String comment) - { - super(key, defaultValue, comment); - } - - - @Override - public Integer decode(String string, Integer defval) - { - return Convert.toInteger(string, defval); - } - } - - private class DoubleProperty extends Property { - - public DoubleProperty(String key, Double defaultValue, String comment) - { - super(key, defaultValue, comment); - } - - - @Override - public Double decode(String string, Double defval) - { - return Convert.toDouble(string, defval); - } - } - - private class StringProperty extends Property { - - public StringProperty(String key, String defaultValue, String comment) - { - super(key, defaultValue, comment); - } - - - @Override - public String decode(String string, String defval) - { - return Convert.toString(string, defval); - } - } - - /** put newline before entry comments */ - private boolean cfgNewlineBeforeComments = true; - - /** Put newline between sections. */ - private boolean cfgSeparateSections = true; - - private final File file; - private String fileComment = ""; - - private final TreeMap> entries; - private final TreeMap renameTable; - private SortedProperties props = new SortedProperties(); + private final TreeMap> entries = new TreeMap<>(); + private final TreeMap renameTable = new TreeMap<>(); + private PropertyStore props; /** * Create property manager from file path and an initial comment. * - * @param file file with the props - * @param comment the initial comment. Use \n in it if you want. + * @param props a property store implementation backing this property + * manager */ - public PropertyManager(File file, String comment) - { - this.file = file; - this.entries = new TreeMap<>(); - this.renameTable = new TreeMap<>(); - this.fileComment = comment; + public PropertyManager(PropertyStore props) { + this.props = props; } /** - * Load, fix and write to file. + * Load from file */ public void load() { - if (!file.getParentFile().mkdirs()) { - if (!file.getParentFile().exists()) { - throw new RuntimeException("Cound not create config file."); - } - } - - try(FileInputStream fis = new FileInputStream(file)) { - props.load(fis); - } catch (final IOException e) { - props = new SortedProperties(); - } - - props.cfgBlankRowBetweenSections = cfgSeparateSections; - props.cfgBlankRowBeforeComment = cfgNewlineBeforeComments; + props.load(); - // rename keys + // rename keys (useful if keys change but value is to be kept) for (final Entry entry : renameTable.entrySet()) { - final String pr = props.getProperty(entry.getKey()); + final String value = props.getProperty(entry.getKey()); - if (pr == null) continue; + if (value == null) continue; - props.remove(entry.getKey()); - props.setProperty(entry.getValue(), pr); + final String oldKey = entry.getKey(); + final String newKey = entry.getValue(); + + props.removeProperty(oldKey); + props.setProperty(newKey, value, entries.get(newKey).getComment()); } for (final Property entry : entries.values()) { - entry.parse(props.getProperty(entry.getKey())); + entry.fromString(props.getProperty(entry.getKey())); } - - renameTable.clear(); } @@ -157,48 +73,23 @@ public class PropertyManager { for (final Property entry : entries.values()) { keyList.add(entry.getKey()); - if (entry.getComment() != null) { - props.setKeyComment(entry.getKey(), entry.getComment()); - } - - props.setProperty(entry.getKey(), entry.toString()); + props.setProperty(entry.getKey(), entry.toString(), entry.getComment()); } // removed unused props - for (final String propname : props.keySet().toArray(new String[props.size()])) { - if (!keyList.contains(propname)) { - props.remove(propname); + for (final String key : props.keys()) { + if (!keyList.contains(key)) { + props.removeProperty(key); } } - try(FileOutputStream fos = new FileOutputStream(file)) { - - props.store(fos, fileComment); - } + props.save(); } catch (final IOException ioe) { ioe.printStackTrace(); } } - /** - * @param newlineBeforeComments put newline before comments - */ - public void cfgNewlineBeforeComments(boolean newlineBeforeComments) - { - this.cfgNewlineBeforeComments = newlineBeforeComments; - } - - - /** - * @param separateSections do separate sections by newline - */ - public void cfgSeparateSections(boolean separateSections) - { - this.cfgSeparateSections = separateSections; - } - - /** * Get a property entry (rarely used) * @@ -334,9 +225,9 @@ public class PropertyManager { /** - * Add a range property + * Add a generic property (can be used with custom property types) * - * @param prop property to put + * @param prop property to add */ public void putProperty(Property prop) { @@ -369,9 +260,14 @@ public class PropertyManager { } + /** + * Set heading comment of the property store. + * + * @param fileComment comment text (can be multi-line) + */ public void setFileComment(String fileComment) { - this.fileComment = fileComment; + props.setComment(fileComment); } } diff --git a/src/mightypork/utils/config/propmgr/PropertyStore.java b/src/mightypork/utils/config/propmgr/PropertyStore.java new file mode 100644 index 0000000..be881af --- /dev/null +++ b/src/mightypork/utils/config/propmgr/PropertyStore.java @@ -0,0 +1,79 @@ +package mightypork.utils.config.propmgr; + + +import java.io.IOException; +import java.util.Collection; + + +/** + * Interface for a property store (used by {@link PropertyManager}).
+ * Due to this abstraction, different kind of property storage can be used, not + * only a file. + * + * @author Ondřej Hruška (MightyPork) + */ +public interface PropertyStore { + + /** + * Set a header comment + * + * @param comment the comment text (can be multi-line) + */ + void setComment(String comment); + + + /** + * Load properties from the file / store. If the file does not exist or is + * inaccessible, nothing is loaded. + */ + void load(); + + + /** + * Save properties to the file / store. + * + * @throws IOException if the file cannot be created or written. + */ + void save() throws IOException; + + + /** + * Get a property value + * + * @param key property key + * @return value retrieved from the file, or null if none found. + */ + String getProperty(String key); + + + /** + * Set a property value + * + * @param key property key + * @param value property value to set + * @param comment property comment. Can be null. + */ + void setProperty(String key, String value, String comment); + + + /** + * Remove a property from the list. + * + * @param key property key to remove + */ + void removeProperty(String key); + + + /** + * Clear the property list + */ + void clear(); + + + /** + * Get keys collection (can be used for iterating) + * + * @return keys collection + */ + public Collection keys(); +} diff --git a/src/mightypork/utils/config/propmgr/properties/BooleanProperty.java b/src/mightypork/utils/config/propmgr/properties/BooleanProperty.java new file mode 100644 index 0000000..15bf83b --- /dev/null +++ b/src/mightypork/utils/config/propmgr/properties/BooleanProperty.java @@ -0,0 +1,30 @@ +package mightypork.utils.config.propmgr.properties; + + +import mightypork.utils.Convert; +import mightypork.utils.config.propmgr.Property; + + +/** + * Boolean property + * + * @author Ondřej Hruška (MightyPork) + */ +public class BooleanProperty extends Property { + + public BooleanProperty(String key, Boolean defaultValue) { + super(key, defaultValue); + } + + + public BooleanProperty(String key, Boolean defaultValue, String comment) { + super(key, defaultValue, comment); + } + + + @Override + public void fromString(String string) + { + setValue(Convert.toBoolean(string, defaultValue)); + } +} diff --git a/src/mightypork/utils/config/propmgr/properties/DoubleProperty.java b/src/mightypork/utils/config/propmgr/properties/DoubleProperty.java new file mode 100644 index 0000000..97f6d66 --- /dev/null +++ b/src/mightypork/utils/config/propmgr/properties/DoubleProperty.java @@ -0,0 +1,30 @@ +package mightypork.utils.config.propmgr.properties; + + +import mightypork.utils.Convert; +import mightypork.utils.config.propmgr.Property; + + +/** + * Double property + * + * @author Ondřej Hruška (MightyPork) + */ +public class DoubleProperty extends Property { + + public DoubleProperty(String key, Double defaultValue) { + super(key, defaultValue); + } + + + public DoubleProperty(String key, Double defaultValue, String comment) { + super(key, defaultValue, comment); + } + + + @Override + public void fromString(String string) + { + setValue(Convert.toDouble(string, defaultValue)); + } +} diff --git a/src/mightypork/utils/config/propmgr/properties/IntegerProperty.java b/src/mightypork/utils/config/propmgr/properties/IntegerProperty.java new file mode 100644 index 0000000..6ad0913 --- /dev/null +++ b/src/mightypork/utils/config/propmgr/properties/IntegerProperty.java @@ -0,0 +1,30 @@ +package mightypork.utils.config.propmgr.properties; + + +import mightypork.utils.Convert; +import mightypork.utils.config.propmgr.Property; + + +/** + * Integer property + * + * @author Ondřej Hruška (MightyPork) + */ +public class IntegerProperty extends Property { + + public IntegerProperty(String key, Integer defaultValue) { + super(key, defaultValue); + } + + + public IntegerProperty(String key, Integer defaultValue, String comment) { + super(key, defaultValue, comment); + } + + + @Override + public void fromString(String string) + { + setValue(Convert.toInteger(string, defaultValue)); + } +} diff --git a/src/mightypork/utils/config/propmgr/properties/StringProperty.java b/src/mightypork/utils/config/propmgr/properties/StringProperty.java new file mode 100644 index 0000000..6032ba1 --- /dev/null +++ b/src/mightypork/utils/config/propmgr/properties/StringProperty.java @@ -0,0 +1,30 @@ +package mightypork.utils.config.propmgr.properties; + + +import mightypork.utils.Convert; +import mightypork.utils.config.propmgr.Property; + + +/** + * String property + * + * @author Ondřej Hruška (MightyPork) + */ +public class StringProperty extends Property { + + public StringProperty(String key, String defaultValue) { + super(key, defaultValue); + } + + + public StringProperty(String key, String defaultValue, String comment) { + super(key, defaultValue, comment); + } + + + @Override + public void fromString(String string) + { + setValue(Convert.toString(string, defaultValue)); + } +} diff --git a/src/mightypork/utils/config/propmgr/store/PropertyFile.java b/src/mightypork/utils/config/propmgr/store/PropertyFile.java new file mode 100644 index 0000000..9bc8360 --- /dev/null +++ b/src/mightypork/utils/config/propmgr/store/PropertyFile.java @@ -0,0 +1,119 @@ +package mightypork.utils.config.propmgr.store; + + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Collection; + +import mightypork.utils.config.propmgr.PropertyStore; + + +/** + * File based implementation utilizing {@link java.util.Properties}, hacked to + * support UTF-8. + * + * @author Ondřej Hruška (MightyPork) + */ +public class PropertyFile implements PropertyStore { + + private String comment; + private File file; + private SortedProperties props; + + + public PropertyFile(File file) { + this.file = file; + this.comment = null; + this.props = new SortedProperties(); + } + + + public PropertyFile(File file, String comment) { + this.file = file; + this.comment = comment; + this.props = new SortedProperties(); + } + + + @Override + public void setComment(String comment) + { + this.comment = comment; + } + + + @Override + public void load() + { + if (!file.exists()) return; + + try (FileInputStream in = new FileInputStream(file)) { + props.load(in); + } catch (IOException e) { + // ignore + } + } + + + @Override + public void save() throws IOException + { + if (!file.getParentFile().mkdirs()) { + if (!file.getParentFile().exists()) { + throw new IOException("Cound not create config file."); + } + } + + try (FileOutputStream out = new FileOutputStream(file)) { + props.store(out, comment); + } + } + + + @Override + public String getProperty(String key) + { + return props.getProperty(key); + } + + + @Override + public void setProperty(String key, String value, String comment) + { + props.setProperty(key, value); + props.setKeyComment(key, comment); + } + + + @Override + public void removeProperty(String key) + { + props.remove(key); + } + + + @Override + public void clear() + { + props.clear(); + } + + + @SuppressWarnings("unchecked") + @Override + public Collection keys() + { + +// Set keys = new HashSet<>(); +// for (Object o : props.keySet()) { +// keys.add((String) o); +// } +// return keys; + + // we know it is strings. + return (Collection) (Collection) props.keySet(); + } + +} diff --git a/src/mightypork/utils/files/config/SortedProperties.java b/src/mightypork/utils/config/propmgr/store/SortedProperties.java similarity index 89% rename from src/mightypork/utils/files/config/SortedProperties.java rename to src/mightypork/utils/config/propmgr/store/SortedProperties.java index 124b526..bdd085a 100644 --- a/src/mightypork/utils/files/config/SortedProperties.java +++ b/src/mightypork/utils/config/propmgr/store/SortedProperties.java @@ -1,13 +1,7 @@ -package mightypork.utils.files.config; +package mightypork.utils.config.propmgr.store; -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; +import java.io.*; import java.util.Collections; import java.util.Enumeration; import java.util.Hashtable; @@ -16,20 +10,13 @@ import java.util.Vector; /** * Properties stored in file, alphabetically sorted.
- * Uses UTF-8 encoding and each property can have it's own comment. + * Uses UTF-8 encoding and each property can have it's own comment.
+ * FIXME The quality of this class is dubious. It would probably be a good idea + * to rewrite it without using {@link java.util.Properties} at all. * * @author Ondřej Hruška (MightyPork) */ -public class SortedProperties extends java.util.Properties { - - /** Option: put empty line before each comment. */ - public boolean cfgBlankRowBeforeComment = true; - - /** - * Option: Separate sections by newline
- * Section = string before first dot in key. - */ - public boolean cfgBlankRowBetweenSections = true; +class SortedProperties extends java.util.Properties { /** Comments for individual keys */ private final Hashtable keyComments = new Hashtable<>(); @@ -205,7 +192,8 @@ public class SortedProperties extends java.util.Properties { key = saveConvert(key, true, escUnicode); val = saveConvert(val, false, escUnicode); - if (cfgBlankRowBetweenSections && !lastSectionBeginning.equals(key.split("[.]")[0])) { + // separate sections + if (!lastSectionBeginning.equals(key.split("[.]")[0])) { if (!firstEntry) { bw.newLine(); bw.newLine(); @@ -223,7 +211,8 @@ public class SortedProperties extends java.util.Properties { final String[] cmlines = cm.split("\n"); - if (!wasNewLine && !firstEntry && cfgBlankRowBeforeComment) { + // newline before comments + if (!wasNewLine && !firstEntry) { bw.newLine(); } @@ -298,6 +287,7 @@ public class SortedProperties extends java.util.Properties { sb.append(c); } + // discard comments final String read = sb.toString().replaceAll("(#|;|//|--)[^\n]*\n", "\n"); final String inputString = escapifyStr(read); diff --git a/src/mightypork/utils/eventbus/EventBus.java b/src/mightypork/utils/eventbus/EventBus.java index 2970e69..53a5ca1 100644 --- a/src/mightypork/utils/eventbus/EventBus.java +++ b/src/mightypork/utils/eventbus/EventBus.java @@ -36,8 +36,7 @@ final public class EventBus implements Destroyable { private final BusEvent evt; - public DelayQueueEntry(double seconds, BusEvent event) - { + public DelayQueueEntry(double seconds, BusEvent event) { super(); this.due = System.currentTimeMillis() + (long) (seconds * 1000); this.evt = event; @@ -73,8 +72,7 @@ final public class EventBus implements Destroyable { public volatile boolean stopped = false; - public QueuePollingThread() - { + public QueuePollingThread() { super("Queue Polling Thread"); } @@ -135,8 +133,7 @@ final public class EventBus implements Destroyable { /** * Make a new bus and start it's queue thread. */ - public EventBus() - { + public EventBus() { busThread = new QueuePollingThread(); busThread.setDaemon(true); busThread.start(); diff --git a/src/mightypork/utils/eventbus/EventChannel.java b/src/mightypork/utils/eventbus/EventChannel.java index 784ab35..911615f 100644 --- a/src/mightypork/utils/eventbus/EventChannel.java +++ b/src/mightypork/utils/eventbus/EventChannel.java @@ -31,8 +31,7 @@ class EventChannel, CLIENT> { * @param eventClass event class * @param clientClass client class */ - public EventChannel(Class eventClass, Class clientClass) - { + public EventChannel(Class eventClass, Class clientClass) { if (eventClass == null || clientClass == null) { throw new NullPointerException("Null Event or Client class."); diff --git a/src/mightypork/utils/eventbus/clients/ClientList.java b/src/mightypork/utils/eventbus/clients/ClientList.java index 55c4a87..f0bdae5 100644 --- a/src/mightypork/utils/eventbus/clients/ClientList.java +++ b/src/mightypork/utils/eventbus/clients/ClientList.java @@ -12,8 +12,7 @@ import java.util.ArrayList; */ public class ClientList extends ArrayList { - public ClientList(Object... clients) - { + public ClientList(Object... clients) { for (final Object c : clients) { super.add(c); } diff --git a/src/mightypork/utils/eventbus/events/UpdateEvent.java b/src/mightypork/utils/eventbus/events/UpdateEvent.java index 7e8c8a3..d053f64 100644 --- a/src/mightypork/utils/eventbus/events/UpdateEvent.java +++ b/src/mightypork/utils/eventbus/events/UpdateEvent.java @@ -24,8 +24,7 @@ public class UpdateEvent extends BusEvent { /** * @param deltaTime time since last update (sec) */ - public UpdateEvent(double deltaTime) - { + public UpdateEvent(double deltaTime) { this.deltaTime = deltaTime; } diff --git a/src/mightypork/utils/eventbus/events/flags/DelayedEvent.java b/src/mightypork/utils/eventbus/events/flags/DelayedEvent.java index e6a3114..11bf9d0 100644 --- a/src/mightypork/utils/eventbus/events/flags/DelayedEvent.java +++ b/src/mightypork/utils/eventbus/events/flags/DelayedEvent.java @@ -1,12 +1,7 @@ package mightypork.utils.eventbus.events.flags; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** diff --git a/src/mightypork/utils/eventbus/events/flags/DirectEvent.java b/src/mightypork/utils/eventbus/events/flags/DirectEvent.java index 8ad9713..fdfd138 100644 --- a/src/mightypork/utils/eventbus/events/flags/DirectEvent.java +++ b/src/mightypork/utils/eventbus/events/flags/DirectEvent.java @@ -1,12 +1,7 @@ package mightypork.utils.eventbus.events.flags; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** diff --git a/src/mightypork/utils/eventbus/events/flags/NotLoggedEvent.java b/src/mightypork/utils/eventbus/events/flags/NotLoggedEvent.java index 291d1b8..aad9872 100644 --- a/src/mightypork/utils/eventbus/events/flags/NotLoggedEvent.java +++ b/src/mightypork/utils/eventbus/events/flags/NotLoggedEvent.java @@ -1,12 +1,7 @@ package mightypork.utils.eventbus.events.flags; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** diff --git a/src/mightypork/utils/eventbus/events/flags/SingleReceiverEvent.java b/src/mightypork/utils/eventbus/events/flags/SingleReceiverEvent.java index 1c15082..a166ef2 100644 --- a/src/mightypork/utils/eventbus/events/flags/SingleReceiverEvent.java +++ b/src/mightypork/utils/eventbus/events/flags/SingleReceiverEvent.java @@ -1,12 +1,7 @@ package mightypork.utils.eventbus.events.flags; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; +import java.lang.annotation.*; /** diff --git a/src/mightypork/utils/exceptions/CorruptDataException.java b/src/mightypork/utils/exceptions/CorruptDataException.java index db75243..9b43778 100644 --- a/src/mightypork/utils/exceptions/CorruptDataException.java +++ b/src/mightypork/utils/exceptions/CorruptDataException.java @@ -11,26 +11,22 @@ import java.io.IOException; */ public class CorruptDataException extends IOException { - public CorruptDataException() - { + public CorruptDataException() { super(); } - public CorruptDataException(String message, Throwable cause) - { + public CorruptDataException(String message, Throwable cause) { super(message, cause); } - public CorruptDataException(String message) - { + public CorruptDataException(String message) { super(message); } - public CorruptDataException(Throwable cause) - { + public CorruptDataException(Throwable cause) { super(cause); } diff --git a/src/mightypork/utils/exceptions/IllegalValueException.java b/src/mightypork/utils/exceptions/IllegalValueException.java index b2b8794..f7c1f48 100644 --- a/src/mightypork/utils/exceptions/IllegalValueException.java +++ b/src/mightypork/utils/exceptions/IllegalValueException.java @@ -9,25 +9,21 @@ package mightypork.utils.exceptions; */ public class IllegalValueException extends RuntimeException { - public IllegalValueException() - { + public IllegalValueException() { } - public IllegalValueException(String message) - { + public IllegalValueException(String message) { super(message); } - public IllegalValueException(Throwable cause) - { + public IllegalValueException(Throwable cause) { super(cause); } - public IllegalValueException(String message, Throwable cause) - { + public IllegalValueException(String message, Throwable cause) { super(message, cause); } diff --git a/src/mightypork/utils/exceptions/KeyAlreadyExistsException.java b/src/mightypork/utils/exceptions/KeyAlreadyExistsException.java index 5e0e31d..8e73c7f 100644 --- a/src/mightypork/utils/exceptions/KeyAlreadyExistsException.java +++ b/src/mightypork/utils/exceptions/KeyAlreadyExistsException.java @@ -8,26 +8,22 @@ package mightypork.utils.exceptions; */ public class KeyAlreadyExistsException extends RuntimeException { - public KeyAlreadyExistsException() - { + public KeyAlreadyExistsException() { super(); } - public KeyAlreadyExistsException(String message, Throwable cause) - { + public KeyAlreadyExistsException(String message, Throwable cause) { super(message, cause); } - public KeyAlreadyExistsException(String message) - { + public KeyAlreadyExistsException(String message) { super(message); } - public KeyAlreadyExistsException(Throwable cause) - { + public KeyAlreadyExistsException(Throwable cause) { super(cause); } diff --git a/src/mightypork/utils/files/FileSuffixFilter.java b/src/mightypork/utils/files/FileSuffixFilter.java index 94308e4..ee0f87c 100644 --- a/src/mightypork/utils/files/FileSuffixFilter.java +++ b/src/mightypork/utils/files/FileSuffixFilter.java @@ -21,8 +21,7 @@ public class FileSuffixFilter implements FileFilter { * * @param suffixes var-args allowed suffixes, case insensitive */ - public FileSuffixFilter(String... suffixes) - { + public FileSuffixFilter(String... suffixes) { this.suffixes = suffixes; } diff --git a/src/mightypork/utils/files/FileTreeDiff.java b/src/mightypork/utils/files/FileTreeDiff.java index dd909a0..6573e1d 100644 --- a/src/mightypork/utils/files/FileTreeDiff.java +++ b/src/mightypork/utils/files/FileTreeDiff.java @@ -72,11 +72,9 @@ public class FileTreeDiff { ck1.reset(); ck2.reset(); - try(FileInputStream in1 = new FileInputStream(pair.a); - FileInputStream in2 = new FileInputStream(pair.b)) { + try (FileInputStream in1 = new FileInputStream(pair.a); FileInputStream in2 = new FileInputStream(pair.b)) { - try(CheckedInputStream cin1 = new CheckedInputStream(in1, ck1); - CheckedInputStream cin2 = new CheckedInputStream(in2, ck2)) { + try (CheckedInputStream cin1 = new CheckedInputStream(in1, ck1); CheckedInputStream cin2 = new CheckedInputStream(in2, ck2)) { while (true) { final int read1 = cin1.read(BUFFER); @@ -130,8 +128,7 @@ public class FileTreeDiff { private class NotEqualException extends Exception { - public NotEqualException(String msg) - { + public NotEqualException(String msg) { super(msg); } @@ -143,8 +140,7 @@ public class FileTreeDiff { public T b; - public Tuple(T a, T b) - { + public Tuple(T a, T b) { this.a = a; this.b = b; } diff --git a/src/mightypork/utils/files/FileUtils.java b/src/mightypork/utils/files/FileUtils.java index b9810eb..024613e 100644 --- a/src/mightypork/utils/files/FileUtils.java +++ b/src/mightypork/utils/files/FileUtils.java @@ -1,19 +1,7 @@ package mightypork.utils.files; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileFilter; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; +import java.io.*; import java.util.ArrayList; import java.util.List; @@ -107,8 +95,7 @@ public class FileUtils { public static void copyFile(File source, File target) throws IOException { - try(InputStream in = new FileInputStream(source); - OutputStream out = new FileOutputStream(target)) { + try (InputStream in = new FileInputStream(source); OutputStream out = new FileOutputStream(target)) { copyStream(in, out); } @@ -173,7 +160,7 @@ public class FileUtils { */ public static String fileToString(File file) throws IOException { - try(FileInputStream fin = new FileInputStream(file)) { + try (FileInputStream fin = new FileInputStream(file)) { return streamToString(fin); } @@ -365,7 +352,7 @@ public class FileUtils { */ public static void stringToFile(File file, String text) throws IOException { - try(PrintStream out = new PrintStream(new FileOutputStream(file), false, "UTF-8")) { + try (PrintStream out = new PrintStream(new FileOutputStream(file), false, "UTF-8")) { out.print(text); @@ -413,8 +400,7 @@ public class FileUtils { */ public static void resourceToFile(String resname, File file) throws IOException { - try(InputStream in = FileUtils.getResource(resname); - OutputStream out = new FileOutputStream(file)) { + try (InputStream in = FileUtils.getResource(resname); OutputStream out = new FileOutputStream(file)) { FileUtils.copyStream(in, out); } @@ -431,7 +417,7 @@ public class FileUtils { */ public static String resourceToString(String resname) throws IOException { - try(InputStream in = FileUtils.getResource(resname)) { + try (InputStream in = FileUtils.getResource(resname)) { return streamToString(in); } } diff --git a/src/mightypork/utils/files/config/Property.java b/src/mightypork/utils/files/config/Property.java deleted file mode 100644 index d4ea4ea..0000000 --- a/src/mightypork/utils/files/config/Property.java +++ /dev/null @@ -1,71 +0,0 @@ -package mightypork.utils.files.config; - - -import mightypork.utils.Convert; - - -public abstract class Property { - - private final String comment; - private final String key; - - private T value; - private final T defaultValue; - - - public Property(String key, T defaultValue, String comment) - { - super(); - this.comment = comment; - this.key = key; - this.value = defaultValue; - this.defaultValue = defaultValue; - } - - - public final void parse(String string) - { - setValue(decode(string, defaultValue)); - } - - - public abstract T decode(String string, T defval); - - - public String encode(T value) - { - return Convert.toString(value, Convert.toString(defaultValue)); - } - - - @Override - public final String toString() - { - return encode(value); - } - - - public T getValue() - { - return value; - } - - - @SuppressWarnings("unchecked") - public void setValue(Object value) - { - this.value = (T) value; - } - - - public String getComment() - { - return comment; - } - - - public String getKey() - { - return key; - } -} diff --git a/src/mightypork/utils/files/zip/ZipBuilder.java b/src/mightypork/utils/files/zip/ZipBuilder.java index 334b8ae..a84caa1 100644 --- a/src/mightypork/utils/files/zip/ZipBuilder.java +++ b/src/mightypork/utils/files/zip/ZipBuilder.java @@ -29,8 +29,7 @@ public class ZipBuilder { * @param target target zip file * @throws IOException if the file is directory or cannot be created */ - public ZipBuilder(File target) throws IOException - { + public ZipBuilder(File target) throws IOException { if (!target.getParentFile().mkdirs()) throw new IOException("Could not create output directory."); @@ -76,7 +75,7 @@ public class ZipBuilder { out.putNextEntry(new ZipEntry(path)); - try(InputStream in = FileUtils.stringToStream(text)) { + try (InputStream in = FileUtils.stringToStream(text)) { FileUtils.copyStream(in, out); } } @@ -97,7 +96,7 @@ public class ZipBuilder { out.putNextEntry(new ZipEntry(path)); - try(InputStream in = FileUtils.getResource(resPath)) { + try (InputStream in = FileUtils.getResource(resPath)) { FileUtils.copyStream(in, out); } } diff --git a/src/mightypork/utils/files/zip/ZipUtils.java b/src/mightypork/utils/files/zip/ZipUtils.java index 9605ce5..d525123 100644 --- a/src/mightypork/utils/files/zip/ZipUtils.java +++ b/src/mightypork/utils/files/zip/ZipUtils.java @@ -1,12 +1,7 @@ package mightypork.utils.files.zip; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; @@ -39,7 +34,7 @@ public class ZipUtils { */ public static List extractZip(File file, File outputDir, StringFilter filter) throws IOException { - try(ZipFile zip = new ZipFile(file)) { + try (ZipFile zip = new ZipFile(file)) { return extractZip(zip, outputDir, filter); } } @@ -95,7 +90,7 @@ public class ZipUtils { */ public static List listZip(File zipFile) throws IOException { - try(ZipFile zip = new ZipFile(zipFile)) { + try (ZipFile zip = new ZipFile(zipFile)) { return listZip(zip); } } @@ -139,10 +134,7 @@ public class ZipUtils { { if (!destFile.getParentFile().mkdirs()) throw new IOException("Could not create output directory."); - try(InputStream in = zip.getInputStream(entry); - BufferedInputStream is = new BufferedInputStream(in); - FileOutputStream fos = new FileOutputStream(destFile); - BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER_SIZE)) { + try (InputStream in = zip.getInputStream(entry); BufferedInputStream is = new BufferedInputStream(in); FileOutputStream fos = new FileOutputStream(destFile); BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER_SIZE)) { FileUtils.copyStream(is, dest); } @@ -176,7 +168,7 @@ public class ZipUtils { public static boolean entryExists(File selectedFile, String string) { - try(ZipFile zf = new ZipFile(selectedFile)) { + try (ZipFile zf = new ZipFile(selectedFile)) { return zf.getEntry(string) != null; } catch (final IOException | RuntimeException e) { Log.w("Error reading zip.", e); diff --git a/src/mightypork/utils/ion/Ion.java b/src/mightypork/utils/ion/Ion.java index 3185604..c5184fb 100644 --- a/src/mightypork/utils/ion/Ion.java +++ b/src/mightypork/utils/ion/Ion.java @@ -1,12 +1,7 @@ package mightypork.utils.ion; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; +import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -85,7 +80,6 @@ public class Ion { /** Array of arbitrary objects */ public static final int OBJECT_ARRAY = 26; - /** Ionizables */ private static Map> markToClass = new HashMap<>(); private static Map, Integer> classToMark = new HashMap<>(); @@ -243,7 +237,7 @@ public class Ion { */ public static T fromFile(File file) throws IOException { - try(InputStream in = new FileInputStream(file)) { + try (InputStream in = new FileInputStream(file)) { return fromStream(in); } } @@ -263,7 +257,7 @@ public class Ion { */ public static void toFile(File file, Object obj) throws IOException { - try(OutputStream out = new FileOutputStream(file)) { + try (OutputStream out = new FileOutputStream(file)) { toStream(out, obj); @@ -279,7 +273,7 @@ public class Ion { */ public static T fromStream(InputStream in) throws IOException { - try(final IonInput inp = new IonInput(in)) { + try (final IonInput inp = new IonInput(in)) { return (T) inp.readObject(); } } @@ -290,7 +284,7 @@ public class Ion { */ public static void toStream(OutputStream out, Object obj) throws IOException { - try(IonOutput iout = new IonOutput(out)) { + try (IonOutput iout = new IonOutput(out)) { iout.writeObject(obj); } } @@ -496,7 +490,6 @@ public class Ion { { final List toRemove = new ArrayList<>(); - // remove direct for (final Integer mark : markToClass.keySet()) { if (!isMarkReserved(mark)) { diff --git a/src/mightypork/utils/ion/IonInput.java b/src/mightypork/utils/ion/IonInput.java index 6c506c7..33a0092 100644 --- a/src/mightypork/utils/ion/IonInput.java +++ b/src/mightypork/utils/ion/IonInput.java @@ -1,14 +1,7 @@ package mightypork.utils.ion; -import java.io.Closeable; -import java.io.DataInput; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; +import java.io.*; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -29,14 +22,12 @@ public class IonInput implements Closeable { @SuppressWarnings("resource") - public IonInput(File inFile) throws FileNotFoundException - { + public IonInput(File inFile) throws FileNotFoundException { this(new FileInputStream(inFile)); } - public IonInput(InputStream in) - { + public IonInput(InputStream in) { this.stream = in; this.in = new DataInputStream(in); } @@ -300,7 +291,6 @@ public class IonInput implements Closeable { { final int mark = readMark(); - try { if (Ion.isMarkForBinary(mark)) { @@ -308,7 +298,6 @@ public class IonInput implements Closeable { loaded = (IonBinary) Ion.getClassForMark(mark).newInstance(); - loaded.load(this); return loaded; } diff --git a/src/mightypork/utils/ion/IonMapWrapper.java b/src/mightypork/utils/ion/IonMapWrapper.java index 9a21bf6..765944d 100644 --- a/src/mightypork/utils/ion/IonMapWrapper.java +++ b/src/mightypork/utils/ion/IonMapWrapper.java @@ -12,14 +12,12 @@ class IonMapWrapper implements IonBinary { private final Map map; - public IonMapWrapper() - { + public IonMapWrapper() { map = new LinkedHashMap<>(); } - public IonMapWrapper(Map saved) - { + public IonMapWrapper(Map saved) { map = saved; } diff --git a/src/mightypork/utils/ion/IonOutput.java b/src/mightypork/utils/ion/IonOutput.java index 51d6bbc..863ddf8 100644 --- a/src/mightypork/utils/ion/IonOutput.java +++ b/src/mightypork/utils/ion/IonOutput.java @@ -1,14 +1,7 @@ package mightypork.utils.ion; -import java.io.Closeable; -import java.io.DataOutput; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; +import java.io.*; import java.util.Collection; import java.util.Map; import java.util.Map.Entry; @@ -26,14 +19,12 @@ public class IonOutput implements Closeable { @SuppressWarnings("resource") - public IonOutput(File outFile) throws FileNotFoundException - { + public IonOutput(File outFile) throws FileNotFoundException { this(new FileOutputStream(outFile)); } - public IonOutput(OutputStream out) - { + public IonOutput(OutputStream out) { this.stream = out; this.out = new DataOutputStream(out); } @@ -299,7 +290,6 @@ public class IonOutput implements Closeable { return; } - if (Ion.isObjectIndirectBundled(obj)) { final IonizerBundled ionizer = Ion.getIonizerBundledForClass(obj.getClass()); diff --git a/src/mightypork/utils/ion/IonSequenceWrapper.java b/src/mightypork/utils/ion/IonSequenceWrapper.java index 9719c0d..54fdefd 100644 --- a/src/mightypork/utils/ion/IonSequenceWrapper.java +++ b/src/mightypork/utils/ion/IonSequenceWrapper.java @@ -12,14 +12,12 @@ class IonSequenceWrapper implements IonBinary { private Collection collection = new ArrayList(); - public IonSequenceWrapper() - { + public IonSequenceWrapper() { collection = new ArrayList(); } - public IonSequenceWrapper(Collection saved) - { + public IonSequenceWrapper(Collection saved) { collection = saved; } diff --git a/src/mightypork/utils/ion/IonizerBinary.java b/src/mightypork/utils/ion/IonizerBinary.java index 0a24a3b..6471ef6 100644 --- a/src/mightypork/utils/ion/IonizerBinary.java +++ b/src/mightypork/utils/ion/IonizerBinary.java @@ -1,5 +1,6 @@ package mightypork.utils.ion; + import java.io.IOException; @@ -13,16 +14,18 @@ import java.io.IOException; public abstract class IonizerBinary { @SuppressWarnings("unchecked") - final void _save(Object object, IonOutput out) throws IOException{ - save((T)object, out); + final void _save(Object object, IonOutput out) throws IOException + { + save((T) object, out); } + /** * Save an object to ion output * * @param object object to save * @param out ion output - * @throws IOException + * @throws IOException */ public abstract void save(T object, IonOutput out) throws IOException; diff --git a/src/mightypork/utils/ion/IonizerBundled.java b/src/mightypork/utils/ion/IonizerBundled.java index f4c21b4..63a657f 100644 --- a/src/mightypork/utils/ion/IonizerBundled.java +++ b/src/mightypork/utils/ion/IonizerBundled.java @@ -11,10 +11,12 @@ package mightypork.utils.ion; public abstract class IonizerBundled { @SuppressWarnings("unchecked") - final void _save(Object object, IonDataBundle out) { - save((T)object, out); + final void _save(Object object, IonDataBundle out) + { + save((T) object, out); } + /** * Save an object to data bundle * diff --git a/src/mightypork/utils/logging/writers/ArchivingLog.java b/src/mightypork/utils/logging/writers/ArchivingLog.java index 29abda9..6c7a0f7 100644 --- a/src/mightypork/utils/logging/writers/ArchivingLog.java +++ b/src/mightypork/utils/logging/writers/ArchivingLog.java @@ -32,8 +32,7 @@ public class ArchivingLog extends SimpleLog { * @param file log file (in log directory) * @param oldLogCount number of old log files to keep: -1 all, 0 none. */ - public ArchivingLog(String name, File file, int oldLogCount) - { + public ArchivingLog(String name, File file, int oldLogCount) { super(name, file); this.logs_to_keep = oldLogCount; } @@ -45,8 +44,7 @@ public class ArchivingLog extends SimpleLog { * @param name log name * @param file log file (in log directory) */ - public ArchivingLog(String name, File file) - { + public ArchivingLog(String name, File file) { super(name, file); this.logs_to_keep = 5; } @@ -64,7 +62,7 @@ public class ArchivingLog extends SimpleLog { private void cleanLoggingDirectory() { if (logs_to_keep == 0) return; // overwrite - + final File log_file = getFile(); final File log_dir = log_file.getParentFile(); final String fname = FileUtils.getBasename(log_file.toString()); @@ -87,7 +85,7 @@ public class ArchivingLog extends SimpleLog { } if (logs_to_keep == -1) return; // keep all - + final List oldLogs = FileUtils.listDirectory(log_dir, new FileFilter() { @Override diff --git a/src/mightypork/utils/logging/writers/SimpleLog.java b/src/mightypork/utils/logging/writers/SimpleLog.java index 8747c5b..cd3b4bc 100644 --- a/src/mightypork/utils/logging/writers/SimpleLog.java +++ b/src/mightypork/utils/logging/writers/SimpleLog.java @@ -48,8 +48,7 @@ public class SimpleLog implements LogWriter { private final long started_ms; - public SimpleLog(String name, File file) - { + public SimpleLog(String name, File file) { this.name = name; this.file = file; this.started_ms = System.currentTimeMillis(); diff --git a/src/mightypork/utils/math/Calc.java b/src/mightypork/utils/math/Calc.java index 9c50bfe..e0d4bdd 100644 --- a/src/mightypork/utils/math/Calc.java +++ b/src/mightypork/utils/math/Calc.java @@ -18,8 +18,7 @@ import mightypork.utils.math.constraints.vect.Vect; */ public final class Calc { - private Calc() - { + private Calc() { // not instantiable } diff --git a/src/mightypork/utils/math/Polar.java b/src/mightypork/utils/math/Polar.java index 8460fb8..8f32e73 100644 --- a/src/mightypork/utils/math/Polar.java +++ b/src/mightypork/utils/math/Polar.java @@ -26,8 +26,7 @@ public class Polar { * @param angle angle in RAD * @param distance distance from origin */ - public Polar(double angle, double distance) - { + public Polar(double angle, double distance) { this(angle, false, distance); } @@ -39,8 +38,7 @@ public class Polar { * @param deg angle is in DEG * @param distance radius */ - public Polar(double angle, boolean deg, double distance) - { + public Polar(double angle, boolean deg, double distance) { this.radius = distance; this.angle = deg ? Math.toRadians(angle) : angle; } diff --git a/src/mightypork/utils/math/Range.java b/src/mightypork/utils/math/Range.java index 3ca15cb..63f9db4 100644 --- a/src/mightypork/utils/math/Range.java +++ b/src/mightypork/utils/math/Range.java @@ -23,8 +23,7 @@ public class Range { /** * Implicit range constructor 0-1 */ - public Range() - { + public Range() { } @@ -34,8 +33,7 @@ public class Range { * @param min min number * @param max max number */ - public Range(double min, double max) - { + public Range(double min, double max) { this.min = min; this.max = max; norm(); @@ -47,8 +45,7 @@ public class Range { * * @param minmax min = max number */ - public Range(double minmax) - { + public Range(double minmax) { this.min = minmax; this.max = minmax; } diff --git a/src/mightypork/utils/math/algo/Coord.java b/src/mightypork/utils/math/algo/Coord.java index eb4dcab..8e7ad2b 100644 --- a/src/mightypork/utils/math/algo/Coord.java +++ b/src/mightypork/utils/math/algo/Coord.java @@ -39,22 +39,19 @@ public class Coord { } - public Coord() - { + public Coord() { // for ion } - public Coord(int x, int y) - { + public Coord(int x, int y) { super(); this.x = x; this.y = y; } - public Coord(Coord other) - { + public Coord(Coord other) { this.x = other.x; this.y = other.y; } diff --git a/src/mightypork/utils/math/algo/Move.java b/src/mightypork/utils/math/algo/Move.java index bbe6332..c9f7fbe 100644 --- a/src/mightypork/utils/math/algo/Move.java +++ b/src/mightypork/utils/math/algo/Move.java @@ -32,10 +32,9 @@ public class Move { private final byte x; private final byte y; - - public Move(int x, int y) - { + + public Move(int x, int y) { this.x = (byte) (x < 0 ? -1 : x > 0 ? 1 : 0); this.y = (byte) (y < 0 ? -1 : y > 0 ? 1 : 0); } diff --git a/src/mightypork/utils/math/algo/pathfinding/PathFinder.java b/src/mightypork/utils/math/algo/pathfinding/PathFinder.java index 8da887d..46ea1a5 100644 --- a/src/mightypork/utils/math/algo/pathfinding/PathFinder.java +++ b/src/mightypork/utils/math/algo/pathfinding/PathFinder.java @@ -100,7 +100,6 @@ public abstract class PathFinder { a.h_cost = (int) (heuristic.getCost(a.pos, end) * getMinCost()); a.parent = current; - if (!closed.contains(a)) { if (open.contains(a)) { @@ -152,8 +151,7 @@ public abstract class PathFinder { Node parent; - public Node(Coord pos) - { + public Node(Coord pos) { this.pos = pos; } diff --git a/src/mightypork/utils/math/algo/pathfinding/PathFinderProxy.java b/src/mightypork/utils/math/algo/pathfinding/PathFinderProxy.java index 006e045..bf21ab3 100644 --- a/src/mightypork/utils/math/algo/pathfinding/PathFinderProxy.java +++ b/src/mightypork/utils/math/algo/pathfinding/PathFinderProxy.java @@ -18,8 +18,7 @@ public class PathFinderProxy extends PathFinder { private final PathFinder source; - public PathFinderProxy(PathFinder other) - { + public PathFinderProxy(PathFinder other) { this.source = other; } diff --git a/src/mightypork/utils/math/animation/Animator.java b/src/mightypork/utils/math/animation/Animator.java index 66921ee..2486e21 100644 --- a/src/mightypork/utils/math/animation/Animator.java +++ b/src/mightypork/utils/math/animation/Animator.java @@ -17,26 +17,22 @@ public abstract class Animator implements NumBound, Updateable, Pauseable { private final double lowValue; - public Animator(double period) - { + public Animator(double period) { this(0, 1, period, Easing.LINEAR); } - public Animator(double start, double end, double period) - { + public Animator(double start, double end, double period) { this(start, end, period, Easing.LINEAR); } - public Animator(double period, Easing easing) - { + public Animator(double period, Easing easing) { this(0, 1, period, easing); } - public Animator(double start, double end, double period, Easing easing) - { + public Animator(double start, double end, double period, Easing easing) { numAnim = new NumAnimated(0, easing); numAnim.setDefaultDuration(period); diff --git a/src/mightypork/utils/math/animation/AnimatorBounce.java b/src/mightypork/utils/math/animation/AnimatorBounce.java index b884645..5610bc6 100644 --- a/src/mightypork/utils/math/animation/AnimatorBounce.java +++ b/src/mightypork/utils/math/animation/AnimatorBounce.java @@ -11,26 +11,22 @@ public class AnimatorBounce extends Animator { private boolean wasUp = false; - public AnimatorBounce(double start, double end, double period, Easing easing) - { + public AnimatorBounce(double start, double end, double period, Easing easing) { super(start, end, period, easing); } - public AnimatorBounce(double start, double end, double period) - { + public AnimatorBounce(double start, double end, double period) { super(start, end, period); } - public AnimatorBounce(double period, Easing easing) - { + public AnimatorBounce(double period, Easing easing) { super(period, easing); } - public AnimatorBounce(double period) - { + public AnimatorBounce(double period) { super(period); } diff --git a/src/mightypork/utils/math/animation/AnimatorRewind.java b/src/mightypork/utils/math/animation/AnimatorRewind.java index e150e0a..161d82c 100644 --- a/src/mightypork/utils/math/animation/AnimatorRewind.java +++ b/src/mightypork/utils/math/animation/AnimatorRewind.java @@ -9,26 +9,22 @@ package mightypork.utils.math.animation; */ public class AnimatorRewind extends Animator { - public AnimatorRewind(double start, double end, double period, Easing easing) - { + public AnimatorRewind(double start, double end, double period, Easing easing) { super(start, end, period, easing); } - public AnimatorRewind(double start, double end, double period) - { + public AnimatorRewind(double start, double end, double period) { super(start, end, period); } - public AnimatorRewind(double period, Easing easing) - { + public AnimatorRewind(double period, Easing easing) { super(period, easing); } - public AnimatorRewind(double period) - { + public AnimatorRewind(double period) { super(period); } diff --git a/src/mightypork/utils/math/animation/Easing.java b/src/mightypork/utils/math/animation/Easing.java index efbcd92..778c7b9 100644 --- a/src/mightypork/utils/math/animation/Easing.java +++ b/src/mightypork/utils/math/animation/Easing.java @@ -67,8 +67,7 @@ public abstract class Easing { /** * @param in Easing to reverse */ - public Reverse(Easing in) - { + public Reverse(Easing in) { this.ea = in; } @@ -97,8 +96,7 @@ public abstract class Easing { * @param in initial EasingFunction * @param out terminal EasingFunction */ - public Composite(Easing in, Easing out) - { + public Composite(Easing in, Easing out) { this.in = in; this.out = out; } diff --git a/src/mightypork/utils/math/animation/NumAnimated.java b/src/mightypork/utils/math/animation/NumAnimated.java index eb0f523..f7d295c 100644 --- a/src/mightypork/utils/math/animation/NumAnimated.java +++ b/src/mightypork/utils/math/animation/NumAnimated.java @@ -45,8 +45,7 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable { * * @param value initial value */ - public NumAnimated(double value) - { + public NumAnimated(double value) { setTo(value); } @@ -57,8 +56,7 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable { * @param value initial value * @param easing easing function */ - public NumAnimated(double value, Easing easing) - { + public NumAnimated(double value, Easing easing) { this(value); setEasing(easing); } @@ -71,8 +69,7 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable { * @param easingIn easing function (fade in) * @param easingOut easing function (fade out) */ - public NumAnimated(double value, Easing easingIn, Easing easingOut) - { + public NumAnimated(double value, Easing easingIn, Easing easingOut) { this(value); setEasing(easingIn, easingOut); } @@ -85,8 +82,7 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable { * @param easing easing function * @param defaultDuration default fade duration */ - public NumAnimated(double value, Easing easing, double defaultDuration) - { + public NumAnimated(double value, Easing easing, double defaultDuration) { this(value); setEasing(easing); setDefaultDuration(defaultDuration); @@ -101,8 +97,7 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable { * @param easingOut easing function (fade out) * @param defaultDuration default fade duration */ - public NumAnimated(double value, Easing easingIn, Easing easingOut, double defaultDuration) - { + public NumAnimated(double value, Easing easingIn, Easing easingOut, double defaultDuration) { this(value); setEasing(easingIn, easingOut); setDefaultDuration(defaultDuration); @@ -114,8 +109,7 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable { * * @param other other animator */ - public NumAnimated(NumAnimated other) - { + public NumAnimated(NumAnimated other) { setTo(other); } diff --git a/src/mightypork/utils/math/animation/NumAnimatedDeg.java b/src/mightypork/utils/math/animation/NumAnimatedDeg.java index 1e3122f..32b2b06 100644 --- a/src/mightypork/utils/math/animation/NumAnimatedDeg.java +++ b/src/mightypork/utils/math/animation/NumAnimatedDeg.java @@ -12,20 +12,17 @@ import mightypork.utils.math.angles.Deg; */ public class NumAnimatedDeg extends NumAnimated { - public NumAnimatedDeg(NumAnimated other) - { + public NumAnimatedDeg(NumAnimated other) { super(other); } - public NumAnimatedDeg(double value) - { + public NumAnimatedDeg(double value) { super(value); } - public NumAnimatedDeg(double value, Easing easing) - { + public NumAnimatedDeg(double value, Easing easing) { super(value, easing); } diff --git a/src/mightypork/utils/math/animation/NumAnimatedRad.java b/src/mightypork/utils/math/animation/NumAnimatedRad.java index 2801acb..7057a63 100644 --- a/src/mightypork/utils/math/animation/NumAnimatedRad.java +++ b/src/mightypork/utils/math/animation/NumAnimatedRad.java @@ -12,20 +12,17 @@ import mightypork.utils.math.angles.Rad; */ public class NumAnimatedRad extends NumAnimated { - public NumAnimatedRad(NumAnimated other) - { + public NumAnimatedRad(NumAnimated other) { super(other); } - public NumAnimatedRad(double value) - { + public NumAnimatedRad(double value) { super(value); } - public NumAnimatedRad(double value, Easing easing) - { + public NumAnimatedRad(double value, Easing easing) { super(value, easing); } diff --git a/src/mightypork/utils/math/animation/VectAnimated.java b/src/mightypork/utils/math/animation/VectAnimated.java index 12c5c45..32cd357 100644 --- a/src/mightypork/utils/math/animation/VectAnimated.java +++ b/src/mightypork/utils/math/animation/VectAnimated.java @@ -27,8 +27,7 @@ public class VectAnimated extends VectMutable implements Pauseable, Updateable { * @param y y animator * @param z z animator */ - public VectAnimated(NumAnimated x, NumAnimated y, NumAnimated z) - { + public VectAnimated(NumAnimated x, NumAnimated y, NumAnimated z) { this.x = x; this.y = y; this.z = z; @@ -41,8 +40,7 @@ public class VectAnimated extends VectMutable implements Pauseable, Updateable { * @param start initial positioon * @param easing animation easing */ - public VectAnimated(Vect start, Easing easing) - { + public VectAnimated(Vect start, Easing easing) { x = new NumAnimated(start.x(), easing); y = new NumAnimated(start.y(), easing); z = new NumAnimated(start.z(), easing); diff --git a/src/mightypork/utils/math/color/ColorAlphaAdjuster.java b/src/mightypork/utils/math/color/ColorAlphaAdjuster.java index b7466a1..9d58577 100644 --- a/src/mightypork/utils/math/color/ColorAlphaAdjuster.java +++ b/src/mightypork/utils/math/color/ColorAlphaAdjuster.java @@ -10,8 +10,7 @@ public class ColorAlphaAdjuster extends Color { private final Num alphaAdjust; - public ColorAlphaAdjuster(Color source, Num alphaMul) - { + public ColorAlphaAdjuster(Color source, Num alphaMul) { this.source = source; this.alphaAdjust = alphaMul; } diff --git a/src/mightypork/utils/math/color/ColorHsb.java b/src/mightypork/utils/math/color/ColorHsb.java index 45e12c3..781873f 100644 --- a/src/mightypork/utils/math/color/ColorHsb.java +++ b/src/mightypork/utils/math/color/ColorHsb.java @@ -12,8 +12,7 @@ public class ColorHsb extends Color { private final Num a; - public ColorHsb(Num h, Num s, Num b, Num a) - { + public ColorHsb(Num h, Num s, Num b, Num a) { this.h = h; this.s = s; this.b = b; diff --git a/src/mightypork/utils/math/color/ColorRgb.java b/src/mightypork/utils/math/color/ColorRgb.java index c7ea99b..38eb212 100644 --- a/src/mightypork/utils/math/color/ColorRgb.java +++ b/src/mightypork/utils/math/color/ColorRgb.java @@ -12,8 +12,7 @@ public class ColorRgb extends Color { private final Num a; - public ColorRgb(Num r, Num g, Num b, Num a) - { + public ColorRgb(Num r, Num g, Num b, Num a) { this.r = r; this.g = g; this.b = b; diff --git a/src/mightypork/utils/math/color/pal/RGB.java b/src/mightypork/utils/math/color/pal/RGB.java index 225986b..1dc490e 100644 --- a/src/mightypork/utils/math/color/pal/RGB.java +++ b/src/mightypork/utils/math/color/pal/RGB.java @@ -21,7 +21,6 @@ public class RGB { public static final Color BLACK_80 = Color.rgba(0, 0, 0, 0.8); public static final Color BLACK_90 = Color.rgba(0, 0, 0, 0.9); - public static final Color WHITE = Color.fromHex(0xFFFFFF); public static final Color BLACK = Color.fromHex(0x000000); public static final Color GRAY_DARK = Color.fromHex(0x808080); diff --git a/src/mightypork/utils/math/constraints/num/NumConst.java b/src/mightypork/utils/math/constraints/num/NumConst.java index 22dc915..b29ac42 100644 --- a/src/mightypork/utils/math/constraints/num/NumConst.java +++ b/src/mightypork/utils/math/constraints/num/NumConst.java @@ -17,14 +17,12 @@ public class NumConst extends Num { private NumDigest digest; - NumConst(Num copied) - { + NumConst(Num copied) { this.value = copied.value(); } - NumConst(double value) - { + NumConst(double value) { this.value = value; } diff --git a/src/mightypork/utils/math/constraints/num/caching/AbstractNumCache.java b/src/mightypork/utils/math/constraints/num/caching/AbstractNumCache.java index fc768b6..83c6809 100644 --- a/src/mightypork/utils/math/constraints/num/caching/AbstractNumCache.java +++ b/src/mightypork/utils/math/constraints/num/caching/AbstractNumCache.java @@ -25,8 +25,7 @@ public abstract class AbstractNumCache extends NumAdapter implements CachedConst private boolean cachingEnabled = true; - public AbstractNumCache() - { + public AbstractNumCache() { enableDigestCaching(true); // it changes only on poll } diff --git a/src/mightypork/utils/math/constraints/num/caching/NumCache.java b/src/mightypork/utils/math/constraints/num/caching/NumCache.java index 36d8389..4e10d19 100644 --- a/src/mightypork/utils/math/constraints/num/caching/NumCache.java +++ b/src/mightypork/utils/math/constraints/num/caching/NumCache.java @@ -14,8 +14,7 @@ public class NumCache extends AbstractNumCache { private final Num source; - public NumCache(Num source) - { + public NumCache(Num source) { this.source = source; } diff --git a/src/mightypork/utils/math/constraints/num/caching/NumDigest.java b/src/mightypork/utils/math/constraints/num/caching/NumDigest.java index 62247f8..599706a 100644 --- a/src/mightypork/utils/math/constraints/num/caching/NumDigest.java +++ b/src/mightypork/utils/math/constraints/num/caching/NumDigest.java @@ -9,8 +9,7 @@ public class NumDigest { public final double value; - public NumDigest(Num num) - { + public NumDigest(Num num) { this.value = num.value(); } diff --git a/src/mightypork/utils/math/constraints/num/proxy/NumProxy.java b/src/mightypork/utils/math/constraints/num/proxy/NumProxy.java index ea70816..da9b67f 100644 --- a/src/mightypork/utils/math/constraints/num/proxy/NumProxy.java +++ b/src/mightypork/utils/math/constraints/num/proxy/NumProxy.java @@ -16,13 +16,11 @@ public class NumProxy extends NumAdapter implements PluggableNumBound { private NumBound backing = null; - public NumProxy() - { + public NumProxy() { } - public NumProxy(NumBound bound) - { + public NumProxy(NumBound bound) { backing = bound; } diff --git a/src/mightypork/utils/math/constraints/num/var/NumVar.java b/src/mightypork/utils/math/constraints/num/var/NumVar.java index dfb48d1..015fe41 100644 --- a/src/mightypork/utils/math/constraints/num/var/NumVar.java +++ b/src/mightypork/utils/math/constraints/num/var/NumVar.java @@ -14,14 +14,12 @@ public class NumVar extends NumMutable { private double value; - public NumVar(Num value) - { + public NumVar(Num value) { this(value.value()); } - public NumVar(double value) - { + public NumVar(double value) { this.value = value; } diff --git a/src/mightypork/utils/math/constraints/rect/Rect.java b/src/mightypork/utils/math/constraints/rect/Rect.java index 65432e0..d8b8ea7 100644 --- a/src/mightypork/utils/math/constraints/rect/Rect.java +++ b/src/mightypork/utils/math/constraints/rect/Rect.java @@ -1058,5 +1058,4 @@ public abstract class Rect implements RectBound, CachedDigestable { return ((rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry)); } - } diff --git a/src/mightypork/utils/math/constraints/rect/RectConst.java b/src/mightypork/utils/math/constraints/rect/RectConst.java index 3ed6f1a..c1195a8 100644 --- a/src/mightypork/utils/math/constraints/rect/RectConst.java +++ b/src/mightypork/utils/math/constraints/rect/RectConst.java @@ -50,8 +50,7 @@ public class RectConst extends Rect { * @param width * @param height */ - RectConst(double x, double y, double width, double height) - { + RectConst(double x, double y, double width, double height) { this.pos = Vect.make(x, y); this.size = Vect.make(width, height); } @@ -63,8 +62,7 @@ public class RectConst extends Rect { * @param origin * @param size */ - RectConst(Vect origin, Vect size) - { + RectConst(Vect origin, Vect size) { this.pos = origin.freeze(); this.size = size.freeze(); } @@ -75,8 +73,7 @@ public class RectConst extends Rect { * * @param another other coord */ - RectConst(Rect another) - { + RectConst(Rect another) { this.pos = another.origin().freeze(); this.size = another.size().freeze(); } diff --git a/src/mightypork/utils/math/constraints/rect/builders/TiledRect.java b/src/mightypork/utils/math/constraints/rect/builders/TiledRect.java index 24eafa5..0b63f4f 100644 --- a/src/mightypork/utils/math/constraints/rect/builders/TiledRect.java +++ b/src/mightypork/utils/math/constraints/rect/builders/TiledRect.java @@ -23,8 +23,7 @@ public class TiledRect extends RectProxy { private Rect aTile; - public TiledRect(Rect source, int horizontal, int vertical) - { + public TiledRect(Rect source, int horizontal, int vertical) { super(source); this.tilesX = horizontal; this.tilesY = vertical; diff --git a/src/mightypork/utils/math/constraints/rect/caching/AbstractRectCache.java b/src/mightypork/utils/math/constraints/rect/caching/AbstractRectCache.java index b193b37..75c27a9 100644 --- a/src/mightypork/utils/math/constraints/rect/caching/AbstractRectCache.java +++ b/src/mightypork/utils/math/constraints/rect/caching/AbstractRectCache.java @@ -25,8 +25,7 @@ public abstract class AbstractRectCache extends RectAdapter implements CachedCon private boolean cachingEnabled = true; - public AbstractRectCache() - { + public AbstractRectCache() { enableDigestCaching(true); // it changes only on poll } diff --git a/src/mightypork/utils/math/constraints/rect/caching/RectCache.java b/src/mightypork/utils/math/constraints/rect/caching/RectCache.java index dc364a8..db1b858 100644 --- a/src/mightypork/utils/math/constraints/rect/caching/RectCache.java +++ b/src/mightypork/utils/math/constraints/rect/caching/RectCache.java @@ -14,8 +14,7 @@ public class RectCache extends AbstractRectCache { private final Rect source; - public RectCache(Rect source) - { + public RectCache(Rect source) { this.source = source; } diff --git a/src/mightypork/utils/math/constraints/rect/caching/RectDigest.java b/src/mightypork/utils/math/constraints/rect/caching/RectDigest.java index 263feaf..3007b9b 100644 --- a/src/mightypork/utils/math/constraints/rect/caching/RectDigest.java +++ b/src/mightypork/utils/math/constraints/rect/caching/RectDigest.java @@ -17,8 +17,7 @@ public class RectDigest { public final double bottom; - public RectDigest(Rect rect) - { + public RectDigest(Rect rect) { this.x = rect.origin().x(); this.y = rect.origin().y(); @@ -35,7 +34,6 @@ public class RectDigest { @Override public String toString() { - return String - .format("Rect{ at: (%.1f, %.1f), size: (%.1f, %.1f), bounds: L %.1f R %.1f T %.1f B %.1f }", x, y, width, height, left, right, top, bottom); + return String.format("Rect{ at: (%.1f, %.1f), size: (%.1f, %.1f), bounds: L %.1f R %.1f T %.1f B %.1f }", x, y, width, height, left, right, top, bottom); } } diff --git a/src/mightypork/utils/math/constraints/rect/proxy/RectProxy.java b/src/mightypork/utils/math/constraints/rect/proxy/RectProxy.java index aab3159..415f30f 100644 --- a/src/mightypork/utils/math/constraints/rect/proxy/RectProxy.java +++ b/src/mightypork/utils/math/constraints/rect/proxy/RectProxy.java @@ -16,13 +16,11 @@ public class RectProxy extends RectAdapter implements PluggableRectBound { private RectBound backing = null; - public RectProxy() - { + public RectProxy() { } - public RectProxy(RectBound proxied) - { + public RectProxy(RectBound proxied) { backing = proxied; } diff --git a/src/mightypork/utils/math/constraints/rect/proxy/RectVectAdapter.java b/src/mightypork/utils/math/constraints/rect/proxy/RectVectAdapter.java index 47f832f..95a2156 100644 --- a/src/mightypork/utils/math/constraints/rect/proxy/RectVectAdapter.java +++ b/src/mightypork/utils/math/constraints/rect/proxy/RectVectAdapter.java @@ -16,8 +16,7 @@ public class RectVectAdapter extends Rect { private final Vect size; - public RectVectAdapter(Vect origin, Vect size) - { + public RectVectAdapter(Vect origin, Vect size) { this.origin = origin; this.size = size; } diff --git a/src/mightypork/utils/math/constraints/rect/var/RectVar.java b/src/mightypork/utils/math/constraints/rect/var/RectVar.java index 88a82c3..3ce2824 100644 --- a/src/mightypork/utils/math/constraints/rect/var/RectVar.java +++ b/src/mightypork/utils/math/constraints/rect/var/RectVar.java @@ -19,8 +19,7 @@ public class RectVar extends RectMutable { * @param width * @param height */ - public RectVar(double x, double y, double width, double height) - { + public RectVar(double x, double y, double width, double height) { this.pos.setTo(x, y); this.size.setTo(width, height); } diff --git a/src/mightypork/utils/math/constraints/vect/VectConst.java b/src/mightypork/utils/math/constraints/vect/VectConst.java index 0a11cc9..56feb52 100644 --- a/src/mightypork/utils/math/constraints/vect/VectConst.java +++ b/src/mightypork/utils/math/constraints/vect/VectConst.java @@ -32,14 +32,12 @@ public final class VectConst extends Vect { private VectDigest digest; - VectConst(Vect other) - { + VectConst(Vect other) { this(other.x(), other.y(), other.z()); } - VectConst(double x, double y, double z) - { + VectConst(double x, double y, double z) { this.x = x; this.y = y; this.z = z; diff --git a/src/mightypork/utils/math/constraints/vect/caching/AbstractVectCache.java b/src/mightypork/utils/math/constraints/vect/caching/AbstractVectCache.java index 313c84f..2994c3e 100644 --- a/src/mightypork/utils/math/constraints/vect/caching/AbstractVectCache.java +++ b/src/mightypork/utils/math/constraints/vect/caching/AbstractVectCache.java @@ -25,8 +25,7 @@ public abstract class AbstractVectCache extends VectAdapter implements CachedCon private boolean cachingEnabled = true; - public AbstractVectCache() - { + public AbstractVectCache() { enableDigestCaching(true); // it changes only on poll } diff --git a/src/mightypork/utils/math/constraints/vect/caching/VectCache.java b/src/mightypork/utils/math/constraints/vect/caching/VectCache.java index b292874..84e5db3 100644 --- a/src/mightypork/utils/math/constraints/vect/caching/VectCache.java +++ b/src/mightypork/utils/math/constraints/vect/caching/VectCache.java @@ -14,8 +14,7 @@ public class VectCache extends AbstractVectCache { private final Vect source; - public VectCache(Vect source) - { + public VectCache(Vect source) { this.source = source; enableDigestCaching(true); } diff --git a/src/mightypork/utils/math/constraints/vect/caching/VectDigest.java b/src/mightypork/utils/math/constraints/vect/caching/VectDigest.java index 12a8847..48a5797 100644 --- a/src/mightypork/utils/math/constraints/vect/caching/VectDigest.java +++ b/src/mightypork/utils/math/constraints/vect/caching/VectDigest.java @@ -11,8 +11,7 @@ public class VectDigest { public final double z; - public VectDigest(Vect vect) - { + public VectDigest(Vect vect) { this.x = vect.x(); this.y = vect.y(); this.z = vect.z(); diff --git a/src/mightypork/utils/math/constraints/vect/proxy/VectNumAdapter.java b/src/mightypork/utils/math/constraints/vect/proxy/VectNumAdapter.java index 1f02d20..40b348c 100644 --- a/src/mightypork/utils/math/constraints/vect/proxy/VectNumAdapter.java +++ b/src/mightypork/utils/math/constraints/vect/proxy/VectNumAdapter.java @@ -18,16 +18,14 @@ public class VectNumAdapter extends Vect { private final Num constrZ; - public VectNumAdapter(Num x, Num y, Num z) - { + public VectNumAdapter(Num x, Num y, Num z) { this.constrX = x; this.constrY = y; this.constrZ = z; } - public VectNumAdapter(Num x, Num y) - { + public VectNumAdapter(Num x, Num y) { this.constrX = x; this.constrY = y; this.constrZ = Num.ZERO; diff --git a/src/mightypork/utils/math/constraints/vect/proxy/VectProxy.java b/src/mightypork/utils/math/constraints/vect/proxy/VectProxy.java index 572d14f..862fb81 100644 --- a/src/mightypork/utils/math/constraints/vect/proxy/VectProxy.java +++ b/src/mightypork/utils/math/constraints/vect/proxy/VectProxy.java @@ -16,13 +16,11 @@ public class VectProxy extends VectAdapter implements PluggableVectBound { private VectBound backing = null; - public VectProxy() - { + public VectProxy() { } - public VectProxy(VectBound proxied) - { + public VectProxy(VectBound proxied) { backing = proxied; } diff --git a/src/mightypork/utils/math/constraints/vect/var/VectVar.java b/src/mightypork/utils/math/constraints/vect/var/VectVar.java index 04221f6..2e64189 100644 --- a/src/mightypork/utils/math/constraints/vect/var/VectVar.java +++ b/src/mightypork/utils/math/constraints/vect/var/VectVar.java @@ -17,8 +17,7 @@ public class VectVar extends VectMutable { * @param y Y coordinate * @param z Z coordinate */ - public VectVar(double x, double y, double z) - { + public VectVar(double x, double y, double z) { super(); this.x = x; this.y = y; diff --git a/src/mightypork/utils/math/noise/NoiseGen.java b/src/mightypork/utils/math/noise/NoiseGen.java index c2e6ebb..37c49b9 100644 --- a/src/mightypork/utils/math/noise/NoiseGen.java +++ b/src/mightypork/utils/math/noise/NoiseGen.java @@ -27,8 +27,7 @@ public class NoiseGen { * @param middle middle bound ("surface") * @param high high bound ("hill") */ - public NoiseGen(double density, double low, double middle, double high) - { + public NoiseGen(double density, double low, double middle, double high) { this(density, low, middle, high, Double.doubleToLongBits(Math.random())); } @@ -42,8 +41,7 @@ public class NoiseGen { * @param high high bound ("hill") * @param seed random seed to use */ - public NoiseGen(double density, double low, double middle, double high, long seed) - { + public NoiseGen(double density, double low, double middle, double high, long seed) { if (low > middle || middle > high) throw new IllegalArgumentException("Invalid value range."); this.density = density; diff --git a/src/mightypork/utils/math/noise/PerlinNoiseGenerator.java b/src/mightypork/utils/math/noise/PerlinNoiseGenerator.java index 1b3f2ef..19afdc3 100644 --- a/src/mightypork/utils/math/noise/PerlinNoiseGenerator.java +++ b/src/mightypork/utils/math/noise/PerlinNoiseGenerator.java @@ -60,8 +60,7 @@ public class PerlinNoiseGenerator { /** * Create a new noise creator with the default seed value */ - public PerlinNoiseGenerator() - { + public PerlinNoiseGenerator() { this(DEFAULT_SEED); } @@ -71,8 +70,7 @@ public class PerlinNoiseGenerator { * * @param seed The seed value to use */ - public PerlinNoiseGenerator(long seed) - { + public PerlinNoiseGenerator(long seed) { p_imp = new int[DEFAULT_SAMPLE_SIZE << 1]; int i, j, k; @@ -410,10 +408,7 @@ public class PerlinNoiseGenerator { */ public double tileableNoise3(double x, double y, double z, double w, double h, double d) { - return (noise3(x, y, z) * (w - x) * (h - y) * (d - z) + noise3(x - w, y, z) * x * (h - y) * (d - z) + noise3(x, y - h, z) * (w - x) * y * (d - z) - + noise3(x - w, y - h, z) * x * y * (d - z) + noise3(x, y, z - d) * (w - x) * (h - y) * z + noise3(x - w, y, z - d) * x * (h - y) * z - + noise3(x, y - h, z - d) * (w - x) * y * z + noise3(x - w, y - h, z - d) * x * y * z) - / (w * h * d); + return (noise3(x, y, z) * (w - x) * (h - y) * (d - z) + noise3(x - w, y, z) * x * (h - y) * (d - z) + noise3(x, y - h, z) * (w - x) * y * (d - z) + noise3(x - w, y - h, z) * x * y * (d - z) + noise3(x, y, z - d) * (w - x) * (h - y) * z + noise3(x - w, y, z - d) * x * (h - y) * z + noise3(x, y - h, z - d) * (w - x) * y * z + noise3(x - w, y - h, z - d) * x * y * z) / (w * h * d); } diff --git a/src/mightypork/utils/math/timing/Profiler.java b/src/mightypork/utils/math/timing/Profiler.java index d484ea6..79700c8 100644 --- a/src/mightypork/utils/math/timing/Profiler.java +++ b/src/mightypork/utils/math/timing/Profiler.java @@ -1,5 +1,6 @@ package mightypork.utils.math.timing; + import mightypork.utils.Support; diff --git a/src/mightypork/utils/math/timing/TaskRepeater.java b/src/mightypork/utils/math/timing/TaskRepeater.java index ef1308a..f221101 100644 --- a/src/mightypork/utils/math/timing/TaskRepeater.java +++ b/src/mightypork/utils/math/timing/TaskRepeater.java @@ -11,8 +11,7 @@ public abstract class TaskRepeater extends AnimatorRewind implements Runnable, E private boolean enabled = true; - public TaskRepeater(double period) - { + public TaskRepeater(double period) { super(period); } diff --git a/src/mightypork/utils/math/timing/TimerDelta.java b/src/mightypork/utils/math/timing/TimerDelta.java index 63688f2..8833e0c 100644 --- a/src/mightypork/utils/math/timing/TimerDelta.java +++ b/src/mightypork/utils/math/timing/TimerDelta.java @@ -16,8 +16,7 @@ public class TimerDelta { /** * New delta timer */ - public TimerDelta() - { + public TimerDelta() { lastFrame = System.nanoTime(); } diff --git a/src/mightypork/utils/math/timing/TimerFps.java b/src/mightypork/utils/math/timing/TimerFps.java index 0cee2ad..786a443 100644 --- a/src/mightypork/utils/math/timing/TimerFps.java +++ b/src/mightypork/utils/math/timing/TimerFps.java @@ -22,8 +22,7 @@ public class TimerFps { * * @param fps target FPS */ - public TimerFps(long fps) - { + public TimerFps(long fps) { FRAME = Math.round(SECOND / (double) fps); lastFrame = System.nanoTime(); diff --git a/src/mightypork/utils/string/StringWrapper.java b/src/mightypork/utils/string/StringWrapper.java index 2f12dbe..551583c 100644 --- a/src/mightypork/utils/string/StringWrapper.java +++ b/src/mightypork/utils/string/StringWrapper.java @@ -11,8 +11,7 @@ public class StringWrapper implements StringProvider { private final String value; - public StringWrapper(String value) - { + public StringWrapper(String value) { this.value = value; } diff --git a/src/mightypork/utils/string/validation/CharFilterRegex.java b/src/mightypork/utils/string/validation/CharFilterRegex.java index 8d05927..1272dbf 100644 --- a/src/mightypork/utils/string/validation/CharFilterRegex.java +++ b/src/mightypork/utils/string/validation/CharFilterRegex.java @@ -6,8 +6,7 @@ public class CharFilterRegex implements CharFilter { private final String formula; - public CharFilterRegex(String regex) - { + public CharFilterRegex(String regex) { this.formula = regex; } diff --git a/src/mightypork/utils/string/validation/CharFilterWhitelist.java b/src/mightypork/utils/string/validation/CharFilterWhitelist.java index d9e62dd..5ab41e6 100644 --- a/src/mightypork/utils/string/validation/CharFilterWhitelist.java +++ b/src/mightypork/utils/string/validation/CharFilterWhitelist.java @@ -6,8 +6,7 @@ public class CharFilterWhitelist implements CharFilter { private final String whitelist; - public CharFilterWhitelist(String allowed) - { + public CharFilterWhitelist(String allowed) { this.whitelist = allowed; } diff --git a/src/mightypork/utils/struct/Mutable.java b/src/mightypork/utils/struct/Mutable.java index acad2db..fdf1ad9 100644 --- a/src/mightypork/utils/struct/Mutable.java +++ b/src/mightypork/utils/struct/Mutable.java @@ -18,8 +18,7 @@ public class Mutable { * * @param o value */ - public Mutable(T o) - { + public Mutable(T o) { this.o = o; } diff --git a/src/mightypork/utils/struct/Pair.java b/src/mightypork/utils/struct/Pair.java index a2465f7..0c04b96 100644 --- a/src/mightypork/utils/struct/Pair.java +++ b/src/mightypork/utils/struct/Pair.java @@ -28,8 +28,7 @@ public class Pair { * @param first 1st object * @param second 2nd object */ - public Pair(T1 first, T2 second) - { + public Pair(T1 first, T2 second) { this.first = first; this.second = second; } diff --git a/src/mightypork/utils/struct/Triad.java b/src/mightypork/utils/struct/Triad.java index 7c9fc05..aa788ac 100644 --- a/src/mightypork/utils/struct/Triad.java +++ b/src/mightypork/utils/struct/Triad.java @@ -25,8 +25,7 @@ public class Triad extends Pair { * @param objB 2nd object * @param objC 3rd object */ - public Triad(T1 objA, T2 objB, T3 objC) - { + public Triad(T1 objA, T2 objB, T3 objC) { super(objA, objB); third = objC; }