org.camunda.bpm.engine.variable.Variables.numberValue()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(19.1k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中org.camunda.bpm.engine.variable.Variables.numberValue()方法的一些代码示例,展示了Variables.numberValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Variables.numberValue()方法的具体详情如下:
包路径:org.camunda.bpm.engine.variable.Variables
类名称:Variables
方法名:numberValue

Variables.numberValue介绍

[英]Creates an abstract Number value. Note that this value cannot be used to set variables. Use the specific methods Variables#integerValue(Integer), #shortValue(Short), #longValue(Long) and #doubleValue(Double) instead.
[中]创建一个抽象的数值。请注意,此值不能用于设置变量。使用特定的方法变量#integerValue(Integer)、#shortValue(Short)、#longValue(Long)和#doubleValue(Double)。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Creates an abstract Number value. Note that this value cannot be used to set variables.
 * Use the specific methods {@link Variables#integerValue(Integer)}, {@link #shortValue(Short)},
 * {@link #longValue(Long)} and {@link #doubleValue(Double)} instead.
 */
public static NumberValue numberValue(Number numberValue) {
 return numberValue(numberValue, false);
}

代码示例来源:origin: camunda/camunda-bpm-platform

public Object resolveValue(ObjectMapper objectMapper) {
  Object value = super.resolveValue(objectMapper);

  if (value != null && Number.class.isAssignableFrom(value.getClass())) {
   return Variables.numberValue((Number) value);
  }

  return value;
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

public Object resolveValue(ObjectMapper objectMapper) {
  Object value = super.resolveValue(objectMapper);

  if (value != null && Number.class.isAssignableFrom(value.getClass())) {
   return Variables.numberValue((Number) value);
  }

  return value;
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

public NumberValue createValue(Object value, Map<String, Object> valueInfo) {
 return Variables.numberValue((Number) value, isTransient(valueInfo));
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
public void testVariableEqualsNumberMax() throws Exception {
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", MAX_DOUBLE_VALUE));
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", Long.MAX_VALUE));
 assertEquals(1, taskService.createTaskQuery().processVariableValueEquals("var", Variables.numberValue(MAX_DOUBLE_VALUE)).count());
 assertEquals(1, taskService.createTaskQuery().processVariableValueEquals("var", Variables.numberValue(Long.MAX_VALUE)).count());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
public void testVariableEqualsNumberLongValueOverflow() throws Exception {
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", MAX_DOUBLE_VALUE));
 // this results in an overflow
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", (long) MAX_DOUBLE_VALUE));
 // the query should not find the long variable
 assertEquals(1, taskService.createTaskQuery().processVariableValueEquals("var", Variables.numberValue(MAX_DOUBLE_VALUE)).count());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
public void testProcessVariableValueNumberComparison() throws Exception {
 // long
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", 123L));
 // non-matching long
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", 12345L));
 // short
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", (short) 123));
 // double
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", 123.0d));
 // integer
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", 123));
 // untyped null
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", null));
 // typed null
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", Variables.longValue(null)));
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", "123"));
 assertEquals(4, runtimeService.createExecutionQuery().processVariableValueNotEquals("var", Variables.numberValue(123)).count());
}

代码示例来源:origin: camunda/camunda-bpm-platform

Collections.<String, Object>singletonMap("var", "123"));
assertEquals(4, historyService.createHistoricProcessInstanceQuery().variableValueEquals("var", Variables.numberValue(123)).count());
assertEquals(4, historyService.createHistoricProcessInstanceQuery().variableValueEquals("var", Variables.numberValue(123L)).count());
assertEquals(4, historyService.createHistoricProcessInstanceQuery().variableValueEquals("var", Variables.numberValue(123.0d)).count());
assertEquals(4, historyService.createHistoricProcessInstanceQuery().variableValueEquals("var", Variables.numberValue((short) 123)).count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("var", Variables.numberValue(null)).count());

代码示例来源:origin: camunda/camunda-bpm-platform

Collections.<String, Object>singletonMap("var", "123"));
assertEquals(4, runtimeService.createProcessInstanceQuery().variableValueEquals("var", Variables.numberValue(123)).count());
assertEquals(4, runtimeService.createProcessInstanceQuery().variableValueEquals("var", Variables.numberValue(123L)).count());
assertEquals(4, runtimeService.createProcessInstanceQuery().variableValueEquals("var", Variables.numberValue(123.0d)).count());
assertEquals(4, runtimeService.createProcessInstanceQuery().variableValueEquals("var", Variables.numberValue((short) 123)).count());
assertEquals(1, runtimeService.createProcessInstanceQuery().variableValueEquals("var", Variables.numberValue(null)).count());

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
public void testVariableEqualsNumberNonIntegerDoubleShouldNotMatchInteger() throws Exception {
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Variables.createVariables().putValue("var", 42).putValue("var2", 52.4d));
 // querying by 42.4 should not match the integer variable 42
 assertEquals(0, taskService.createTaskQuery().processVariableValueEquals("var", Variables.numberValue(42.4d)).count());
 runtimeService.startProcessInstanceByKey("oneTaskProcess",
   Collections.<String, Object>singletonMap("var", 42.4d));
 // querying by 52 should not find the double variable 52.4
 assertEquals(0, taskService.createTaskQuery().processVariableValueEquals("var", Variables.numberValue(52)).count());
}

代码示例来源:origin: camunda/camunda-bpm-platform

Collections.<String, Object>singletonMap("var", "123"));
assertEquals(4, taskService.createTaskQuery().processVariableValueNotEquals("var", Variables.numberValue(123)).count());
assertEquals(1, taskService.createTaskQuery().processVariableValueGreaterThan("var", Variables.numberValue(123)).count());
assertEquals(5, taskService.createTaskQuery().processVariableValueGreaterThanOrEquals("var", Variables.numberValue(123)).count());
assertEquals(0, taskService.createTaskQuery().processVariableValueLessThan("var", Variables.numberValue(123)).count());
assertEquals(4, taskService.createTaskQuery().processVariableValueLessThanOrEquals("var", Variables.numberValue(123)).count());

代码示例来源:origin: camunda/camunda-bpm-platform

Collections.<String, Object>singletonMap("var", "123"));
assertEquals(4, taskService.createTaskQuery().processVariableValueEquals("var", Variables.numberValue(123)).count());
assertEquals(4, taskService.createTaskQuery().processVariableValueEquals("var", Variables.numberValue(123L)).count());
assertEquals(4, taskService.createTaskQuery().processVariableValueEquals("var", Variables.numberValue(123.0d)).count());
assertEquals(4, taskService.createTaskQuery().processVariableValueEquals("var", Variables.numberValue((short) 123)).count());
assertEquals(1, taskService.createTaskQuery().processVariableValueEquals("var", Variables.numberValue(null)).count());

代码示例来源:origin: camunda/camunda-bpm-platform

Collections.<String, Object>singletonMap("var", "123"));
assertEquals(4, runtimeService.createProcessInstanceQuery().variableValueNotEquals("var", Variables.numberValue(123)).count());
assertEquals(1, runtimeService.createProcessInstanceQuery().variableValueGreaterThan("var", Variables.numberValue(123)).count());
assertEquals(5, runtimeService.createProcessInstanceQuery().variableValueGreaterThanOrEqual("var", Variables.numberValue(123)).count());
assertEquals(0, runtimeService.createProcessInstanceQuery().variableValueLessThan("var", Variables.numberValue(123)).count());
assertEquals(4, runtimeService.createProcessInstanceQuery().variableValueLessThanOrEqual("var", Variables.numberValue(123)).count());

代码示例来源:origin: camunda/camunda-bpm-platform

Collections.<String, Object>singletonMap("var", "123"));
assertEquals(4, runtimeService.createExecutionQuery().processVariableValueEquals("var", Variables.numberValue(123)).count());
assertEquals(4, runtimeService.createExecutionQuery().processVariableValueEquals("var", Variables.numberValue(123L)).count());
assertEquals(4, runtimeService.createExecutionQuery().processVariableValueEquals("var", Variables.numberValue(123.0d)).count());
assertEquals(4, runtimeService.createExecutionQuery().processVariableValueEquals("var", Variables.numberValue((short) 123)).count());
assertEquals(1, runtimeService.createExecutionQuery().processVariableValueEquals("var", Variables.numberValue(null)).count());
assertEquals(4, runtimeService.createExecutionQuery().variableValueEquals("var", Variables.numberValue(123)).count());
assertEquals(4, runtimeService.createExecutionQuery().variableValueEquals("var", Variables.numberValue(123L)).count());
assertEquals(4, runtimeService.createExecutionQuery().variableValueEquals("var", Variables.numberValue(123.0d)).count());
assertEquals(4, runtimeService.createExecutionQuery().variableValueEquals("var", Variables.numberValue((short) 123)).count());
assertEquals(1, runtimeService.createExecutionQuery().variableValueEquals("var", Variables.numberValue(null)).count());

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
public void testTaskVariableValueEqualsNumber() throws Exception {
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 List<Task> tasks = taskService.createTaskQuery().processDefinitionKey("oneTaskProcess").list();
 assertEquals(8, tasks.size());
 taskService.setVariableLocal(tasks.get(0).getId(), "var", 123L);
 taskService.setVariableLocal(tasks.get(1).getId(), "var", 12345L);
 taskService.setVariableLocal(tasks.get(2).getId(), "var", (short) 123);
 taskService.setVariableLocal(tasks.get(3).getId(), "var", 123.0d);
 taskService.setVariableLocal(tasks.get(4).getId(), "var", 123);
 taskService.setVariableLocal(tasks.get(5).getId(), "var", null);
 taskService.setVariableLocal(tasks.get(6).getId(), "var", Variables.longValue(null));
 taskService.setVariableLocal(tasks.get(7).getId(), "var", "123");
 assertEquals(4, historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("var", Variables.numberValue(123)).count());
 assertEquals(4, historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("var", Variables.numberValue(123L)).count());
 assertEquals(4, historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("var", Variables.numberValue(123.0d)).count());
 assertEquals(4, historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("var", Variables.numberValue((short) 123)).count());
 assertEquals(1, historyService.createHistoricTaskInstanceQuery().taskVariableValueEquals("var", Variables.numberValue(null)).count());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
public void testTaskVariableValueEqualsNumber() throws Exception {
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 runtimeService.startProcessInstanceByKey("oneTaskProcess");
 List<Task> tasks = taskService.createTaskQuery().processDefinitionKey("oneTaskProcess").list();
 assertEquals(8, tasks.size());
 taskService.setVariableLocal(tasks.get(0).getId(), "var", 123L);
 taskService.setVariableLocal(tasks.get(1).getId(), "var", 12345L);
 taskService.setVariableLocal(tasks.get(2).getId(), "var", (short) 123);
 taskService.setVariableLocal(tasks.get(3).getId(), "var", 123.0d);
 taskService.setVariableLocal(tasks.get(4).getId(), "var", 123);
 taskService.setVariableLocal(tasks.get(5).getId(), "var", null);
 taskService.setVariableLocal(tasks.get(6).getId(), "var", Variables.longValue(null));
 taskService.setVariableLocal(tasks.get(7).getId(), "var", "123");
 assertEquals(4, taskService.createTaskQuery().taskVariableValueEquals("var", Variables.numberValue(123)).count());
 assertEquals(4, taskService.createTaskQuery().taskVariableValueEquals("var", Variables.numberValue(123L)).count());
 assertEquals(4, taskService.createTaskQuery().taskVariableValueEquals("var", Variables.numberValue(123.0d)).count());
 assertEquals(4, taskService.createTaskQuery().taskVariableValueEquals("var", Variables.numberValue((short) 123)).count());
 assertEquals(1, taskService.createTaskQuery().taskVariableValueEquals("var", Variables.numberValue(null)).count());
}

代码示例来源:origin: camunda/camunda-bpm-platform

@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
@Test
public void testSetAbstractNumberValueFails() {
 try {
  runtimeService.startProcessInstanceByKey("oneTaskProcess",
    Variables.createVariables().putValueTyped("var", Variables.numberValue(42)));
  fail("exception expected");
 } catch (ProcessEngineException e) {
  // happy path
  testRule.assertTextPresentIgnoreCase("cannot serialize value of abstract type number", e.getMessage());
 }
 ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
 try {
  runtimeService.setVariable(processInstance.getId(), "var", Variables.numberValue(42));
  fail("exception expected");
 } catch (ProcessEngineException e) {
  // happy path
  testRule.assertTextPresentIgnoreCase("cannot serialize value of abstract type number", e.getMessage());
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

Collections.<String, Object>singletonMap("var", "123"));
assertEquals(4, historyService.createHistoricTaskInstanceQuery().processVariableValueEquals("var", Variables.numberValue(123)).count());
assertEquals(4, historyService.createHistoricTaskInstanceQuery().processVariableValueEquals("var", Variables.numberValue(123L)).count());
assertEquals(4, historyService.createHistoricTaskInstanceQuery().processVariableValueEquals("var", Variables.numberValue(123.0d)).count());
assertEquals(4, historyService.createHistoricTaskInstanceQuery().processVariableValueEquals("var", Variables.numberValue((short) 123)).count());
assertEquals(1, historyService.createHistoricTaskInstanceQuery().processVariableValueEquals("var", Variables.numberValue(null)).count());

代码示例来源:origin: camunda/camunda-bpm-platform

.create();
assertEquals(4, caseService.createCaseInstanceQuery().variableValueEquals("var", Variables.numberValue(123)).count());
assertEquals(4, caseService.createCaseInstanceQuery().variableValueEquals("var", Variables.numberValue(123L)).count());
assertEquals(4, caseService.createCaseInstanceQuery().variableValueEquals("var", Variables.numberValue(123.0d)).count());
assertEquals(4, caseService.createCaseInstanceQuery().variableValueEquals("var", Variables.numberValue((short) 123)).count());
assertEquals(1, caseService.createCaseInstanceQuery().variableValueEquals("var", Variables.numberValue(null)).count());
assertEquals(4, caseService.createCaseInstanceQuery().variableValueNotEquals("var", Variables.numberValue(123)).count());
assertEquals(1, caseService.createCaseInstanceQuery().variableValueGreaterThan("var", Variables.numberValue(123L)).count());
assertEquals(5, caseService.createCaseInstanceQuery().variableValueGreaterThanOrEqual("var", Variables.numberValue(123.0d)).count());
assertEquals(0, caseService.createCaseInstanceQuery().variableValueLessThan("var", Variables.numberValue((short) 123)).count());
assertEquals(4, caseService.createCaseInstanceQuery().variableValueLessThanOrEqual("var", Variables.numberValue((short) 123)).count());

代码示例来源:origin: camunda/camunda-bpm-platform

.create();
assertEquals(4, historicQuery().variableValueEquals("var", Variables.numberValue(123)).count());
assertEquals(4, historicQuery().variableValueEquals("var", Variables.numberValue(123L)).count());
assertEquals(4, historicQuery().variableValueEquals("var", Variables.numberValue(123.0d)).count());
assertEquals(4, historicQuery().variableValueEquals("var", Variables.numberValue((short) 123)).count());
assertEquals(1, historicQuery().variableValueEquals("var", Variables.numberValue(null)).count());

相关文章