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

io.openapiprocessor.jsonschema.converter.IntegerConverter Maven / Gradle / Ivy

There is a newer version: 2024.4
Show newest version
/*
 * Copyright 2022 https://github.com/openapi-processor/openapi-parser
 * PDX-License-Identifier: Apache-2.0
 */

package io.openapiprocessor.jsonschema.converter;

import org.checkerframework.checker.nullness.qual.Nullable;

import static io.openapiprocessor.jsonschema.support.Types.convertOrNull;

/**
 * converts the property {@code value} to {@link Integer}.
 */
public class IntegerConverter implements PropertyConverter {

    @Override
    public @Nullable Integer convert (String name, @Nullable Object value, String location) {
        Number number = convertOrNull(location, value, Number.class);
        if (number == null)
            return null;

        return number.intValue();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy