All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.swagger.models.properties.BaseIntegerProperty Maven / Gradle / Ivy

The newest version!
package io.swagger.models.properties;

/**
 * The BaseIntegerProperty class defines property for integers without specific format, or with a custom
 * format.
 */
public class BaseIntegerProperty extends AbstractNumericProperty {
    public static final String TYPE = "integer";

    public BaseIntegerProperty() {
        this(null);
    }

    public BaseIntegerProperty(String format) {
        super.type = TYPE;
        super.format = format;
    }

    public static boolean isType(String type, String format) {
        return TYPE.equals(type);
    }

    @Override
    public void setExample(Object example) {
        if (example instanceof String) {
            try {
                this.example = Long.parseLong((String)example);
            } catch (NumberFormatException e) {
                this.example = example;
            }
        } else {
            this.example = example;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy