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(); } } }
@Override public boolean isEnum() { return ((typeDeclaration instanceof StringTypeDeclaration) && ((StringTypeDeclaration) typeDeclaration).enumValues() != null) || ((typeDeclaration instanceof NumberTypeDeclaration) && ((NumberTypeDeclaration) typeDeclaration).enumValues() != null); }
/** * Safely get example from a type with null checks * * @param type * The RAML TypeDeclaration to check * @return The example if defined or null if empty */ public static String getExample(TypeDeclaration type) { if (type == null || type.example() == null) { return null; } else { return type.example().value(); } }
private String elementType(TypeDeclaration type) { final String t = type.type(); if (t.endsWith("[]")) { return t.substring(0, t.length() - 2); } if (type instanceof ArrayTypeDeclaration) { final String items = ((ArrayTypeDeclaration) type).items().type(); return "array".equals(items) ? "string" : items; } return null; }
@Override public String getRawType() { return this.formParameter.type(); } }
@Override public String name() { return input.name(); }
@Override public Integer getMinLength() { if (formParameter instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) formParameter).minLength(); } return null; }
@Override public Integer getMaxLength() { if (uriParameter instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) uriParameter).maxLength(); } return null; }
@Override public String getDiscriminatorValue() { if (this.dataType instanceof ObjectTypeDeclaration) { return ((ObjectTypeDeclaration) this.dataType).discriminatorValue(); } return null; } }
@Override public String getPattern() { if (header instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) header).pattern(); } return null; }
@Override public List<AnnotationRef> getAnnotations() { return this.queryParameter.annotations(); } }
@Override public String getRawType() { return this.uriParameter.type(); } }
@Override public Integer getMinLength() { if (header instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) header).minLength(); } return null; }
@Override public Integer getMaxLength() { if (queryParameter instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) queryParameter).maxLength(); } return null; }
@Override public String getPattern() { if (queryParameter instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) queryParameter).pattern(); } return null; }
@Override public String getRawType() { return this.header.type(); } }
@Override public Integer getMinLength() { if (queryParameter instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) queryParameter).minLength(); } return null; }
@Override public Integer getMaxLength() { if (header instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) header).maxLength(); } return null; }
@Override public String getPattern() { if (uriParameter instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) uriParameter).pattern(); } return null; }
@Override public Integer getMinLength() { if (uriParameter instanceof StringTypeDeclaration) { return ((StringTypeDeclaration) uriParameter).minLength(); } return null; }