Java Code Examples for org.jboss.dmr.ModelType#BIG_DECIMAL
The following examples show how to use
org.jboss.dmr.ModelType#BIG_DECIMAL .
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: ModelTypeValidatorUnitTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Test public void testBigDecimal() { ModelTypeValidator testee = new ModelTypeValidator(ModelType.BIG_DECIMAL, false, false, false); validateNumbers(testee); testee = new ModelTypeValidator(ModelType.BIG_DECIMAL, false, false, true); assertOk(testee, new ModelNode().set(new BigDecimal(1))); assertInvalid(testee, new ModelNode().set(1)); }
Example 2
Source File: ManagementModelNode.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public boolean isNumeric() { ModelType type = getType(); return (type == ModelType.BIG_DECIMAL) || (type == ModelType.BIG_INTEGER) || (type == ModelType.DOUBLE) || (type == ModelType.INT) || (type == ModelType.LONG); }
Example 3
Source File: ModelTestModelDescriptionValidator.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public String validate(ModelType currentType, ModelNode currentNode, String descriptor) { if (currentNode.hasDefined(descriptor)) { if (currentType != ModelType.BIG_DECIMAL && currentType != ModelType.BIG_INTEGER && currentType != ModelType.DOUBLE && currentType != ModelType.INT && currentType != ModelType.LONG) { return "Unnecessary '" + descriptor + "' for non-numeric type=" + currentType; } if (!descriptor.equals(UNIT)) { try { if (currentType == ModelType.BIG_DECIMAL) { currentNode.get(descriptor).asBigDecimal(); } else if (currentType == ModelType.BIG_INTEGER) { currentNode.get(descriptor).asBigInteger(); } else if (currentType == ModelType.DOUBLE) { currentNode.get(descriptor).asDouble(); } else if (currentType == ModelType.INT) { currentNode.get(descriptor).asInt(); } else if (currentType == ModelType.LONG) { currentNode.get(descriptor).asLong(); } } catch (Exception e) { return "'" + descriptor + "' is not a " + currentType; } } } return null; }
Example 4
Source File: ValidateOperationsTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); if (value.getType() == ModelType.BIG_DECIMAL && value.asBigDecimal().compareTo(max) > 0) { throw new OperationFailedException(value.asString()); } if (value.getType() == ModelType.BIG_DECIMAL && value.asBigDecimal().compareTo(min) < 0) { throw new OperationFailedException(value.asString()); } }
Example 5
Source File: OptionAttributeDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void setType() { try { final Field typeField; if (option.getClass().getSimpleName().equals("SequenceOption")) { typeField = option.getClass().getDeclaredField("elementType"); } else { typeField = option.getClass().getDeclaredField("type"); } typeField.setAccessible(true); optionType = (Class<?>) typeField.get(option); if (optionType.isAssignableFrom(Integer.class)) { type = ModelType.INT; } else if (optionType.isAssignableFrom(Long.class)) { type = ModelType.LONG; } else if (optionType.isAssignableFrom(BigInteger.class)) { type = ModelType.BIG_INTEGER; } else if (optionType.isAssignableFrom(Double.class)) { type = ModelType.DOUBLE; } else if (optionType.isAssignableFrom(BigDecimal.class)) { type = ModelType.BIG_DECIMAL; } else if (optionType.isEnum() || optionType.isAssignableFrom(String.class)) { type = ModelType.STRING; } else if (optionType.isAssignableFrom(Boolean.class)) { type = ModelType.BOOLEAN; } else { type = ModelType.UNDEFINED; } } catch (Exception e) { throw new IllegalArgumentException(e); } }
Example 6
Source File: ValidateOperationsTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private BigDecimalRangeValidator(int min, int max) { super(ModelType.BIG_DECIMAL); this.min = new BigDecimal(min); this.max = new BigDecimal(max); }