Removed some "final" qualifiers from static methods.

Also fixed some other warnings IntelliJ annoyed me with
This commit is contained in:
TomyLobo 2013-09-21 12:28:09 +02:00 committed by wizjany
parent c26de335ff
commit cabced11a7
2 changed files with 77 additions and 77 deletions

View File

@ -34,6 +34,7 @@ import com.sk89q.worldedit.expression.runtime.Function.Dynamic;
*
* @author TomyLobo
*/
@SuppressWarnings("UnusedDeclaration")
public final class Functions {
private static class Overload {
private final Method method;
@ -92,7 +93,7 @@ public final class Functions {
}
}
public static final Function getFunction(int position, String name, RValue... args) throws NoSuchMethodException {
public static Function getFunction(int position, String name, RValue... args) throws NoSuchMethodException {
final Method getter = getMethod(name, false, args);
try {
Method setter = getMethod(name, true, args);
@ -120,7 +121,7 @@ public final class Functions {
for (Method method : Functions.class.getMethods()) {
try {
addFunction(method);
} catch(IllegalArgumentException e) {}
} catch (IllegalArgumentException ignored) { }
}
}
@ -139,114 +140,114 @@ public final class Functions {
}
public static final double sin(RValue x) throws EvaluationException {
public static double sin(RValue x) throws EvaluationException {
return Math.sin(x.getValue());
}
public static final double cos(RValue x) throws EvaluationException {
public static double cos(RValue x) throws EvaluationException {
return Math.cos(x.getValue());
}
public static final double tan(RValue x) throws EvaluationException {
public static double tan(RValue x) throws EvaluationException {
return Math.tan(x.getValue());
}
public static final double asin(RValue x) throws EvaluationException {
public static double asin(RValue x) throws EvaluationException {
return Math.asin(x.getValue());
}
public static final double acos(RValue x) throws EvaluationException {
public static double acos(RValue x) throws EvaluationException {
return Math.acos(x.getValue());
}
public static final double atan(RValue x) throws EvaluationException {
public static double atan(RValue x) throws EvaluationException {
return Math.atan(x.getValue());
}
public static final double atan2(RValue y, RValue x) throws EvaluationException {
public static double atan2(RValue y, RValue x) throws EvaluationException {
return Math.atan2(y.getValue(), x.getValue());
}
public static final double sinh(RValue x) throws EvaluationException {
public static double sinh(RValue x) throws EvaluationException {
return Math.sinh(x.getValue());
}
public static final double cosh(RValue x) throws EvaluationException {
public static double cosh(RValue x) throws EvaluationException {
return Math.cosh(x.getValue());
}
public static final double tanh(RValue x) throws EvaluationException {
public static double tanh(RValue x) throws EvaluationException {
return Math.tanh(x.getValue());
}
public static final double sqrt(RValue x) throws EvaluationException {
public static double sqrt(RValue x) throws EvaluationException {
return Math.sqrt(x.getValue());
}
public static final double cbrt(RValue x) throws EvaluationException {
public static double cbrt(RValue x) throws EvaluationException {
return Math.cbrt(x.getValue());
}
public static final double abs(RValue x) throws EvaluationException {
public static double abs(RValue x) throws EvaluationException {
return Math.abs(x.getValue());
}
public static final double min(RValue a, RValue b) throws EvaluationException {
public static double min(RValue a, RValue b) throws EvaluationException {
return Math.min(a.getValue(), b.getValue());
}
public static final double min(RValue a, RValue b, RValue c) throws EvaluationException {
public static double min(RValue a, RValue b, RValue c) throws EvaluationException {
return Math.min(a.getValue(), Math.min(b.getValue(), c.getValue()));
}
public static final double max(RValue a, RValue b) throws EvaluationException {
public static double max(RValue a, RValue b) throws EvaluationException {
return Math.max(a.getValue(), b.getValue());
}
public static final double max(RValue a, RValue b, RValue c) throws EvaluationException {
public static double max(RValue a, RValue b, RValue c) throws EvaluationException {
return Math.max(a.getValue(), Math.max(b.getValue(), c.getValue()));
}
public static final double ceil(RValue x) throws EvaluationException {
public static double ceil(RValue x) throws EvaluationException {
return Math.ceil(x.getValue());
}
public static final double floor(RValue x) throws EvaluationException {
public static double floor(RValue x) throws EvaluationException {
return Math.floor(x.getValue());
}
public static final double rint(RValue x) throws EvaluationException {
public static double rint(RValue x) throws EvaluationException {
return Math.rint(x.getValue());
}
public static final double round(RValue x) throws EvaluationException {
public static double round(RValue x) throws EvaluationException {
return Math.round(x.getValue());
}
public static final double exp(RValue x) throws EvaluationException {
public static double exp(RValue x) throws EvaluationException {
return Math.exp(x.getValue());
}
public static final double ln(RValue x) throws EvaluationException {
public static double ln(RValue x) throws EvaluationException {
return Math.log(x.getValue());
}
public static final double log(RValue x) throws EvaluationException {
public static double log(RValue x) throws EvaluationException {
return Math.log(x.getValue());
}
public static final double log10(RValue x) throws EvaluationException {
public static double log10(RValue x) throws EvaluationException {
return Math.log10(x.getValue());
}
public static final double rotate(LValue x, LValue y, RValue angle) throws EvaluationException {
public static double rotate(LValue x, LValue y, RValue angle) throws EvaluationException {
final double f = angle.getValue();
final double cosF = Math.cos(f);
@ -261,7 +262,7 @@ public final class Functions {
return 0.0;
}
public static final double swap(LValue x, LValue y) throws EvaluationException {
public static double swap(LValue x, LValue y) throws EvaluationException {
final double tmp = x.getValue();
x.assign(y.getValue());
@ -290,27 +291,27 @@ public final class Functions {
}
@Dynamic
public static final double gmegabuf(RValue index) throws EvaluationException {
public static double gmegabuf(RValue index) throws EvaluationException {
return getBufferItem(gmegabuf, (int) index.getValue());
}
@Dynamic
public static final double gmegabuf(RValue index, double value) throws EvaluationException {
public static double gmegabuf(RValue index, double value) throws EvaluationException {
return setBufferItem(gmegabuf, (int) index.getValue(), value);
}
@Dynamic
public static final double megabuf(RValue index) throws EvaluationException {
public static double megabuf(RValue index) throws EvaluationException {
return getBufferItem(Expression.getInstance().getMegabuf(), (int) index.getValue());
}
@Dynamic
public static final double megabuf(RValue index, double value) throws EvaluationException {
public static double megabuf(RValue index, double value) throws EvaluationException {
return setBufferItem(Expression.getInstance().getMegabuf(), (int) index.getValue(), value);
}
@Dynamic
public static final double closest(RValue x, RValue y, RValue z, RValue index, RValue count, RValue stride) throws EvaluationException {
public static double closest(RValue x, RValue y, RValue z, RValue index, RValue count, RValue stride) throws EvaluationException {
return findClosest(
Expression.getInstance().getMegabuf(),
x.getValue(),
@ -323,7 +324,7 @@ public final class Functions {
}
@Dynamic
public static final double gclosest(RValue x, RValue y, RValue z, RValue index, RValue count, RValue stride) throws EvaluationException {
public static double gclosest(RValue x, RValue y, RValue z, RValue index, RValue count, RValue stride) throws EvaluationException {
return findClosest(
gmegabuf,
x.getValue(),
@ -361,12 +362,12 @@ public final class Functions {
private static final Random random = new Random();
@Dynamic
public static final double random() {
public static double random() {
return random.nextDouble();
}
@Dynamic
public static final double randint(RValue max) throws EvaluationException {
public static double randint(RValue max) throws EvaluationException {
return random.nextInt((int) Math.floor(max.getValue()));
}
}

View File

@ -24,159 +24,158 @@ package com.sk89q.worldedit.expression.runtime;
*
* @author TomyLobo
*/
@SuppressWarnings("UnusedDeclaration")
public final class Operators {
public static final Function getOperator(int position, String name, RValue lhs, RValue rhs) throws NoSuchMethodException {
public static Function getOperator(int position, String name, RValue lhs, RValue rhs) throws NoSuchMethodException {
if (lhs instanceof LValue) {
try {
return new Function(position, Operators.class.getMethod(name, LValue.class, RValue.class), lhs, rhs);
} catch (NoSuchMethodException e) {
}
} catch (NoSuchMethodException ignored) { }
}
return new Function(position, Operators.class.getMethod(name, RValue.class, RValue.class), lhs, rhs);
}
public static final Function getOperator(int position, String name, RValue argument) throws NoSuchMethodException {
public static Function getOperator(int position, String name, RValue argument) throws NoSuchMethodException {
if (argument instanceof LValue) {
try {
return new Function(position, Operators.class.getMethod(name, LValue.class), argument);
} catch (NoSuchMethodException e) {
}
} catch (NoSuchMethodException ignored) { }
}
return new Function(position, Operators.class.getMethod(name, RValue.class), argument);
}
public static final double add(RValue lhs, RValue rhs) throws EvaluationException {
public static double add(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() + rhs.getValue();
}
public static final double sub(RValue lhs, RValue rhs) throws EvaluationException {
public static double sub(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() - rhs.getValue();
}
public static final double mul(RValue lhs, RValue rhs) throws EvaluationException {
public static double mul(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() * rhs.getValue();
}
public static final double div(RValue lhs, RValue rhs) throws EvaluationException {
public static double div(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() / rhs.getValue();
}
public static final double mod(RValue lhs, RValue rhs) throws EvaluationException {
public static double mod(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() % rhs.getValue();
}
public static final double pow(RValue lhs, RValue rhs) throws EvaluationException {
public static double pow(RValue lhs, RValue rhs) throws EvaluationException {
return Math.pow(lhs.getValue(), rhs.getValue());
}
public static final double neg(RValue x) throws EvaluationException {
public static double neg(RValue x) throws EvaluationException {
return -x.getValue();
}
public static final double not(RValue x) throws EvaluationException {
public static double not(RValue x) throws EvaluationException {
return x.getValue() > 0.0 ? 0.0 : 1.0;
}
public static final double inv(RValue x) throws EvaluationException {
public static double inv(RValue x) throws EvaluationException {
return ~(long) x.getValue();
}
public static final double lth(RValue lhs, RValue rhs) throws EvaluationException {
public static double lth(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() < rhs.getValue() ? 1.0 : 0.0;
}
public static final double gth(RValue lhs, RValue rhs) throws EvaluationException {
public static double gth(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() > rhs.getValue() ? 1.0 : 0.0;
}
public static final double leq(RValue lhs, RValue rhs) throws EvaluationException {
public static double leq(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() <= rhs.getValue() ? 1.0 : 0.0;
}
public static final double geq(RValue lhs, RValue rhs) throws EvaluationException {
public static double geq(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() >= rhs.getValue() ? 1.0 : 0.0;
}
public static final double equ(RValue lhs, RValue rhs) throws EvaluationException {
public static double equ(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() == rhs.getValue() ? 1.0 : 0.0;
}
public static final double neq(RValue lhs, RValue rhs) throws EvaluationException {
public static double neq(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() != rhs.getValue() ? 1.0 : 0.0;
}
public static final double near(RValue lhs, RValue rhs) throws EvaluationException {
public static double near(RValue lhs, RValue rhs) throws EvaluationException {
return almostEqual2sComplement(lhs.getValue(), rhs.getValue(), 450359963L) ? 1.0 : 0.0;
//return Math.abs(lhs.invoke() - rhs.invoke()) < 1e-7 ? 1.0 : 0.0;
}
public static final double or(RValue lhs, RValue rhs) throws EvaluationException {
public static double or(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() > 0.0 || rhs.getValue() > 0.0 ? 1.0 : 0.0;
}
public static final double and(RValue lhs, RValue rhs) throws EvaluationException {
public static double and(RValue lhs, RValue rhs) throws EvaluationException {
return lhs.getValue() > 0.0 && rhs.getValue() > 0.0 ? 1.0 : 0.0;
}
public static final double shl(RValue lhs, RValue rhs) throws EvaluationException {
public static double shl(RValue lhs, RValue rhs) throws EvaluationException {
return (long) lhs.getValue() << (long) rhs.getValue();
}
public static final double shr(RValue lhs, RValue rhs) throws EvaluationException {
public static double shr(RValue lhs, RValue rhs) throws EvaluationException {
return (long) lhs.getValue() >> (long) rhs.getValue();
}
public static final double ass(LValue lhs, RValue rhs) throws EvaluationException {
public static double ass(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(rhs.getValue());
}
public static final double aadd(LValue lhs, RValue rhs) throws EvaluationException {
public static double aadd(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(lhs.getValue() + rhs.getValue());
}
public static final double asub(LValue lhs, RValue rhs) throws EvaluationException {
public static double asub(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(lhs.getValue() - rhs.getValue());
}
public static final double amul(LValue lhs, RValue rhs) throws EvaluationException {
public static double amul(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(lhs.getValue() * rhs.getValue());
}
public static final double adiv(LValue lhs, RValue rhs) throws EvaluationException {
public static double adiv(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(lhs.getValue() / rhs.getValue());
}
public static final double amod(LValue lhs, RValue rhs) throws EvaluationException {
public static double amod(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(lhs.getValue() % rhs.getValue());
}
public static final double aexp(LValue lhs, RValue rhs) throws EvaluationException {
public static double aexp(LValue lhs, RValue rhs) throws EvaluationException {
return lhs.assign(Math.pow(lhs.getValue(), rhs.getValue()));
}
public static final double inc(LValue x) throws EvaluationException {
public static double inc(LValue x) throws EvaluationException {
return x.assign(x.getValue() + 1);
}
public static final double dec(LValue x) throws EvaluationException {
public static double dec(LValue x) throws EvaluationException {
return x.assign(x.getValue() - 1);
}
public static final double postinc(LValue x) throws EvaluationException {
public static double postinc(LValue x) throws EvaluationException {
final double oldValue = x.getValue();
x.assign(oldValue + 1);
return oldValue;
}
public static final double postdec(LValue x) throws EvaluationException {
public static double postdec(LValue x) throws EvaluationException {
final double oldValue = x.getValue();
x.assign(oldValue - 1);
return oldValue;
@ -192,8 +191,8 @@ public final class Operators {
}
}
public static final double fac(RValue x) throws EvaluationException {
int n = (int) x.getValue();
public static double fac(RValue x) throws EvaluationException {
final int n = (int) x.getValue();
if (n < 0) {
return 0;
@ -220,7 +219,7 @@ public final class Operators {
// Make bLong lexicographically ordered as a twos-complement long
if (bLong < 0) bLong = 0x8000000000000000L - bLong;
long longDiff = Math.abs(aLong - bLong);
final long longDiff = Math.abs(aLong - bLong);
return longDiff <= maxUlps;
}
}