Java Code Examples for org.camunda.bpm.engine.variable.value.TypedValue#getType()
The following examples show how to use
org.camunda.bpm.engine.variable.value.TypedValue#getType() .
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 |
@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 2
Source File: PrimitiveValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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 3
Source File: PrimitiveValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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 |
@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 5
Source File: PrimitiveValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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 6
Source File: EqualsUntypedValue.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public boolean matches(Object argument) { if (argument == null || !TypedValue.class.isAssignableFrom(argument.getClass())) { return false; } TypedValue typedValue = (TypedValue) argument; if (typedValue.getType() != null) { return false; } if (value == null) { if (typedValue.getValue() != null) { return false; } } else { if (!value.equals(typedValue.getValue())) { return false; } } return true; }
Example 7
Source File: EqualsNullValue.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public boolean matches(Object argument) { if (argument == null || !TypedValue.class.isAssignableFrom(argument.getClass())) { return false; } TypedValue typedValue = (TypedValue) argument; if (typedValue.getType() != ValueType.NULL) { return false; } if (typedValue.getValue() != null) { return false; } return true; }
Example 8
Source File: AbstractCollectNumberHitPolicyHandler.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected List<Integer> convertValuesToInteger(List<TypedValue> typedValues) throws IllegalArgumentException { List<Integer> intValues = new ArrayList<Integer>(); for (TypedValue typedValue : typedValues) { if (ValueType.INTEGER.equals(typedValue.getType())) { intValues.add((Integer) typedValue.getValue()); } else if (typedValue.getType() == null) { // check if it is an integer Object value = typedValue.getValue(); if (value instanceof Integer) { intValues.add((Integer) value); } else { throw new IllegalArgumentException(); } } else { // reject other typed values throw new IllegalArgumentException(); } } return intValues; }
Example 9
Source File: PrimitiveValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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 10
Source File: AbstractCollectNumberHitPolicyHandler.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected List<Double> convertValuesToDouble(List<TypedValue> typedValues) throws IllegalArgumentException { List<Double> doubleValues = new ArrayList<Double>(); for (TypedValue typedValue : typedValues) { if (ValueType.DOUBLE.equals(typedValue.getType())) { doubleValues.add((Double) typedValue.getValue()); } else if (typedValue.getType() == null) { // check if it is a double or a string of a decimal number Object value = typedValue.getValue(); if (value instanceof Double) { doubleValues.add((Double) value); } else { Double doubleValue = Double.valueOf(value.toString()); doubleValues.add(doubleValue); } } else { // reject other typed values throw new IllegalArgumentException(); } } return doubleValues; }
Example 11
Source File: DateFormType.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public TypedValue convertToFormValue(TypedValue modelValue) { if(modelValue.getValue() == null) { return Variables.stringValue(null, modelValue.isTransient()); } else if(modelValue.getType() == ValueType.DATE) { return Variables.stringValue(dateFormat.format(modelValue.getValue()), modelValue.isTransient()); } else { throw new ProcessEngineException("Expected value to be of type '"+ValueType.DATE+"' but got '"+modelValue.getType()+"'."); } }
Example 12
Source File: AbstractTypedValueSerializer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public boolean canHandle(TypedValue value) { if(value.getType() != null && !valueType.getClass().isAssignableFrom(value.getType().getClass())) { return false; } else { return canWriteValue(value); } }
Example 13
Source File: FileValueSerializer.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override protected boolean canWriteValue(TypedValue value) { if (value == null || value.getType() == null) { // untyped value return false; } return value.getType().getName().equals(getName()); }
Example 14
Source File: VariableValueDto.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public static void fromTypedValue(VariableValueDto dto, TypedValue typedValue, boolean preferSerializedValue) { ValueType type = typedValue.getType(); if (type != null) { String typeName = type.getName(); dto.setType(toRestApiTypeName(typeName)); dto.setValueInfo(type.getValueInfo(typedValue)); } if(typedValue instanceof SerializableValue) { SerializableValue serializableValue = (SerializableValue) typedValue; if(serializableValue.isDeserialized() && !preferSerializedValue) { dto.setValue(serializableValue.getValue()); } else { dto.setValue(serializableValue.getValueSerialized()); } } else if(typedValue instanceof FileValue){ //do not set the value for FileValues since we don't want to send megabytes over the network without explicit request } else { dto.setValue(typedValue.getValue()); } }
Example 15
Source File: AbstractCollectNumberHitPolicyHandler.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected List<Long> convertValuesToLong(List<TypedValue> typedValues) throws IllegalArgumentException { List<Long> longValues = new ArrayList<Long>(); for (TypedValue typedValue : typedValues) { if (ValueType.LONG.equals(typedValue.getType())) { longValues.add((Long) typedValue.getValue()); } else if (typedValue.getType() == null) { // check if it is a long or a string of a number Object value = typedValue.getValue(); if (value instanceof Long) { longValues.add((Long) value); } else { Long longValue = Long.valueOf(value.toString()); longValues.add(longValue); } } else { // reject other typed values throw new IllegalArgumentException(); } } return longValues; }
Example 16
Source File: PrimitiveValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public boolean canConvertFromTypedValue(TypedValue typedValue) { if (typedValue.getType() != ValueType.NUMBER) { return false; } return true; }
Example 17
Source File: PrimitiveValueTypeImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@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 18
Source File: AbstractCollectNumberHitPolicyHandler.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
protected List<Double> convertValuesToDouble(List<TypedValue> typedValues) throws IllegalArgumentException { List<Double> doubleValues = new ArrayList<Double>(); for (TypedValue typedValue : typedValues) { if (ValueType.DOUBLE.equals(typedValue.getType())) { doubleValues.add((Double) typedValue.getValue()); } else if (typedValue.getType() == null) { // check if it is a double or a string of a decimal number Object value = typedValue.getValue(); if (value instanceof Double) { doubleValues.add((Double) value); } else { Double doubleValue = Double.valueOf(value.toString()); doubleValues.add(doubleValue); } } else { // reject other typed values throw new IllegalArgumentException(); } } return doubleValues; }
Example 19
Source File: AbstractCollectNumberHitPolicyHandler.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
protected List<Long> convertValuesToLong(List<TypedValue> typedValues) throws IllegalArgumentException { List<Long> longValues = new ArrayList<Long>(); for (TypedValue typedValue : typedValues) { if (ValueType.LONG.equals(typedValue.getType())) { longValues.add((Long) typedValue.getValue()); } else if (typedValue.getType() == null) { // check if it is a long or a string of a number Object value = typedValue.getValue(); if (value instanceof Long) { longValues.add((Long) value); } else { Long longValue = Long.valueOf(value.toString()); longValues.add(longValue); } } else { // reject other typed values throw new IllegalArgumentException(); } } return longValues; }
Example 20
Source File: AbstractTypedValueMapper.java From camunda-external-task-client-java with Apache License 2.0 | 4 votes |
public boolean canHandleTypedValue(TypedValue typedValue) { ValueType type = typedValue.getType(); return (type == null || valueType.getClass().isAssignableFrom(type.getClass())) && canWriteValue(typedValue); }