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

org.aarboard.nextcloud.api.provisioning.QuotaDeserializer Maven / Gradle / Ivy

The newest version!
package org.aarboard.nextcloud.api.provisioning;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import org.apache.commons.lang3.math.NumberUtils;

import java.io.IOException;
import java.util.Optional;

public class QuotaDeserializer extends JsonDeserializer> {

    @Override
    public Optional deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
        Long result = null;
        String quota = jsonParser.getValueAsString();
        if (NumberUtils.isCreatable(quota)) {
            result = NumberUtils.createLong(quota);
        }

        return Optional.ofNullable(result);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy