41 lines
1.5 KiB
Java
41 lines
1.5 KiB
Java
package expression;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigInteger;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author Doschennikov Nikita (me@fymio.us)
|
|
*/
|
|
public class Low extends AbstractExpression {
|
|
private final AbstractExpression operand;
|
|
|
|
public Low(AbstractExpression operand) {
|
|
this.operand = operand;
|
|
}
|
|
|
|
@Override public int evaluate(int x) { int n = operand.evaluate(x); return n & -n; }
|
|
@Override public int evaluate(int x, int y, int z) { int n = operand.evaluate(x,y,z); return n & -n; }
|
|
@Override public int evaluate(List<Integer> vars) { int n = operand.evaluate(vars); return n & -n; }
|
|
@Override public BigInteger evaluateBi(List<BigInteger> vars) { throw new UnsupportedOperationException(); }
|
|
@Override public BigDecimal evaluateBd(List<BigDecimal> vars) { throw new UnsupportedOperationException(); }
|
|
|
|
@Override public String toString() { return "low(" + operand + ")"; }
|
|
|
|
@Override
|
|
public String toMiniString() {
|
|
if (operand instanceof AbstractBinaryOperation) {
|
|
return "low(" + operand.toMiniString() + ")";
|
|
}
|
|
return "low " + operand.toMiniString();
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) return true;
|
|
if (!(obj instanceof Low)) return false;
|
|
return operand.equals(((Low) obj).operand);
|
|
}
|
|
|
|
@Override public int hashCode() { return operand.hashCode() ^ 0x4C4F5700; }
|
|
} |