org.aarboard.nextcloud.api.provisioning.QuotaDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nextcloud-api Show documentation
Show all versions of nextcloud-api Show documentation
Java api library to access nextcloud features from java applications
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);
}
}