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

de.hakenadu.terms.gson.converter.IntegerConstantValueConverter Maven / Gradle / Ivy

Go to download

A light extensible java 8+ library for creating composites of terms which are evaluatable using a visitor pattern.

The newest version!
package de.hakenadu.terms.gson.converter;

import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;

public final class IntegerConstantValueConverter implements ConstantValueConverter {

	@Override
	public JsonElement toJson(final Integer value) {
		return new JsonPrimitive(value);
	}

	@Override
	public Integer fromJson(final JsonElement jsonElement) {
		return NumberConstantValueConverter.getAsNumber(jsonElement)//
				.map(Number::intValue)//
				.orElseThrow(() -> new JsonParseException("not a integer member: " + jsonElement));
	}

	@Override
	public String getTypeName() {
		return "integer";
	}

	@Override
	public Class getTypeClass() {
		return Integer.class;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy