m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/pl/edu/mimuw/cloudatlas/model/ValueInt.java
diff options
context:
space:
mode:
authorMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-10-21 21:45:57 +0200
committerMarcin Chrzanowski <marcin.j.chrzanowski@gmail.com>2019-10-21 21:45:57 +0200
commita0c4b252e5867219871b5c6df10219d916e29bff (patch)
tree08cc82ec20db1c68ec6002d965209c5168fad7a9 /src/pl/edu/mimuw/cloudatlas/model/ValueInt.java
parent38847dbb8809a8214a911b120b6b11ee4d7f1399 (diff)
Tabs to spaces
Diffstat (limited to 'src/pl/edu/mimuw/cloudatlas/model/ValueInt.java')
-rw-r--r--src/pl/edu/mimuw/cloudatlas/model/ValueInt.java196
1 files changed, 98 insertions, 98 deletions
diff --git a/src/pl/edu/mimuw/cloudatlas/model/ValueInt.java b/src/pl/edu/mimuw/cloudatlas/model/ValueInt.java
index d48532d..8811d57 100644
--- a/src/pl/edu/mimuw/cloudatlas/model/ValueInt.java
+++ b/src/pl/edu/mimuw/cloudatlas/model/ValueInt.java
@@ -32,102 +32,102 @@ import pl.edu.mimuw.cloudatlas.model.ValueInt;
* A class that wraps a Java <code>Long</code> object.
*/
public class ValueInt extends ValueSimple<Long> {
- /**
- * Constructs a new <code>ValueInt</code> object wrapping the specified <code>value</code>.
- *
- * @param value the value to wrap
- */
- public ValueInt(Long value) {
- super(value);
- }
-
- @Override
- public Type getType() {
- return TypePrimitive.INTEGER;
- }
-
- @Override
- public Value getDefaultValue() {
- return new ValueInt(0l);
- }
-
- @Override
- public ValueBoolean isLowerThan(Value value) {
- sameTypesOrThrow(value, Operation.COMPARE);
- if(isNull() || value.isNull())
- return new ValueBoolean(null);
- return new ValueBoolean(getValue() < ((ValueInt)value).getValue());
- }
-
- @Override
- public ValueInt addValue(Value value) {
- sameTypesOrThrow(value, Operation.ADD);
- if(isNull() || value.isNull())
- return new ValueInt(null);
- return new ValueInt(getValue() + ((ValueInt)value).getValue());
- }
-
- @Override
- public ValueInt subtract(Value value) {
- sameTypesOrThrow(value, Operation.SUBTRACT);
- if(isNull() || value.isNull())
- return new ValueInt(null);
- return new ValueInt(getValue() - ((ValueInt)value).getValue());
- }
-
- @Override
- public Value multiply(Value value) {
- if(value.getType().getPrimaryType() == PrimaryType.DURATION)
- return value.multiply(this);
- sameTypesOrThrow(value, Operation.MULTIPLY);
- if(isNull() || value.isNull())
- return new ValueInt(null);
- return new ValueInt(getValue() * ((ValueInt)value).getValue());
- }
-
- @Override
- public ValueDouble divide(Value value) {
- sameTypesOrThrow(value, Operation.DIVIDE);
- if(value.isNull())
- return new ValueDouble(null);
- if(((ValueInt)value).getValue() == 0l)
- throw new ArithmeticException("Division by zero.");
- if(isNull())
- return new ValueDouble(null);
- return new ValueDouble((double)getValue() / ((ValueInt)value).getValue());
- }
-
- @Override
- public ValueInt modulo(Value value) {
- sameTypesOrThrow(value, Operation.MODULO);
- if(value.isNull())
- return new ValueInt(null);
- if(((ValueInt)value).getValue() == 0l)
- throw new ArithmeticException("Division by zero.");
- if(isNull())
- return new ValueInt(null);
- return new ValueInt(getValue() % ((ValueInt)value).getValue());
- }
-
- @Override
- public ValueInt negate() {
- return new ValueInt(isNull()? null : -getValue());
- }
-
- @Override
- public Value convertTo(Type type) {
- switch(type.getPrimaryType()) {
- case DOUBLE:
- return new ValueDouble(getValue() == null? null : getValue().doubleValue());
- case DURATION:
- return new ValueDuration(getValue());
- case INT:
- return this;
- case STRING:
- return getValue() == null? ValueString.NULL_STRING : new ValueString(Long.toString(getValue()
- .longValue()));
- default:
- throw new UnsupportedConversionException(getType(), type);
- }
- }
+ /**
+ * Constructs a new <code>ValueInt</code> object wrapping the specified <code>value</code>.
+ *
+ * @param value the value to wrap
+ */
+ public ValueInt(Long value) {
+ super(value);
+ }
+
+ @Override
+ public Type getType() {
+ return TypePrimitive.INTEGER;
+ }
+
+ @Override
+ public Value getDefaultValue() {
+ return new ValueInt(0l);
+ }
+
+ @Override
+ public ValueBoolean isLowerThan(Value value) {
+ sameTypesOrThrow(value, Operation.COMPARE);
+ if(isNull() || value.isNull())
+ return new ValueBoolean(null);
+ return new ValueBoolean(getValue() < ((ValueInt)value).getValue());
+ }
+
+ @Override
+ public ValueInt addValue(Value value) {
+ sameTypesOrThrow(value, Operation.ADD);
+ if(isNull() || value.isNull())
+ return new ValueInt(null);
+ return new ValueInt(getValue() + ((ValueInt)value).getValue());
+ }
+
+ @Override
+ public ValueInt subtract(Value value) {
+ sameTypesOrThrow(value, Operation.SUBTRACT);
+ if(isNull() || value.isNull())
+ return new ValueInt(null);
+ return new ValueInt(getValue() - ((ValueInt)value).getValue());
+ }
+
+ @Override
+ public Value multiply(Value value) {
+ if(value.getType().getPrimaryType() == PrimaryType.DURATION)
+ return value.multiply(this);
+ sameTypesOrThrow(value, Operation.MULTIPLY);
+ if(isNull() || value.isNull())
+ return new ValueInt(null);
+ return new ValueInt(getValue() * ((ValueInt)value).getValue());
+ }
+
+ @Override
+ public ValueDouble divide(Value value) {
+ sameTypesOrThrow(value, Operation.DIVIDE);
+ if(value.isNull())
+ return new ValueDouble(null);
+ if(((ValueInt)value).getValue() == 0l)
+ throw new ArithmeticException("Division by zero.");
+ if(isNull())
+ return new ValueDouble(null);
+ return new ValueDouble((double)getValue() / ((ValueInt)value).getValue());
+ }
+
+ @Override
+ public ValueInt modulo(Value value) {
+ sameTypesOrThrow(value, Operation.MODULO);
+ if(value.isNull())
+ return new ValueInt(null);
+ if(((ValueInt)value).getValue() == 0l)
+ throw new ArithmeticException("Division by zero.");
+ if(isNull())
+ return new ValueInt(null);
+ return new ValueInt(getValue() % ((ValueInt)value).getValue());
+ }
+
+ @Override
+ public ValueInt negate() {
+ return new ValueInt(isNull()? null : -getValue());
+ }
+
+ @Override
+ public Value convertTo(Type type) {
+ switch(type.getPrimaryType()) {
+ case DOUBLE:
+ return new ValueDouble(getValue() == null? null : getValue().doubleValue());
+ case DURATION:
+ return new ValueDuration(getValue());
+ case INT:
+ return this;
+ case STRING:
+ return getValue() == null? ValueString.NULL_STRING : new ValueString(Long.toString(getValue()
+ .longValue()));
+ default:
+ throw new UnsupportedConversionException(getType(), type);
+ }
+ }
}