Cleanup and minor javadoc fixes
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
package mightypork.utils;
|
package mightypork.utils;
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
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.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
|
||||||
@@ -85,6 +90,7 @@ public class MapSort {
|
|||||||
|
|
||||||
Collections.sort(entries, new Comparator<Map.Entry<K, V>>() {
|
Collections.sort(entries, new Comparator<Map.Entry<K, V>>() {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public int compare(Entry<K, V> o1, Entry<K, V> o2)
|
public int compare(Entry<K, V> o1, Entry<K, V> o2)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,6 +69,16 @@ public class Reflect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get value of a public static final field. If the modifiers don't match,
|
||||||
|
* an exception is thrown.
|
||||||
|
*
|
||||||
|
* @param objClass the class
|
||||||
|
* @param fieldName field to retrieve
|
||||||
|
* @return the field value
|
||||||
|
* @throws ReflectiveOperationException if the field is not constant, or if
|
||||||
|
* the value could not be retrieved.
|
||||||
|
*/
|
||||||
public static Object getConstantFieldValue(Class<?> objClass, String fieldName) throws ReflectiveOperationException
|
public static Object getConstantFieldValue(Class<?> objClass, String fieldName) throws ReflectiveOperationException
|
||||||
{
|
{
|
||||||
final Field fld = objClass.getDeclaredField(fieldName);
|
final Field fld = objClass.getDeclaredField(fieldName);
|
||||||
@@ -76,7 +86,7 @@ public class Reflect {
|
|||||||
final int modif = fld.getModifiers();
|
final int modif = fld.getModifiers();
|
||||||
|
|
||||||
if (!Modifier.isFinal(modif) || !Modifier.isStatic(modif)) {
|
if (!Modifier.isFinal(modif) || !Modifier.isStatic(modif)) {
|
||||||
throw new RuntimeException("The " + fieldName + " field of " + Support.str(objClass) + " must be static and final!");
|
throw new ReflectiveOperationException("The " + fieldName + " field of " + Support.str(objClass) + " must be static and final!");
|
||||||
}
|
}
|
||||||
|
|
||||||
fld.setAccessible(true);
|
fld.setAccessible(true);
|
||||||
|
|||||||
@@ -167,7 +167,8 @@ public final class Support {
|
|||||||
/**
|
/**
|
||||||
* @param enumeration the iterated enumeration
|
* @param enumeration the iterated enumeration
|
||||||
*/
|
*/
|
||||||
public IterableEnumerationWrapper(Enumeration<? extends T> enumeration) {
|
public IterableEnumerationWrapper(Enumeration<? extends T> enumeration)
|
||||||
|
{
|
||||||
this.enumeration = enumeration;
|
this.enumeration = enumeration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,8 +207,8 @@ public final class Support {
|
|||||||
* Convert a class to string, preserving name and outer class, but excluding
|
* Convert a class to string, preserving name and outer class, but excluding
|
||||||
* path.
|
* path.
|
||||||
*
|
*
|
||||||
* @param cls
|
* @param cls the class
|
||||||
* @return
|
* @return class name
|
||||||
*/
|
*/
|
||||||
public static String str(Class<?> cls)
|
public static String str(Class<?> cls)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package mightypork.utils.annotations;
|
package mightypork.utils.annotations;
|
||||||
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ public abstract class Property<T> {
|
|||||||
* @param defaultValue defualt property value (used as fallback when
|
* @param defaultValue defualt property value (used as fallback when
|
||||||
* parsing)
|
* parsing)
|
||||||
*/
|
*/
|
||||||
public Property(String key, T defaultValue) {
|
public Property(String key, T defaultValue)
|
||||||
|
{
|
||||||
this(key, defaultValue, null);
|
this(key, defaultValue, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,12 +39,13 @@ public abstract class Property<T> {
|
|||||||
* Create a property with a comment
|
* Create a property with a comment
|
||||||
*
|
*
|
||||||
* @param key key in the config file
|
* @param key key in the config file
|
||||||
* @param defaultValue defualt property value (used as fallback when
|
* @param defaultValue default property value, used as fallback when
|
||||||
* parsing)
|
* parsing. Initially the value is assigned to defaultValue.
|
||||||
* @param comment optional property comment included above the property in
|
* @param comment optional property comment included above the property in
|
||||||
* the config file. Can be null.
|
* the config file. Can be null.
|
||||||
*/
|
*/
|
||||||
public Property(String key, T defaultValue, String comment) {
|
public Property(String key, T defaultValue, String comment)
|
||||||
|
{
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.value = defaultValue;
|
this.value = defaultValue;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class PropertyManager {
|
|||||||
|
|
||||||
private final TreeMap<String, Property<?>> entries = new TreeMap<>();
|
private final TreeMap<String, Property<?>> entries = new TreeMap<>();
|
||||||
private final TreeMap<String, String> renameTable = new TreeMap<>();
|
private final TreeMap<String, String> renameTable = new TreeMap<>();
|
||||||
private PropertyStore props;
|
private final PropertyStore props;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,7 +35,8 @@ public class PropertyManager {
|
|||||||
* @param file property file
|
* @param file property file
|
||||||
* @param comment header comment.
|
* @param comment header comment.
|
||||||
*/
|
*/
|
||||||
public PropertyManager(File file, String comment) {
|
public PropertyManager(File file, String comment)
|
||||||
|
{
|
||||||
this(new PropertyFile(file, comment));
|
this(new PropertyFile(file, comment));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +47,8 @@ public class PropertyManager {
|
|||||||
* @param props a property store implementation backing this property
|
* @param props a property store implementation backing this property
|
||||||
* manager
|
* manager
|
||||||
*/
|
*/
|
||||||
public PropertyManager(PropertyStore props) {
|
public PropertyManager(PropertyStore props)
|
||||||
|
{
|
||||||
this.props = props;
|
this.props = props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ import mightypork.utils.config.propmgr.Property;
|
|||||||
*/
|
*/
|
||||||
public class BooleanProperty extends Property<Boolean> {
|
public class BooleanProperty extends Property<Boolean> {
|
||||||
|
|
||||||
public BooleanProperty(String key, Boolean defaultValue) {
|
public BooleanProperty(String key, Boolean defaultValue)
|
||||||
|
{
|
||||||
super(key, defaultValue);
|
super(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BooleanProperty(String key, Boolean defaultValue, String comment) {
|
public BooleanProperty(String key, Boolean defaultValue, String comment)
|
||||||
|
{
|
||||||
super(key, defaultValue, comment);
|
super(key, defaultValue, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ import mightypork.utils.config.propmgr.Property;
|
|||||||
*/
|
*/
|
||||||
public class DoubleProperty extends Property<Double> {
|
public class DoubleProperty extends Property<Double> {
|
||||||
|
|
||||||
public DoubleProperty(String key, Double defaultValue) {
|
public DoubleProperty(String key, Double defaultValue)
|
||||||
|
{
|
||||||
super(key, defaultValue);
|
super(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DoubleProperty(String key, Double defaultValue, String comment) {
|
public DoubleProperty(String key, Double defaultValue, String comment)
|
||||||
|
{
|
||||||
super(key, defaultValue, comment);
|
super(key, defaultValue, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ import mightypork.utils.config.propmgr.Property;
|
|||||||
*/
|
*/
|
||||||
public class IntegerProperty extends Property<Integer> {
|
public class IntegerProperty extends Property<Integer> {
|
||||||
|
|
||||||
public IntegerProperty(String key, Integer defaultValue) {
|
public IntegerProperty(String key, Integer defaultValue)
|
||||||
|
{
|
||||||
super(key, defaultValue);
|
super(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IntegerProperty(String key, Integer defaultValue, String comment) {
|
public IntegerProperty(String key, Integer defaultValue, String comment)
|
||||||
|
{
|
||||||
super(key, defaultValue, comment);
|
super(key, defaultValue, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ import mightypork.utils.config.propmgr.Property;
|
|||||||
*/
|
*/
|
||||||
public class StringProperty extends Property<String> {
|
public class StringProperty extends Property<String> {
|
||||||
|
|
||||||
public StringProperty(String key, String defaultValue) {
|
public StringProperty(String key, String defaultValue)
|
||||||
|
{
|
||||||
super(key, defaultValue);
|
super(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public StringProperty(String key, String defaultValue, String comment) {
|
public StringProperty(String key, String defaultValue, String comment)
|
||||||
|
{
|
||||||
super(key, defaultValue, comment);
|
super(key, defaultValue, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,18 +19,20 @@ import mightypork.utils.config.propmgr.PropertyStore;
|
|||||||
public class PropertyFile implements PropertyStore {
|
public class PropertyFile implements PropertyStore {
|
||||||
|
|
||||||
private String comment;
|
private String comment;
|
||||||
private File file;
|
private final File file;
|
||||||
private SortedProperties props;
|
private final SortedProperties props;
|
||||||
|
|
||||||
|
|
||||||
public PropertyFile(File file) {
|
public PropertyFile(File file)
|
||||||
|
{
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.comment = null;
|
this.comment = null;
|
||||||
this.props = new SortedProperties();
|
this.props = new SortedProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PropertyFile(File file, String comment) {
|
public PropertyFile(File file, String comment)
|
||||||
|
{
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
this.props = new SortedProperties();
|
this.props = new SortedProperties();
|
||||||
@@ -49,9 +51,9 @@ public class PropertyFile implements PropertyStore {
|
|||||||
{
|
{
|
||||||
if (!file.exists()) return;
|
if (!file.exists()) return;
|
||||||
|
|
||||||
try (FileInputStream in = new FileInputStream(file)) {
|
try(FileInputStream in = new FileInputStream(file)) {
|
||||||
props.load(in);
|
props.load(in);
|
||||||
} catch (IOException e) {
|
} catch (final IOException e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -66,7 +68,7 @@ public class PropertyFile implements PropertyStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try (FileOutputStream out = new FileOutputStream(file)) {
|
try(FileOutputStream out = new FileOutputStream(file)) {
|
||||||
props.store(out, comment);
|
props.store(out, comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package mightypork.utils.config.propmgr.store;
|
package mightypork.utils.config.propmgr.store;
|
||||||
|
|
||||||
|
|
||||||
import java.io.*;
|
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.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ final public class EventBus implements Destroyable {
|
|||||||
private final BusEvent<?> evt;
|
private final BusEvent<?> evt;
|
||||||
|
|
||||||
|
|
||||||
public DelayQueueEntry(double seconds, BusEvent<?> event) {
|
public DelayQueueEntry(double seconds, BusEvent<?> event)
|
||||||
|
{
|
||||||
super();
|
super();
|
||||||
this.due = System.currentTimeMillis() + (long) (seconds * 1000);
|
this.due = System.currentTimeMillis() + (long) (seconds * 1000);
|
||||||
this.evt = event;
|
this.evt = event;
|
||||||
@@ -72,7 +73,8 @@ final public class EventBus implements Destroyable {
|
|||||||
public volatile boolean stopped = false;
|
public volatile boolean stopped = false;
|
||||||
|
|
||||||
|
|
||||||
public QueuePollingThread() {
|
public QueuePollingThread()
|
||||||
|
{
|
||||||
super("Queue Polling Thread");
|
super("Queue Polling Thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +135,8 @@ final public class EventBus implements Destroyable {
|
|||||||
/**
|
/**
|
||||||
* Make a new bus and start it's queue thread.
|
* Make a new bus and start it's queue thread.
|
||||||
*/
|
*/
|
||||||
public EventBus() {
|
public EventBus()
|
||||||
|
{
|
||||||
busThread = new QueuePollingThread();
|
busThread = new QueuePollingThread();
|
||||||
busThread.setDaemon(true);
|
busThread.setDaemon(true);
|
||||||
busThread.start();
|
busThread.start();
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ class EventChannel<EVENT extends BusEvent<CLIENT>, CLIENT> {
|
|||||||
* @param eventClass event class
|
* @param eventClass event class
|
||||||
* @param clientClass client class
|
* @param clientClass client class
|
||||||
*/
|
*/
|
||||||
public EventChannel(Class<EVENT> eventClass, Class<CLIENT> clientClass) {
|
public EventChannel(Class<EVENT> eventClass, Class<CLIENT> clientClass)
|
||||||
|
{
|
||||||
|
|
||||||
if (eventClass == null || clientClass == null) {
|
if (eventClass == null || clientClass == null) {
|
||||||
throw new NullPointerException("Null Event or Client class.");
|
throw new NullPointerException("Null Event or Client class.");
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ import java.util.ArrayList;
|
|||||||
*/
|
*/
|
||||||
public class ClientList extends ArrayList<Object> {
|
public class ClientList extends ArrayList<Object> {
|
||||||
|
|
||||||
public ClientList(Object... clients) {
|
public ClientList(Object... clients)
|
||||||
|
{
|
||||||
for (final Object c : clients) {
|
for (final Object c : clients) {
|
||||||
super.add(c);
|
super.add(c);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ public class DelegatingList extends ClientList implements DelegatingClient, Enab
|
|||||||
*
|
*
|
||||||
* @param clients initial list members (clients)
|
* @param clients initial list members (clients)
|
||||||
*/
|
*/
|
||||||
public DelegatingList(Object... clients) {
|
public DelegatingList(Object... clients)
|
||||||
|
{
|
||||||
super(clients);
|
super(clients);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +30,8 @@ public class DelegatingList extends ClientList implements DelegatingClient, Enab
|
|||||||
/**
|
/**
|
||||||
* Empty delegating list.
|
* Empty delegating list.
|
||||||
*/
|
*/
|
||||||
public DelegatingList() {
|
public DelegatingList()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ public class UpdateEvent extends BusEvent<Updateable> {
|
|||||||
/**
|
/**
|
||||||
* @param deltaTime time since last update (sec)
|
* @param deltaTime time since last update (sec)
|
||||||
*/
|
*/
|
||||||
public UpdateEvent(double deltaTime) {
|
public UpdateEvent(double deltaTime)
|
||||||
|
{
|
||||||
this.deltaTime = deltaTime;
|
this.deltaTime = deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package mightypork.utils.eventbus.events.flags;
|
package mightypork.utils.eventbus.events.flags;
|
||||||
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package mightypork.utils.eventbus.events.flags;
|
package mightypork.utils.eventbus.events.flags;
|
||||||
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package mightypork.utils.eventbus.events.flags;
|
package mightypork.utils.eventbus.events.flags;
|
||||||
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package mightypork.utils.eventbus.events.flags;
|
package mightypork.utils.eventbus.events.flags;
|
||||||
|
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,22 +11,26 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class CorruptDataException extends IOException {
|
public class CorruptDataException extends IOException {
|
||||||
|
|
||||||
public CorruptDataException() {
|
public CorruptDataException()
|
||||||
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CorruptDataException(String message, Throwable cause) {
|
public CorruptDataException(String message, Throwable cause)
|
||||||
|
{
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CorruptDataException(String message) {
|
public CorruptDataException(String message)
|
||||||
|
{
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CorruptDataException(Throwable cause) {
|
public CorruptDataException(Throwable cause)
|
||||||
|
{
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,21 +9,25 @@ package mightypork.utils.exceptions;
|
|||||||
*/
|
*/
|
||||||
public class IllegalValueException extends RuntimeException {
|
public class IllegalValueException extends RuntimeException {
|
||||||
|
|
||||||
public IllegalValueException() {
|
public IllegalValueException()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IllegalValueException(String message) {
|
public IllegalValueException(String message)
|
||||||
|
{
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IllegalValueException(Throwable cause) {
|
public IllegalValueException(Throwable cause)
|
||||||
|
{
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IllegalValueException(String message, Throwable cause) {
|
public IllegalValueException(String message, Throwable cause)
|
||||||
|
{
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,22 +8,26 @@ package mightypork.utils.exceptions;
|
|||||||
*/
|
*/
|
||||||
public class KeyAlreadyExistsException extends RuntimeException {
|
public class KeyAlreadyExistsException extends RuntimeException {
|
||||||
|
|
||||||
public KeyAlreadyExistsException() {
|
public KeyAlreadyExistsException()
|
||||||
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public KeyAlreadyExistsException(String message, Throwable cause) {
|
public KeyAlreadyExistsException(String message, Throwable cause)
|
||||||
|
{
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public KeyAlreadyExistsException(String message) {
|
public KeyAlreadyExistsException(String message)
|
||||||
|
{
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public KeyAlreadyExistsException(Throwable cause) {
|
public KeyAlreadyExistsException(Throwable cause)
|
||||||
|
{
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ public class FileSuffixFilter implements FileFilter {
|
|||||||
*
|
*
|
||||||
* @param suffixes var-args allowed suffixes, case insensitive
|
* @param suffixes var-args allowed suffixes, case insensitive
|
||||||
*/
|
*/
|
||||||
public FileSuffixFilter(String... suffixes) {
|
public FileSuffixFilter(String... suffixes)
|
||||||
|
{
|
||||||
this.suffixes = suffixes;
|
this.suffixes = suffixes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,9 +72,11 @@ public class FileTreeDiff {
|
|||||||
ck1.reset();
|
ck1.reset();
|
||||||
ck2.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) {
|
while (true) {
|
||||||
final int read1 = cin1.read(BUFFER);
|
final int read1 = cin1.read(BUFFER);
|
||||||
@@ -128,7 +130,8 @@ public class FileTreeDiff {
|
|||||||
|
|
||||||
private class NotEqualException extends Exception {
|
private class NotEqualException extends Exception {
|
||||||
|
|
||||||
public NotEqualException(String msg) {
|
public NotEqualException(String msg)
|
||||||
|
{
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +143,8 @@ public class FileTreeDiff {
|
|||||||
public T b;
|
public T b;
|
||||||
|
|
||||||
|
|
||||||
public Tuple(T a, T b) {
|
public Tuple(T a, T b)
|
||||||
|
{
|
||||||
this.a = a;
|
this.a = a;
|
||||||
this.b = b;
|
this.b = b;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,19 @@
|
|||||||
package mightypork.utils.files;
|
package mightypork.utils.files;
|
||||||
|
|
||||||
|
|
||||||
import java.io.*;
|
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.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -12,6 +24,7 @@ import mightypork.utils.string.validation.StringFilter;
|
|||||||
|
|
||||||
public class FileUtil {
|
public class FileUtil {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy directory recursively.
|
* Copy directory recursively.
|
||||||
*
|
*
|
||||||
@@ -95,7 +108,8 @@ public class FileUtil {
|
|||||||
public static void copyFile(File source, File target) throws IOException
|
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);
|
copyStream(in, out);
|
||||||
}
|
}
|
||||||
@@ -160,7 +174,7 @@ public class FileUtil {
|
|||||||
*/
|
*/
|
||||||
public static String fileToString(File file) throws IOException
|
public static String fileToString(File file) throws IOException
|
||||||
{
|
{
|
||||||
try (FileInputStream fin = new FileInputStream(file)) {
|
try(FileInputStream fin = new FileInputStream(file)) {
|
||||||
|
|
||||||
return streamToString(fin);
|
return streamToString(fin);
|
||||||
}
|
}
|
||||||
@@ -327,9 +341,8 @@ public class FileUtil {
|
|||||||
if (in != null) return in;
|
if (in != null) return in;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new FileInputStream(new File(".", path));
|
return new FileInputStream(WorkDir.getFile(path));
|
||||||
} catch (final FileNotFoundException e) {
|
} catch (final FileNotFoundException e) {
|
||||||
// error
|
|
||||||
Log.w("Could not open resource stream: " + path);
|
Log.w("Could not open resource stream: " + path);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -339,7 +352,7 @@ public class FileUtil {
|
|||||||
|
|
||||||
public static String getResourceAsString(String path)
|
public static String getResourceAsString(String path)
|
||||||
{
|
{
|
||||||
return streamToString(FileUtil.class.getResourceAsStream(path));
|
return streamToString(getResource(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -352,7 +365,7 @@ public class FileUtil {
|
|||||||
*/
|
*/
|
||||||
public static void stringToFile(File file, String text) throws IOException
|
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);
|
out.print(text);
|
||||||
|
|
||||||
@@ -400,7 +413,8 @@ public class FileUtil {
|
|||||||
*/
|
*/
|
||||||
public static void resourceToFile(String resname, File file) throws IOException
|
public static void resourceToFile(String resname, File file) throws IOException
|
||||||
{
|
{
|
||||||
try (InputStream in = FileUtil.getResource(resname); OutputStream out = new FileOutputStream(file)) {
|
try(InputStream in = FileUtil.getResource(resname);
|
||||||
|
OutputStream out = new FileOutputStream(file)) {
|
||||||
|
|
||||||
FileUtil.copyStream(in, out);
|
FileUtil.copyStream(in, out);
|
||||||
}
|
}
|
||||||
@@ -417,7 +431,7 @@ public class FileUtil {
|
|||||||
*/
|
*/
|
||||||
public static String resourceToString(String resname) throws IOException
|
public static String resourceToString(String resname) throws IOException
|
||||||
{
|
{
|
||||||
try (InputStream in = FileUtil.getResource(resname)) {
|
try(InputStream in = FileUtil.getResource(resname)) {
|
||||||
return streamToString(in);
|
return streamToString(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
package mightypork.utils.files;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import mightypork.utils.logging.Log;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Working directory helper.
|
||||||
|
*
|
||||||
|
* @author Ondřej Hruška (MightyPork)
|
||||||
|
*/
|
||||||
|
public class WorkDir {
|
||||||
|
|
||||||
|
private static File baseDir = new File(".");
|
||||||
|
private static Map<String, String> namedPaths = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the workdir for the given root path
|
||||||
|
*
|
||||||
|
* @param workdir workdir root path
|
||||||
|
*/
|
||||||
|
public static void setBaseDir(File workdir)
|
||||||
|
{
|
||||||
|
WorkDir.baseDir = workdir;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a path alias (dir or file), relative to the workdir.
|
||||||
|
*
|
||||||
|
* @param alias path alias
|
||||||
|
* @param path path relative to workdir
|
||||||
|
*/
|
||||||
|
public static void addPath(String alias, String path)
|
||||||
|
{
|
||||||
|
namedPaths.put(alias, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get workdir folder, create if not exists.
|
||||||
|
*
|
||||||
|
* @param path dir path relative to workdir
|
||||||
|
* @return dir file
|
||||||
|
*/
|
||||||
|
public static File getDir(String path)
|
||||||
|
{
|
||||||
|
if (namedPaths.containsKey(path)) path = namedPaths.get(path);
|
||||||
|
|
||||||
|
final File f = new File(baseDir, path);
|
||||||
|
if (!f.exists()) {
|
||||||
|
if (!f.mkdirs()) {
|
||||||
|
Log.w("Could not create a directory: " + f + " (path: " + path + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get workdir file, create parent if not exists.
|
||||||
|
*
|
||||||
|
* @param path dir path relative to workdir
|
||||||
|
* @return dir file
|
||||||
|
*/
|
||||||
|
public static File getFile(String path)
|
||||||
|
{
|
||||||
|
if (namedPaths.containsKey(path)) path = namedPaths.get(path);
|
||||||
|
|
||||||
|
final File f = new File(baseDir, path);
|
||||||
|
|
||||||
|
// create the parent dir
|
||||||
|
if (!f.getParent().equals(baseDir)) {
|
||||||
|
f.getParentFile().mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
return f;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the workdir File
|
||||||
|
*/
|
||||||
|
public static File getBaseDir()
|
||||||
|
{
|
||||||
|
return baseDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,7 +29,8 @@ public class ZipBuilder {
|
|||||||
* @param target target zip file
|
* @param target target zip file
|
||||||
* @throws IOException if the file is directory or cannot be created
|
* @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.");
|
if (!target.getParentFile().mkdirs()) throw new IOException("Could not create output directory.");
|
||||||
|
|
||||||
@@ -75,7 +76,7 @@ public class ZipBuilder {
|
|||||||
|
|
||||||
out.putNextEntry(new ZipEntry(path));
|
out.putNextEntry(new ZipEntry(path));
|
||||||
|
|
||||||
try (InputStream in = FileUtil.stringToStream(text)) {
|
try(InputStream in = FileUtil.stringToStream(text)) {
|
||||||
FileUtil.copyStream(in, out);
|
FileUtil.copyStream(in, out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +97,7 @@ public class ZipBuilder {
|
|||||||
|
|
||||||
out.putNextEntry(new ZipEntry(path));
|
out.putNextEntry(new ZipEntry(path));
|
||||||
|
|
||||||
try (InputStream in = FileUtil.getResource(resPath)) {
|
try(InputStream in = FileUtil.getResource(resPath)) {
|
||||||
FileUtil.copyStream(in, out);
|
FileUtil.copyStream(in, out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package mightypork.utils.files.zip;
|
package mightypork.utils.files.zip;
|
||||||
|
|
||||||
|
|
||||||
import java.io.*;
|
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.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -34,7 +39,7 @@ public class ZipUtils {
|
|||||||
*/
|
*/
|
||||||
public static List<String> extractZip(File file, File outputDir, StringFilter filter) throws IOException
|
public static List<String> 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);
|
return extractZip(zip, outputDir, filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +95,7 @@ public class ZipUtils {
|
|||||||
*/
|
*/
|
||||||
public static List<String> listZip(File zipFile) throws IOException
|
public static List<String> listZip(File zipFile) throws IOException
|
||||||
{
|
{
|
||||||
try (ZipFile zip = new ZipFile(zipFile)) {
|
try(ZipFile zip = new ZipFile(zipFile)) {
|
||||||
return listZip(zip);
|
return listZip(zip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,7 +139,10 @@ public class ZipUtils {
|
|||||||
{
|
{
|
||||||
if (!destFile.getParentFile().mkdirs()) throw new IOException("Could not create output directory.");
|
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)) {
|
||||||
|
|
||||||
FileUtil.copyStream(is, dest);
|
FileUtil.copyStream(is, dest);
|
||||||
}
|
}
|
||||||
@@ -168,7 +176,7 @@ public class ZipUtils {
|
|||||||
|
|
||||||
public static boolean entryExists(File selectedFile, String string)
|
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;
|
return zf.getEntry(string) != null;
|
||||||
} catch (final IOException | RuntimeException e) {
|
} catch (final IOException | RuntimeException e) {
|
||||||
Log.w("Error reading zip.", e);
|
Log.w("Error reading zip.", e);
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package mightypork.utils.ion;
|
package mightypork.utils.ion;
|
||||||
|
|
||||||
|
|
||||||
import java.io.*;
|
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.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -237,7 +242,7 @@ public class Ion {
|
|||||||
*/
|
*/
|
||||||
public static <T> T fromFile(File file) throws IOException
|
public static <T> T fromFile(File file) throws IOException
|
||||||
{
|
{
|
||||||
try (InputStream in = new FileInputStream(file)) {
|
try(InputStream in = new FileInputStream(file)) {
|
||||||
return fromStream(in);
|
return fromStream(in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,7 +262,7 @@ public class Ion {
|
|||||||
*/
|
*/
|
||||||
public static void toFile(File file, Object obj) throws IOException
|
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);
|
toStream(out, obj);
|
||||||
|
|
||||||
@@ -273,7 +278,7 @@ public class Ion {
|
|||||||
*/
|
*/
|
||||||
public static <T> T fromStream(InputStream in) throws IOException
|
public static <T> T fromStream(InputStream in) throws IOException
|
||||||
{
|
{
|
||||||
try (final IonInput inp = new IonInput(in)) {
|
try(final IonInput inp = new IonInput(in)) {
|
||||||
return (T) inp.readObject();
|
return (T) inp.readObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,7 +289,7 @@ public class Ion {
|
|||||||
*/
|
*/
|
||||||
public static void toStream(OutputStream out, Object obj) throws IOException
|
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);
|
iout.writeObject(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
package mightypork.utils.ion;
|
package mightypork.utils.ion;
|
||||||
|
|
||||||
|
|
||||||
import java.io.*;
|
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.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -22,12 +29,14 @@ public class IonInput implements Closeable {
|
|||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
public IonInput(File inFile) throws FileNotFoundException {
|
public IonInput(File inFile) throws FileNotFoundException
|
||||||
|
{
|
||||||
this(new FileInputStream(inFile));
|
this(new FileInputStream(inFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IonInput(InputStream in) {
|
public IonInput(InputStream in)
|
||||||
|
{
|
||||||
this.stream = in;
|
this.stream = in;
|
||||||
this.in = new DataInputStream(in);
|
this.in = new DataInputStream(in);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ class IonMapWrapper implements IonBinary {
|
|||||||
private final Map map;
|
private final Map map;
|
||||||
|
|
||||||
|
|
||||||
public IonMapWrapper() {
|
public IonMapWrapper()
|
||||||
|
{
|
||||||
map = new LinkedHashMap<>();
|
map = new LinkedHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IonMapWrapper(Map saved) {
|
public IonMapWrapper(Map saved)
|
||||||
|
{
|
||||||
map = saved;
|
map = saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
package mightypork.utils.ion;
|
package mightypork.utils.ion;
|
||||||
|
|
||||||
|
|
||||||
import java.io.*;
|
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.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@@ -19,12 +26,14 @@ public class IonOutput implements Closeable {
|
|||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
public IonOutput(File outFile) throws FileNotFoundException {
|
public IonOutput(File outFile) throws FileNotFoundException
|
||||||
|
{
|
||||||
this(new FileOutputStream(outFile));
|
this(new FileOutputStream(outFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IonOutput(OutputStream out) {
|
public IonOutput(OutputStream out)
|
||||||
|
{
|
||||||
this.stream = out;
|
this.stream = out;
|
||||||
this.out = new DataOutputStream(out);
|
this.out = new DataOutputStream(out);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ class IonSequenceWrapper implements IonBinary {
|
|||||||
private Collection collection = new ArrayList();
|
private Collection collection = new ArrayList();
|
||||||
|
|
||||||
|
|
||||||
public IonSequenceWrapper() {
|
public IonSequenceWrapper()
|
||||||
|
{
|
||||||
collection = new ArrayList();
|
collection = new ArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IonSequenceWrapper(Collection saved) {
|
public IonSequenceWrapper(Collection saved)
|
||||||
|
{
|
||||||
collection = saved;
|
collection = saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ public class ArchivingLog extends SimpleLog {
|
|||||||
* @param file log file (in log directory)
|
* @param file log file (in log directory)
|
||||||
* @param oldLogCount number of old log files to keep: -1 all, 0 none.
|
* @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);
|
super(name, file);
|
||||||
this.logs_to_keep = oldLogCount;
|
this.logs_to_keep = oldLogCount;
|
||||||
}
|
}
|
||||||
@@ -44,7 +45,8 @@ public class ArchivingLog extends SimpleLog {
|
|||||||
* @param name log name
|
* @param name log name
|
||||||
* @param file log file (in log directory)
|
* @param file log file (in log directory)
|
||||||
*/
|
*/
|
||||||
public ArchivingLog(String name, File file) {
|
public ArchivingLog(String name, File file)
|
||||||
|
{
|
||||||
super(name, file);
|
super(name, file);
|
||||||
this.logs_to_keep = 5;
|
this.logs_to_keep = 5;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ public class SimpleLog implements LogWriter {
|
|||||||
private final long started_ms;
|
private final long started_ms;
|
||||||
|
|
||||||
|
|
||||||
public SimpleLog(String name, File file) {
|
public SimpleLog(String name, File file)
|
||||||
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.started_ms = System.currentTimeMillis();
|
this.started_ms = System.currentTimeMillis();
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ import mightypork.utils.math.constraints.vect.Vect;
|
|||||||
*/
|
*/
|
||||||
public final class Calc {
|
public final class Calc {
|
||||||
|
|
||||||
private Calc() {
|
private Calc()
|
||||||
|
{
|
||||||
// not instantiable
|
// not instantiable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ public class Polar {
|
|||||||
* @param angle angle in RAD
|
* @param angle angle in RAD
|
||||||
* @param distance distance from origin
|
* @param distance distance from origin
|
||||||
*/
|
*/
|
||||||
public Polar(double angle, double distance) {
|
public Polar(double angle, double distance)
|
||||||
|
{
|
||||||
this(angle, false, distance);
|
this(angle, false, distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,7 +39,8 @@ public class Polar {
|
|||||||
* @param deg angle is in DEG
|
* @param deg angle is in DEG
|
||||||
* @param distance radius
|
* @param distance radius
|
||||||
*/
|
*/
|
||||||
public Polar(double angle, boolean deg, double distance) {
|
public Polar(double angle, boolean deg, double distance)
|
||||||
|
{
|
||||||
this.radius = distance;
|
this.radius = distance;
|
||||||
this.angle = deg ? Math.toRadians(angle) : angle;
|
this.angle = deg ? Math.toRadians(angle) : angle;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ public class Range {
|
|||||||
/**
|
/**
|
||||||
* Implicit range constructor 0-1
|
* Implicit range constructor 0-1
|
||||||
*/
|
*/
|
||||||
public Range() {
|
public Range()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +34,8 @@ public class Range {
|
|||||||
* @param min min number
|
* @param min min number
|
||||||
* @param max max number
|
* @param max max number
|
||||||
*/
|
*/
|
||||||
public Range(double min, double max) {
|
public Range(double min, double max)
|
||||||
|
{
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
norm();
|
norm();
|
||||||
@@ -45,7 +47,8 @@ public class Range {
|
|||||||
*
|
*
|
||||||
* @param minmax min = max number
|
* @param minmax min = max number
|
||||||
*/
|
*/
|
||||||
public Range(double minmax) {
|
public Range(double minmax)
|
||||||
|
{
|
||||||
this.min = minmax;
|
this.min = minmax;
|
||||||
this.max = minmax;
|
this.max = minmax;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,19 +39,22 @@ public class Coord {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Coord() {
|
public Coord()
|
||||||
|
{
|
||||||
// for ion
|
// for ion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Coord(int x, int y) {
|
public Coord(int x, int y)
|
||||||
|
{
|
||||||
super();
|
super();
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Coord(Coord other) {
|
public Coord(Coord other)
|
||||||
|
{
|
||||||
this.x = other.x;
|
this.x = other.x;
|
||||||
this.y = other.y;
|
this.y = other.y;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,8 @@ public class Move {
|
|||||||
private final byte y;
|
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.x = (byte) (x < 0 ? -1 : x > 0 ? 1 : 0);
|
||||||
this.y = (byte) (y < 0 ? -1 : y > 0 ? 1 : 0);
|
this.y = (byte) (y < 0 ? -1 : y > 0 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,22 +45,22 @@ public class Moves {
|
|||||||
//@formatter:off
|
//@formatter:off
|
||||||
/** All sides, in the order of bits. */
|
/** All sides, in the order of bits. */
|
||||||
public final static List<Move> ALL_SIDES = Collections.unmodifiableList(Arrays.asList(
|
public final static List<Move> ALL_SIDES = Collections.unmodifiableList(Arrays.asList(
|
||||||
NW,
|
NW,
|
||||||
N,
|
N,
|
||||||
NE,
|
NE,
|
||||||
E,
|
E,
|
||||||
SE,
|
SE,
|
||||||
S,
|
S,
|
||||||
SW,
|
SW,
|
||||||
W
|
W
|
||||||
));
|
));
|
||||||
|
|
||||||
public final static List<Move> CARDINAL_SIDES = Collections.unmodifiableList(Arrays.asList(
|
public final static List<Move> CARDINAL_SIDES = Collections.unmodifiableList(Arrays.asList(
|
||||||
N,
|
N,
|
||||||
E,
|
E,
|
||||||
S,
|
S,
|
||||||
W
|
W
|
||||||
));
|
));
|
||||||
|
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,8 @@ public abstract class PathFinder {
|
|||||||
Node parent;
|
Node parent;
|
||||||
|
|
||||||
|
|
||||||
public Node(Coord pos) {
|
public Node(Coord pos)
|
||||||
|
{
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ public class PathFinderProxy extends PathFinder {
|
|||||||
private final PathFinder source;
|
private final PathFinder source;
|
||||||
|
|
||||||
|
|
||||||
public PathFinderProxy(PathFinder other) {
|
public PathFinderProxy(PathFinder other)
|
||||||
|
{
|
||||||
this.source = other;
|
this.source = other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,22 +17,26 @@ public abstract class Animator implements NumBound, Updateable, Pauseable {
|
|||||||
private final double lowValue;
|
private final double lowValue;
|
||||||
|
|
||||||
|
|
||||||
public Animator(double period) {
|
public Animator(double period)
|
||||||
|
{
|
||||||
this(0, 1, period, Easing.LINEAR);
|
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);
|
this(start, end, period, Easing.LINEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Animator(double period, Easing easing) {
|
public Animator(double period, Easing easing)
|
||||||
|
{
|
||||||
this(0, 1, period, 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 = new NumAnimated(0, easing);
|
||||||
numAnim.setDefaultDuration(period);
|
numAnim.setDefaultDuration(period);
|
||||||
|
|
||||||
|
|||||||
@@ -11,22 +11,26 @@ public class AnimatorBounce extends Animator {
|
|||||||
private boolean wasUp = false;
|
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);
|
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);
|
super(start, end, period);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AnimatorBounce(double period, Easing easing) {
|
public AnimatorBounce(double period, Easing easing)
|
||||||
|
{
|
||||||
super(period, easing);
|
super(period, easing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AnimatorBounce(double period) {
|
public AnimatorBounce(double period)
|
||||||
|
{
|
||||||
super(period);
|
super(period);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,22 +9,26 @@ package mightypork.utils.math.animation;
|
|||||||
*/
|
*/
|
||||||
public class AnimatorRewind extends Animator {
|
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);
|
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);
|
super(start, end, period);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AnimatorRewind(double period, Easing easing) {
|
public AnimatorRewind(double period, Easing easing)
|
||||||
|
{
|
||||||
super(period, easing);
|
super(period, easing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AnimatorRewind(double period) {
|
public AnimatorRewind(double period)
|
||||||
|
{
|
||||||
super(period);
|
super(period);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ public abstract class Easing {
|
|||||||
/**
|
/**
|
||||||
* @param in Easing to reverse
|
* @param in Easing to reverse
|
||||||
*/
|
*/
|
||||||
public Reverse(Easing in) {
|
public Reverse(Easing in)
|
||||||
|
{
|
||||||
this.ea = in;
|
this.ea = in;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +97,8 @@ public abstract class Easing {
|
|||||||
* @param in initial EasingFunction
|
* @param in initial EasingFunction
|
||||||
* @param out terminal EasingFunction
|
* @param out terminal EasingFunction
|
||||||
*/
|
*/
|
||||||
public Composite(Easing in, Easing out) {
|
public Composite(Easing in, Easing out)
|
||||||
|
{
|
||||||
this.in = in;
|
this.in = in;
|
||||||
this.out = out;
|
this.out = out;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
|
|||||||
*
|
*
|
||||||
* @param value initial value
|
* @param value initial value
|
||||||
*/
|
*/
|
||||||
public NumAnimated(double value) {
|
public NumAnimated(double value)
|
||||||
|
{
|
||||||
setTo(value);
|
setTo(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,7 +57,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
|
|||||||
* @param value initial value
|
* @param value initial value
|
||||||
* @param easing easing function
|
* @param easing easing function
|
||||||
*/
|
*/
|
||||||
public NumAnimated(double value, Easing easing) {
|
public NumAnimated(double value, Easing easing)
|
||||||
|
{
|
||||||
this(value);
|
this(value);
|
||||||
setEasing(easing);
|
setEasing(easing);
|
||||||
}
|
}
|
||||||
@@ -69,7 +71,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
|
|||||||
* @param easingIn easing function (fade in)
|
* @param easingIn easing function (fade in)
|
||||||
* @param easingOut easing function (fade out)
|
* @param easingOut easing function (fade out)
|
||||||
*/
|
*/
|
||||||
public NumAnimated(double value, Easing easingIn, Easing easingOut) {
|
public NumAnimated(double value, Easing easingIn, Easing easingOut)
|
||||||
|
{
|
||||||
this(value);
|
this(value);
|
||||||
setEasing(easingIn, easingOut);
|
setEasing(easingIn, easingOut);
|
||||||
}
|
}
|
||||||
@@ -82,7 +85,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
|
|||||||
* @param easing easing function
|
* @param easing easing function
|
||||||
* @param defaultDuration default fade duration
|
* @param defaultDuration default fade duration
|
||||||
*/
|
*/
|
||||||
public NumAnimated(double value, Easing easing, double defaultDuration) {
|
public NumAnimated(double value, Easing easing, double defaultDuration)
|
||||||
|
{
|
||||||
this(value);
|
this(value);
|
||||||
setEasing(easing);
|
setEasing(easing);
|
||||||
setDefaultDuration(defaultDuration);
|
setDefaultDuration(defaultDuration);
|
||||||
@@ -97,7 +101,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
|
|||||||
* @param easingOut easing function (fade out)
|
* @param easingOut easing function (fade out)
|
||||||
* @param defaultDuration default fade duration
|
* @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);
|
this(value);
|
||||||
setEasing(easingIn, easingOut);
|
setEasing(easingIn, easingOut);
|
||||||
setDefaultDuration(defaultDuration);
|
setDefaultDuration(defaultDuration);
|
||||||
@@ -109,7 +114,8 @@ public class NumAnimated extends NumMutable implements Updateable, Pauseable {
|
|||||||
*
|
*
|
||||||
* @param other other animator
|
* @param other other animator
|
||||||
*/
|
*/
|
||||||
public NumAnimated(NumAnimated other) {
|
public NumAnimated(NumAnimated other)
|
||||||
|
{
|
||||||
setTo(other);
|
setTo(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,17 +12,20 @@ import mightypork.utils.math.angles.Deg;
|
|||||||
*/
|
*/
|
||||||
public class NumAnimatedDeg extends NumAnimated {
|
public class NumAnimatedDeg extends NumAnimated {
|
||||||
|
|
||||||
public NumAnimatedDeg(NumAnimated other) {
|
public NumAnimatedDeg(NumAnimated other)
|
||||||
|
{
|
||||||
super(other);
|
super(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public NumAnimatedDeg(double value) {
|
public NumAnimatedDeg(double value)
|
||||||
|
{
|
||||||
super(value);
|
super(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public NumAnimatedDeg(double value, Easing easing) {
|
public NumAnimatedDeg(double value, Easing easing)
|
||||||
|
{
|
||||||
super(value, easing);
|
super(value, easing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,17 +12,20 @@ import mightypork.utils.math.angles.Rad;
|
|||||||
*/
|
*/
|
||||||
public class NumAnimatedRad extends NumAnimated {
|
public class NumAnimatedRad extends NumAnimated {
|
||||||
|
|
||||||
public NumAnimatedRad(NumAnimated other) {
|
public NumAnimatedRad(NumAnimated other)
|
||||||
|
{
|
||||||
super(other);
|
super(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public NumAnimatedRad(double value) {
|
public NumAnimatedRad(double value)
|
||||||
|
{
|
||||||
super(value);
|
super(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public NumAnimatedRad(double value, Easing easing) {
|
public NumAnimatedRad(double value, Easing easing)
|
||||||
|
{
|
||||||
super(value, easing);
|
super(value, easing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ public class VectAnimated extends VectMutable implements Pauseable, Updateable {
|
|||||||
* @param y y animator
|
* @param y y animator
|
||||||
* @param z z 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.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
@@ -40,7 +41,8 @@ public class VectAnimated extends VectMutable implements Pauseable, Updateable {
|
|||||||
* @param start initial positioon
|
* @param start initial positioon
|
||||||
* @param easing animation easing
|
* @param easing animation easing
|
||||||
*/
|
*/
|
||||||
public VectAnimated(Vect start, Easing easing) {
|
public VectAnimated(Vect start, Easing easing)
|
||||||
|
{
|
||||||
x = new NumAnimated(start.x(), easing);
|
x = new NumAnimated(start.x(), easing);
|
||||||
y = new NumAnimated(start.y(), easing);
|
y = new NumAnimated(start.y(), easing);
|
||||||
z = new NumAnimated(start.z(), easing);
|
z = new NumAnimated(start.z(), easing);
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ public abstract class Color {
|
|||||||
if (this == obj) return true;
|
if (this == obj) return true;
|
||||||
if (obj == null) return false;
|
if (obj == null) return false;
|
||||||
if (!(obj instanceof Color)) return false;
|
if (!(obj instanceof Color)) return false;
|
||||||
Color other = (Color) obj;
|
final Color other = (Color) obj;
|
||||||
if (Double.doubleToLongBits(b()) != Double.doubleToLongBits(other.b())) return false;
|
if (Double.doubleToLongBits(b()) != Double.doubleToLongBits(other.b())) return false;
|
||||||
if (Double.doubleToLongBits(g()) != Double.doubleToLongBits(other.g())) return false;
|
if (Double.doubleToLongBits(g()) != Double.doubleToLongBits(other.g())) return false;
|
||||||
if (Double.doubleToLongBits(r()) != Double.doubleToLongBits(other.r())) return false;
|
if (Double.doubleToLongBits(r()) != Double.doubleToLongBits(other.r())) return false;
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ public class ColorAlphaAdjuster extends Color {
|
|||||||
private final Num alphaAdjust;
|
private final Num alphaAdjust;
|
||||||
|
|
||||||
|
|
||||||
public ColorAlphaAdjuster(Color source, Num alphaMul) {
|
public ColorAlphaAdjuster(Color source, Num alphaMul)
|
||||||
|
{
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this.alphaAdjust = alphaMul;
|
this.alphaAdjust = alphaMul;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ public class ColorHsb extends Color {
|
|||||||
private final Num a;
|
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.h = h;
|
||||||
this.s = s;
|
this.s = s;
|
||||||
this.b = b;
|
this.b = b;
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ public class ColorRgb extends Color {
|
|||||||
private final Num a;
|
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.r = r;
|
||||||
this.g = g;
|
this.g = g;
|
||||||
this.b = b;
|
this.b = b;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package mightypork.utils.math.color;
|
package mightypork.utils.math.color;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Linear gradient (each corner can have different color)
|
* Linear gradient (each corner can have different color)
|
||||||
*
|
*
|
||||||
@@ -21,7 +19,8 @@ public class Grad {
|
|||||||
* @param rightBottom right bottom color
|
* @param rightBottom right bottom color
|
||||||
* @param leftBottom left bottom color
|
* @param leftBottom left bottom color
|
||||||
*/
|
*/
|
||||||
public Grad(Color leftTop, Color rightTop, Color rightBottom, Color leftBottom) {
|
public Grad(Color leftTop, Color rightTop, Color rightBottom, Color leftBottom)
|
||||||
|
{
|
||||||
this.leftTop = leftTop;
|
this.leftTop = leftTop;
|
||||||
this.rightTop = rightTop;
|
this.rightTop = rightTop;
|
||||||
this.rightBottom = rightBottom;
|
this.rightBottom = rightBottom;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package mightypork.utils.math.color;
|
package mightypork.utils.math.color;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Linear horizontal gradient
|
* Linear horizontal gradient
|
||||||
*
|
*
|
||||||
@@ -10,7 +8,8 @@ package mightypork.utils.math.color;
|
|||||||
*/
|
*/
|
||||||
public class GradH extends Grad {
|
public class GradH extends Grad {
|
||||||
|
|
||||||
public GradH(Color left, Color right) {
|
public GradH(Color left, Color right)
|
||||||
|
{
|
||||||
super(left, right, right, left);
|
super(left, right, right, left);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package mightypork.utils.math.color;
|
package mightypork.utils.math.color;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Linear vertical gradient
|
* Linear vertical gradient
|
||||||
*
|
*
|
||||||
@@ -10,7 +8,8 @@ package mightypork.utils.math.color;
|
|||||||
*/
|
*/
|
||||||
public class GradV extends Grad {
|
public class GradV extends Grad {
|
||||||
|
|
||||||
public GradV(Color top, Color bottom) {
|
public GradV(Color top, Color bottom)
|
||||||
|
{
|
||||||
super(top, top, bottom, bottom);
|
super(top, top, bottom, bottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,14 @@ public class NumConst extends Num {
|
|||||||
private NumDigest digest;
|
private NumDigest digest;
|
||||||
|
|
||||||
|
|
||||||
NumConst(Num copied) {
|
NumConst(Num copied)
|
||||||
|
{
|
||||||
this.value = copied.value();
|
this.value = copied.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NumConst(double value) {
|
NumConst(double value)
|
||||||
|
{
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ public abstract class AbstractNumCache extends NumAdapter implements CachedConst
|
|||||||
private boolean cachingEnabled = true;
|
private boolean cachingEnabled = true;
|
||||||
|
|
||||||
|
|
||||||
public AbstractNumCache() {
|
public AbstractNumCache()
|
||||||
|
{
|
||||||
enableDigestCaching(true); // it changes only on poll
|
enableDigestCaching(true); // it changes only on poll
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ public class NumCache extends AbstractNumCache {
|
|||||||
private final Num source;
|
private final Num source;
|
||||||
|
|
||||||
|
|
||||||
public NumCache(Num source) {
|
public NumCache(Num source)
|
||||||
|
{
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ public class NumDigest {
|
|||||||
public final double value;
|
public final double value;
|
||||||
|
|
||||||
|
|
||||||
public NumDigest(Num num) {
|
public NumDigest(Num num)
|
||||||
|
{
|
||||||
this.value = num.value();
|
this.value = num.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ public class NumProxy extends NumAdapter implements PluggableNumBound {
|
|||||||
private NumBound backing = null;
|
private NumBound backing = null;
|
||||||
|
|
||||||
|
|
||||||
public NumProxy() {
|
public NumProxy()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public NumProxy(NumBound bound) {
|
public NumProxy(NumBound bound)
|
||||||
|
{
|
||||||
backing = bound;
|
backing = bound;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,14 @@ public class NumVar extends NumMutable {
|
|||||||
private double value;
|
private double value;
|
||||||
|
|
||||||
|
|
||||||
public NumVar(Num value) {
|
public NumVar(Num value)
|
||||||
|
{
|
||||||
this(value.value());
|
this(value.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public NumVar(double value) {
|
public NumVar(double value)
|
||||||
|
{
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,8 @@ public class RectConst extends Rect {
|
|||||||
* @param width
|
* @param width
|
||||||
* @param height
|
* @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.pos = Vect.make(x, y);
|
||||||
this.size = Vect.make(width, height);
|
this.size = Vect.make(width, height);
|
||||||
}
|
}
|
||||||
@@ -62,7 +63,8 @@ public class RectConst extends Rect {
|
|||||||
* @param origin
|
* @param origin
|
||||||
* @param size
|
* @param size
|
||||||
*/
|
*/
|
||||||
RectConst(Vect origin, Vect size) {
|
RectConst(Vect origin, Vect size)
|
||||||
|
{
|
||||||
this.pos = origin.freeze();
|
this.pos = origin.freeze();
|
||||||
this.size = size.freeze();
|
this.size = size.freeze();
|
||||||
}
|
}
|
||||||
@@ -73,7 +75,8 @@ public class RectConst extends Rect {
|
|||||||
*
|
*
|
||||||
* @param another other coord
|
* @param another other coord
|
||||||
*/
|
*/
|
||||||
RectConst(Rect another) {
|
RectConst(Rect another)
|
||||||
|
{
|
||||||
this.pos = another.origin().freeze();
|
this.pos = another.origin().freeze();
|
||||||
this.size = another.size().freeze();
|
this.size = another.size().freeze();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ public class TiledRect extends RectProxy {
|
|||||||
private Rect aTile;
|
private Rect aTile;
|
||||||
|
|
||||||
|
|
||||||
public TiledRect(Rect source, int horizontal, int vertical) {
|
public TiledRect(Rect source, int horizontal, int vertical)
|
||||||
|
{
|
||||||
super(source);
|
super(source);
|
||||||
this.tilesX = horizontal;
|
this.tilesX = horizontal;
|
||||||
this.tilesY = vertical;
|
this.tilesY = vertical;
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ public abstract class AbstractRectCache extends RectAdapter implements CachedCon
|
|||||||
private boolean cachingEnabled = true;
|
private boolean cachingEnabled = true;
|
||||||
|
|
||||||
|
|
||||||
public AbstractRectCache() {
|
public AbstractRectCache()
|
||||||
|
{
|
||||||
enableDigestCaching(true); // it changes only on poll
|
enableDigestCaching(true); // it changes only on poll
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ public class RectCache extends AbstractRectCache {
|
|||||||
private final Rect source;
|
private final Rect source;
|
||||||
|
|
||||||
|
|
||||||
public RectCache(Rect source) {
|
public RectCache(Rect source)
|
||||||
|
{
|
||||||
this.source = source;
|
this.source = source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ public class RectDigest {
|
|||||||
public final double bottom;
|
public final double bottom;
|
||||||
|
|
||||||
|
|
||||||
public RectDigest(Rect rect) {
|
public RectDigest(Rect rect)
|
||||||
|
{
|
||||||
this.x = rect.origin().x();
|
this.x = rect.origin().x();
|
||||||
this.y = rect.origin().y();
|
this.y = rect.origin().y();
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ public class RectDigest {
|
|||||||
@Override
|
@Override
|
||||||
public String toString()
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ public class RectProxy extends RectAdapter implements PluggableRectBound {
|
|||||||
private RectBound backing = null;
|
private RectBound backing = null;
|
||||||
|
|
||||||
|
|
||||||
public RectProxy() {
|
public RectProxy()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public RectProxy(RectBound proxied) {
|
public RectProxy(RectBound proxied)
|
||||||
|
{
|
||||||
backing = proxied;
|
backing = proxied;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ public class RectVectAdapter extends Rect {
|
|||||||
private final Vect size;
|
private final Vect size;
|
||||||
|
|
||||||
|
|
||||||
public RectVectAdapter(Vect origin, Vect size) {
|
public RectVectAdapter(Vect origin, Vect size)
|
||||||
|
{
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ public class RectVar extends RectMutable {
|
|||||||
* @param width
|
* @param width
|
||||||
* @param height
|
* @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.pos.setTo(x, y);
|
||||||
this.size.setTo(width, height);
|
this.size.setTo(width, height);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,12 +32,14 @@ public final class VectConst extends Vect {
|
|||||||
private VectDigest digest;
|
private VectDigest digest;
|
||||||
|
|
||||||
|
|
||||||
VectConst(Vect other) {
|
VectConst(Vect other)
|
||||||
|
{
|
||||||
this(other.x(), other.y(), other.z());
|
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.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ public abstract class AbstractVectCache extends VectAdapter implements CachedCon
|
|||||||
private boolean cachingEnabled = true;
|
private boolean cachingEnabled = true;
|
||||||
|
|
||||||
|
|
||||||
public AbstractVectCache() {
|
public AbstractVectCache()
|
||||||
|
{
|
||||||
enableDigestCaching(true); // it changes only on poll
|
enableDigestCaching(true); // it changes only on poll
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ public class VectCache extends AbstractVectCache {
|
|||||||
private final Vect source;
|
private final Vect source;
|
||||||
|
|
||||||
|
|
||||||
public VectCache(Vect source) {
|
public VectCache(Vect source)
|
||||||
|
{
|
||||||
this.source = source;
|
this.source = source;
|
||||||
enableDigestCaching(true);
|
enableDigestCaching(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ public class VectDigest {
|
|||||||
public final double z;
|
public final double z;
|
||||||
|
|
||||||
|
|
||||||
public VectDigest(Vect vect) {
|
public VectDigest(Vect vect)
|
||||||
|
{
|
||||||
this.x = vect.x();
|
this.x = vect.x();
|
||||||
this.y = vect.y();
|
this.y = vect.y();
|
||||||
this.z = vect.z();
|
this.z = vect.z();
|
||||||
|
|||||||
@@ -18,14 +18,16 @@ public class VectNumAdapter extends Vect {
|
|||||||
private final Num constrZ;
|
private final Num constrZ;
|
||||||
|
|
||||||
|
|
||||||
public VectNumAdapter(Num x, Num y, Num z) {
|
public VectNumAdapter(Num x, Num y, Num z)
|
||||||
|
{
|
||||||
this.constrX = x;
|
this.constrX = x;
|
||||||
this.constrY = y;
|
this.constrY = y;
|
||||||
this.constrZ = z;
|
this.constrZ = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public VectNumAdapter(Num x, Num y) {
|
public VectNumAdapter(Num x, Num y)
|
||||||
|
{
|
||||||
this.constrX = x;
|
this.constrX = x;
|
||||||
this.constrY = y;
|
this.constrY = y;
|
||||||
this.constrZ = Num.ZERO;
|
this.constrZ = Num.ZERO;
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ public class VectProxy extends VectAdapter implements PluggableVectBound {
|
|||||||
private VectBound backing = null;
|
private VectBound backing = null;
|
||||||
|
|
||||||
|
|
||||||
public VectProxy() {
|
public VectProxy()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public VectProxy(VectBound proxied) {
|
public VectProxy(VectBound proxied)
|
||||||
|
{
|
||||||
backing = proxied;
|
backing = proxied;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ public class VectVar extends VectMutable {
|
|||||||
* @param y Y coordinate
|
* @param y Y coordinate
|
||||||
* @param z Z coordinate
|
* @param z Z coordinate
|
||||||
*/
|
*/
|
||||||
public VectVar(double x, double y, double z) {
|
public VectVar(double x, double y, double z)
|
||||||
|
{
|
||||||
super();
|
super();
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ public class NoiseGen {
|
|||||||
* @param middle middle bound ("surface")
|
* @param middle middle bound ("surface")
|
||||||
* @param high high bound ("hill")
|
* @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()));
|
this(density, low, middle, high, Double.doubleToLongBits(Math.random()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +42,8 @@ public class NoiseGen {
|
|||||||
* @param high high bound ("hill")
|
* @param high high bound ("hill")
|
||||||
* @param seed random seed to use
|
* @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.");
|
if (low > middle || middle > high) throw new IllegalArgumentException("Invalid value range.");
|
||||||
|
|
||||||
this.density = density;
|
this.density = density;
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ public class PerlinNoiseGenerator {
|
|||||||
/**
|
/**
|
||||||
* Create a new noise creator with the default seed value
|
* Create a new noise creator with the default seed value
|
||||||
*/
|
*/
|
||||||
public PerlinNoiseGenerator() {
|
public PerlinNoiseGenerator()
|
||||||
|
{
|
||||||
this(DEFAULT_SEED);
|
this(DEFAULT_SEED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +71,8 @@ public class PerlinNoiseGenerator {
|
|||||||
*
|
*
|
||||||
* @param seed The seed value to use
|
* @param seed The seed value to use
|
||||||
*/
|
*/
|
||||||
public PerlinNoiseGenerator(long seed) {
|
public PerlinNoiseGenerator(long seed)
|
||||||
|
{
|
||||||
p_imp = new int[DEFAULT_SAMPLE_SIZE << 1];
|
p_imp = new int[DEFAULT_SAMPLE_SIZE << 1];
|
||||||
|
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
@@ -291,8 +293,8 @@ public class PerlinNoiseGenerator {
|
|||||||
* set the colour to be:
|
* set the colour to be:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* sin(point + turbulence(point) * point.x);
|
* sin(point + turbulence(point) * point.x);
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
@@ -408,7 +410,10 @@ public class PerlinNoiseGenerator {
|
|||||||
*/
|
*/
|
||||||
public double tileableNoise3(double x, double y, double z, double w, double h, double d)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,26 +4,57 @@ package mightypork.utils.math.timing;
|
|||||||
import mightypork.utils.Support;
|
import mightypork.utils.Support;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time metering utils for profiling.<br>
|
||||||
|
* The profiler work with long (starting ms time), so it has very little
|
||||||
|
* overhead and you can easily have multiple "profilers" running at the same
|
||||||
|
* time.
|
||||||
|
*
|
||||||
|
* @author Ondřej Hruška (MightyPork)
|
||||||
|
*/
|
||||||
public class Profiler {
|
public class Profiler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current time, to be later used in the end*() methods
|
||||||
|
*
|
||||||
|
* @return current time (ms)
|
||||||
|
*/
|
||||||
public static long begin()
|
public static long begin()
|
||||||
{
|
{
|
||||||
return System.currentTimeMillis();
|
return System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get seconds since begin.
|
||||||
|
*
|
||||||
|
* @param begun profiling start time (ms), obtained using begin()
|
||||||
|
* @return seconds elapsed
|
||||||
|
*/
|
||||||
public static double end(long begun)
|
public static double end(long begun)
|
||||||
{
|
{
|
||||||
return endLong(begun) / 1000D;
|
return endMs(begun) / 1000D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static long endLong(long begun)
|
/**
|
||||||
|
* Get milliseconds since begin.
|
||||||
|
*
|
||||||
|
* @param begun profiling start time (ms), obtained using begin()
|
||||||
|
* @return milliseconds elapsed
|
||||||
|
*/
|
||||||
|
public static long endMs(long begun)
|
||||||
{
|
{
|
||||||
return System.currentTimeMillis() - begun;
|
return System.currentTimeMillis() - begun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Elapsed time in human readable format, in seconds.
|
||||||
|
*
|
||||||
|
* @param begun profiling start time (ms), obtained using begin()
|
||||||
|
* @return something like "0.121 s"
|
||||||
|
*/
|
||||||
public static String endStr(long begun)
|
public static String endStr(long begun)
|
||||||
{
|
{
|
||||||
return Support.str(end(begun)) + " s";
|
return Support.str(end(begun)) + " s";
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ public abstract class TaskRepeater extends AnimatorRewind implements Runnable, E
|
|||||||
private boolean enabled = true;
|
private boolean enabled = true;
|
||||||
|
|
||||||
|
|
||||||
public TaskRepeater(double period) {
|
public TaskRepeater(double period)
|
||||||
|
{
|
||||||
super(period);
|
super(period);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ public class TimerDelta {
|
|||||||
/**
|
/**
|
||||||
* New delta timer
|
* New delta timer
|
||||||
*/
|
*/
|
||||||
public TimerDelta() {
|
public TimerDelta()
|
||||||
|
{
|
||||||
lastFrame = System.nanoTime();
|
lastFrame = System.nanoTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ public class TimerFps {
|
|||||||
*
|
*
|
||||||
* @param fps target FPS
|
* @param fps target FPS
|
||||||
*/
|
*/
|
||||||
public TimerFps(long fps) {
|
public TimerFps(long fps)
|
||||||
|
{
|
||||||
FRAME = Math.round(SECOND / (double) fps);
|
FRAME = Math.round(SECOND / (double) fps);
|
||||||
|
|
||||||
lastFrame = System.nanoTime();
|
lastFrame = System.nanoTime();
|
||||||
|
|||||||
@@ -2,16 +2,33 @@ package mightypork.utils.string;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String provider with constant string
|
* String provider that holds a string.
|
||||||
*
|
*
|
||||||
* @author Ondřej Hruška (MightyPork)
|
* @author Ondřej Hruška (MightyPork)
|
||||||
*/
|
*/
|
||||||
public class StringWrapper implements StringProvider {
|
public class StringWrapper implements StringProvider {
|
||||||
|
|
||||||
private final String value;
|
private String value;
|
||||||
|
|
||||||
|
|
||||||
public StringWrapper(String value) {
|
/**
|
||||||
|
* Create a string wrapper
|
||||||
|
*
|
||||||
|
* @param value original value
|
||||||
|
*/
|
||||||
|
public StringWrapper(String value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the string
|
||||||
|
*
|
||||||
|
* @param value string to set
|
||||||
|
*/
|
||||||
|
public void setString(String value)
|
||||||
|
{
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ public class CharFilterRegex implements CharFilter {
|
|||||||
private final String formula;
|
private final String formula;
|
||||||
|
|
||||||
|
|
||||||
public CharFilterRegex(String regex) {
|
public CharFilterRegex(String regex)
|
||||||
|
{
|
||||||
this.formula = regex;
|
this.formula = regex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ public class CharFilterWhitelist implements CharFilter {
|
|||||||
private final String whitelist;
|
private final String whitelist;
|
||||||
|
|
||||||
|
|
||||||
public CharFilterWhitelist(String allowed) {
|
public CharFilterWhitelist(String allowed)
|
||||||
|
{
|
||||||
this.whitelist = allowed;
|
this.whitelist = allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ public class Mutable<T> {
|
|||||||
*
|
*
|
||||||
* @param o value
|
* @param o value
|
||||||
*/
|
*/
|
||||||
public Mutable(T o) {
|
public Mutable(T o)
|
||||||
|
{
|
||||||
this.o = o;
|
this.o = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ public class Pair<T1, T2> {
|
|||||||
* @param first 1st object
|
* @param first 1st object
|
||||||
* @param second 2nd object
|
* @param second 2nd object
|
||||||
*/
|
*/
|
||||||
public Pair(T1 first, T2 second) {
|
public Pair(T1 first, T2 second)
|
||||||
|
{
|
||||||
this.first = first;
|
this.first = first;
|
||||||
this.second = second;
|
this.second = second;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ public class Triad<T1, T2, T3> extends Pair<T1, T2> {
|
|||||||
* @param objB 2nd object
|
* @param objB 2nd object
|
||||||
* @param objC 3rd object
|
* @param objC 3rd object
|
||||||
*/
|
*/
|
||||||
public Triad(T1 objA, T2 objB, T3 objC) {
|
public Triad(T1 objA, T2 objB, T3 objC)
|
||||||
|
{
|
||||||
super(objA, objB);
|
super(objA, objB);
|
||||||
third = objC;
|
third = objC;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user