org.raml.v2.api.model.v10.datamodel.NumberTypeDeclaration Java Examples
The following examples show how to use
org.raml.v2.api.model.v10.datamodel.NumberTypeDeclaration.
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: UnionTypesHelper.java From raml-java-tools with Apache License 2.0 | 6 votes |
private static Map<Class<? extends TypeDeclaration>, Integer> getPriorityTypeMap() { return new ImmutableMap.Builder<Class<? extends TypeDeclaration>, Integer>() .put(NullTypeDeclaration.class, 1) .put(BooleanTypeDeclaration.class, 2) .put(IntegerTypeDeclaration.class, 3) .put(NumberTypeDeclaration.class, 4) .put(DateTypeDeclaration.class, 5) .put(TimeOnlyTypeDeclaration.class, 6) .put(DateTimeOnlyTypeDeclaration.class, 7) .put(DateTimeTypeDeclaration.class, 8) .put(StringTypeDeclaration.class, 9) .put(ObjectTypeDeclaration.class, 10) .put(ArrayTypeDeclaration.class, 11) .put(UnionTypeDeclaration.class, 12) .put(FileTypeDeclaration.class, 13) .put(AnyTypeDeclaration.class, 14) .build(); }
Example #2
Source File: EnumerationTypeHandler.java From raml-java-tools with Apache License 2.0 | 5 votes |
List pullEnumValues(TypeDeclaration typeDeclaration) { if ( typeDeclaration instanceof IntegerTypeDeclaration ) { return ((IntegerTypeDeclaration)typeDeclaration).enumValues(); } else if (typeDeclaration instanceof NumberTypeDeclaration) { return ((NumberTypeDeclaration)typeDeclaration).enumValues(); } else { return ((StringTypeDeclaration)typeDeclaration).enumValues(); } }
Example #3
Source File: RamlTypeHelper.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
/** * IF it has a format defined, this will return it * * @param param * The parameter to inspect * @return Format, if defined */ public static String getFormat(TypeDeclaration param) { if (param == null) { return null; } if (param instanceof NumberTypeDeclaration) { return ((NumberTypeDeclaration) param).format(); } if (param instanceof DateTimeTypeDeclaration) { return ((DateTimeTypeDeclaration) param).format(); } return null; }
Example #4
Source File: NumberTypeInterpreter.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
@Override public RamlInterpretationResult interpret(RamlRoot document, TypeDeclaration type, JCodeModel builderModel, boolean property) { RamlInterpretationResult result = new RamlInterpretationResult(type.required()); String resolvedType = String.class.getSimpleName(); typeCheck(type); if (type instanceof NumberTypeDeclaration) { NumberTypeDeclaration numberType = (NumberTypeDeclaration) type; String format = numberType.format(); RamlTypeValidations validations = result.getValidations(); validations.withMinMax(numberType.minimum(), numberType.maximum()); if (!StringUtils.hasText(format)) { // format not supplied. Defaulting to long if it's integer since // it's safer if (type instanceof IntegerTypeDeclaration) { resolvedType = Long.class.getSimpleName(); } else { resolvedType = Double.class.getSimpleName(); } } else { resolvedType = SchemaHelper.mapSimpleType(RamlParamType.NUMBER, format, type.type()).getSimpleName(); } } if (resolvedType.equals(Double.class.getSimpleName()) && Config.getPojoConfig().isUseBigDecimals()) { resolvedType = BigDecimal.class.getName(); } if (resolvedType.equals(Long.class.getSimpleName()) && Config.getPojoConfig().isUseBigIntegers()) { resolvedType = BigInteger.class.getName(); } result.setResolvedClass(CodeModelHelper.findFirstClassBySimpleName(builderModel, resolvedType)); return result; }
Example #5
Source File: RJP10V2RamlQueryParameter.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
@Override public BigDecimal getMinimum() { if (queryParameter instanceof NumberTypeDeclaration) { Double minimum = ((NumberTypeDeclaration) queryParameter).minimum(); if (minimum != null) { return BigDecimal.valueOf(minimum); } } return null; }
Example #6
Source File: RJP10V2RamlQueryParameter.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
@Override public BigDecimal getMaximum() { if (queryParameter instanceof NumberTypeDeclaration) { Double maximum = ((NumberTypeDeclaration) queryParameter).maximum(); if (maximum != null) { return BigDecimal.valueOf(maximum); } } return null; }
Example #7
Source File: RJP10V2RamlUriParameter.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
@Override public BigDecimal getMinimum() { if (uriParameter instanceof NumberTypeDeclaration) { Double minimum = ((NumberTypeDeclaration) uriParameter).minimum(); if (minimum != null) { return BigDecimal.valueOf(minimum); } } return null; }
Example #8
Source File: RJP10V2RamlUriParameter.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
@Override public BigDecimal getMaximum() { if (uriParameter instanceof NumberTypeDeclaration) { Double maximum = ((NumberTypeDeclaration) uriParameter).maximum(); if (maximum != null) { return BigDecimal.valueOf(maximum); } } return null; }
Example #9
Source File: RJP10V2RamlFormParameter.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
@Override public BigDecimal getMinimum() { if (formParameter instanceof NumberTypeDeclaration) { Double minimum = ((NumberTypeDeclaration) formParameter).minimum(); if (minimum != null) { return BigDecimal.valueOf(minimum); } } return null; }
Example #10
Source File: RJP10V2RamlFormParameter.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
@Override public BigDecimal getMaximum() { if (formParameter instanceof NumberTypeDeclaration) { Double maximum = ((NumberTypeDeclaration) formParameter).maximum(); if (maximum != null) { return BigDecimal.valueOf(maximum); } } return null; }
Example #11
Source File: RJP10V2RamlHeader.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
@Override public BigDecimal getMinimum() { if (header instanceof NumberTypeDeclaration) { Double minimum = ((NumberTypeDeclaration) header).minimum(); if (minimum != null) { return BigDecimal.valueOf(minimum); } } return null; }
Example #12
Source File: RJP10V2RamlHeader.java From springmvc-raml-plugin with Apache License 2.0 | 5 votes |
@Override public BigDecimal getMaximum() { if (header instanceof NumberTypeDeclaration) { Double maximum = ((NumberTypeDeclaration) header).maximum(); if (maximum != null) { return BigDecimal.valueOf(maximum); } } return null; }
Example #13
Source File: NumberTypeInterpreter.java From springmvc-raml-plugin with Apache License 2.0 | 4 votes |
@Override public Set<Class<? extends TypeDeclaration>> getSupportedTypes() { return Collections.singleton(NumberTypeDeclaration.class); }