protected Property getSwaggerProperty ( Swagger swagger , Class < ? > objectClass ) { Property swaggerProperty = null ; if ( byte . class == objectClass || Byte . class == objectClass ) { // STRING swaggerProperty = new StringProperty ( "byte" ) ; } else if ( char . class == objectClass || Character . class == objectClass ) { // CHAR is STRING LEN 1 StringProperty property = new StringProperty ( ) ; property . setMaxLength ( 1 ) ; swaggerProperty = property ; } else if ( short . class == objectClass || Short . class == objectClass ) { // SHORT is INTEGER with 16-bit max & min IntegerProperty property = new IntegerProperty ( ) ; property . setMinimum ( BigDecimal . valueOf ( Short . MIN_VALUE ) ) ; property . setMaximum ( BigDecimal . valueOf ( Short . MAX_VALUE ) ) ; swaggerProperty = property ; } else if ( int . class == objectClass || Integer . class == objectClass ) { // INTEGER swaggerProperty = new IntegerProperty ( ) ; } else if ( long . class == objectClass || Long . class == objectClass ) { // LONG swaggerProperty = new LongProperty ( ) ; } else if ( float . class == objectClass || Float . class == objectClass ) { // FLOAT swaggerProperty = new FloatProperty ( ) ; } else if ( double . class == objectClass || Double . class == objectClass ) { // DOUBLE swaggerProperty = new DoubleProperty ( ) ; } else if ( BigDecimal . class == objectClass ) { // DECIMAL swaggerProperty = new DecimalProperty ( ) ; } else if ( boolean . class == objectClass || Boolean . class == objectClass ) { // BOOLEAN swaggerProperty = new BooleanProperty ( ) ; } else if ( String . class == objectClass ) { // STRING swaggerProperty = new StringProperty ( ) ; } else if ( Date . class == objectClass || Timestamp . class == objectClass ) { // DATETIME swaggerProperty = new DateTimeProperty ( ) ; } else if ( java . sql . Date . class == objectClass ) { // DATE swaggerProperty = new DateProperty ( ) ; } else if ( java . sql . Time . class == objectClass ) { // TIME -> STRING StringProperty property = new StringProperty ( ) ; property . setPattern ( "HH:mm:ss" ) ; swaggerProperty = property ; } else if ( UUID . class == objectClass ) { // UUID swaggerProperty = new UUIDProperty ( ) ; } else if ( objectClass . isEnum ( ) ) { // ENUM StringProperty property = new StringProperty ( ) ; List < String > enumValues = new ArrayList <> ( ) ; for ( Object enumValue : objectClass . getEnumConstants ( ) ) { enumValues . add ( ( ( Enum ) enumValue ) . name ( ) ) ; } property . setEnum ( enumValues ) ; swaggerProperty = property ; } else if ( FileItem . class == objectClass ) { // FILE UPLOAD swaggerProperty = new FileProperty ( ) ; } else { // Register a Model class String modelRef = registerModel ( swagger , objectClass ) ; swaggerProperty = new RefProperty ( modelRef ) ; } return swaggerProperty ; }
Returns the appropriate Swagger Property instance for a given object class .