Java Code Examples for org.camunda.bpm.engine.variable.type.ValueType#NUMBER

The following examples show how to use org.camunda.bpm.engine.variable.type.ValueType#NUMBER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public boolean canConvertFromTypedValue(TypedValue typedValue) {
  if (typedValue.getType() != ValueType.NUMBER) {
    return false;
  }

  if (typedValue.getValue() != null) {
    NumberValue numberValue = (NumberValue) typedValue;
    double doubleValue = numberValue.getValue().doubleValue();

    // returns false if the value changes due to conversion (e.g. by overflows
    // or by loss in precision)
    if (numberValue.getValue().intValue() != doubleValue) {
      return false;
    }
  }

  return true;
}
 
Example 2
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public IntegerValue convertFromTypedValue(TypedValue typedValue) {
  if (typedValue.getType() != ValueType.NUMBER) {
    throw unsupportedConversion(typedValue.getType());
  }

  IntegerValueImpl integerValue = null;
  NumberValue numberValue = (NumberValue) typedValue;
  if (numberValue.getValue() != null) {
    integerValue = (IntegerValueImpl) Variables.integerValue(numberValue.getValue().intValue());
  } else {
    integerValue = (IntegerValueImpl) Variables.integerValue(null);
  }
  integerValue.setTransient(numberValue.isTransient());
  return integerValue;
}
 
Example 3
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public boolean canConvertFromTypedValue(TypedValue typedValue) {
  if (typedValue.getType() != ValueType.NUMBER) {
    return false;
  }

  if (typedValue.getValue() != null) {
    NumberValue numberValue = (NumberValue) typedValue;
    double doubleValue = numberValue.getValue().doubleValue();

    // returns false if the value changes due to conversion (e.g. by overflows
    // or by loss in precision)
    if (numberValue.getValue().longValue() != doubleValue) {
      return false;
    }
  }

  return true;
}
 
Example 4
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public LongValue convertFromTypedValue(TypedValue typedValue) {
  if (typedValue.getType() != ValueType.NUMBER) {
    throw unsupportedConversion(typedValue.getType());
  }

  LongValueImpl longvalue = null;
  NumberValue numberValue = (NumberValue) typedValue;

  if (numberValue.getValue() != null) {
    longvalue = (LongValueImpl) Variables.longValue(numberValue.getValue().longValue());
  } else {
    longvalue =  (LongValueImpl) Variables.longValue(null);
  }
  longvalue.setTransient(numberValue.isTransient());
  return longvalue;
}
 
Example 5
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public ShortValue convertFromTypedValue(TypedValue typedValue) {
  if (typedValue.getType() != ValueType.NUMBER) {
    throw unsupportedConversion(typedValue.getType());
  }

  ShortValueImpl shortValue = null;
  NumberValue numberValue = (NumberValue) typedValue;
  if (numberValue.getValue() != null) {
    shortValue = (ShortValueImpl) Variables.shortValue(numberValue.getValue().shortValue());
  } else {
    shortValue =  (ShortValueImpl) Variables.shortValue(null);
  }
  shortValue.setTransient(numberValue.isTransient());
  return shortValue;
}
 
Example 6
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public boolean canConvertFromTypedValue(TypedValue typedValue) {
  if (typedValue.getType() != ValueType.NUMBER) {
    return false;
  }

  if (typedValue.getValue() != null) {
    NumberValue numberValue = (NumberValue) typedValue;
    double doubleValue = numberValue.getValue().doubleValue();

    // returns false if the value changes due to conversion (e.g. by overflows
    // or by loss in precision)
    if (numberValue.getValue().shortValue() != doubleValue) {
      return false;
    }
  }

  return true;
}
 
Example 7
Source File: EqualsPrimitiveValue.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected boolean matchesValues(Object otherValue) {
  // explicit matching for byte[]
  if (value instanceof byte[]) {
    if (!(otherValue instanceof byte[])) {
      return false;
    }

    byte[] byteValue = (byte[]) value;
    byte[] otherByteValue = (byte[]) otherValue;

    return Arrays.equals(byteValue, otherByteValue);
  }

  if (type == ValueType.NUMBER) {
    if (!(otherValue instanceof Number)) {
      return false;
    }

    Number thisNumer = (Number) value;
    Number otherNumber = (Number) otherValue;

    return thisNumer.doubleValue() == otherNumber.doubleValue();
  }

  return value.equals(otherValue);

}
 
Example 8
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canConvertFromTypedValue(TypedValue typedValue) {
  if (typedValue.getType() != ValueType.NUMBER) {
    return false;
  }

  return true;
}
 
Example 9
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public DoubleValue convertFromTypedValue(TypedValue typedValue) {
  if (typedValue.getType() != ValueType.NUMBER) {
    throw unsupportedConversion(typedValue.getType());
  }
  DoubleValueImpl doubleValue = null;
  NumberValue numberValue = (NumberValue) typedValue;
  if (numberValue.getValue() != null) {
    doubleValue = (DoubleValueImpl) Variables.doubleValue(numberValue.getValue().doubleValue());
  } else {
    doubleValue = (DoubleValueImpl) Variables.doubleValue(null);
  }
  doubleValue.setTransient(numberValue.isTransient());
  return doubleValue;
}
 
Example 10
Source File: PrimitiveTypeValueImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public NumberValueImpl(Number value) {
  super(value, ValueType.NUMBER);
}
 
Example 11
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public ValueType getParent() {
  return ValueType.NUMBER;
}
 
Example 12
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public ValueType getParent() {
  return ValueType.NUMBER;
}
 
Example 13
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public ValueType getParent() {
  return ValueType.NUMBER;
}
 
Example 14
Source File: PrimitiveValueTypeImpl.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public ValueType getParent() {
  return ValueType.NUMBER;
}