package com.loopperfect.buckaroo.serialization;
import com.google.common.base.Preconditions;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.net.URL;
public final class UrlDeserializer implements JsonDeserializer<URL> {
@Override
public URL deserialize(final JsonElement jsonElement, final Type type, final JsonDeserializationContext context) throws JsonParseException {
Preconditions.checkNotNull(jsonElement);
Preconditions.checkNotNull(type);
Preconditions.checkNotNull(context);
try {
return new URL(jsonElement.getAsString());
} catch (final MalformedURLException e) {
throw new JsonParseException(e);
}
}
}