mirror of https://github.com/apache/jclouds.git
took out null checking, as exceptions are now thrown when parsing fails
git-svn-id: http://jclouds.googlecode.com/svn/trunk@1873 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
94b13626f1
commit
4e05fcf529
|
@ -60,13 +60,13 @@ import com.google.inject.assistedinject.FactoryProvider;
|
||||||
public class ParserModule extends AbstractModule {
|
public class ParserModule extends AbstractModule {
|
||||||
private final static TypeLiteral<ParseSax.Factory> parseSaxFactoryLiteral = new TypeLiteral<ParseSax.Factory>() {
|
private final static TypeLiteral<ParseSax.Factory> parseSaxFactoryLiteral = new TypeLiteral<ParseSax.Factory>() {
|
||||||
};
|
};
|
||||||
|
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(parseSaxFactoryLiteral).toProvider(
|
bind(parseSaxFactoryLiteral).toProvider(
|
||||||
FactoryProvider.newFactory(parseSaxFactoryLiteral, new TypeLiteral<ParseSax<?>>() {
|
FactoryProvider.newFactory(parseSaxFactoryLiteral, new TypeLiteral<ParseSax<?>>() {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
static class DateTimeAdapter implements JsonSerializer<DateTime>, JsonDeserializer<DateTime> {
|
static class DateTimeAdapter implements JsonSerializer<DateTime>, JsonDeserializer<DateTime> {
|
||||||
private final static DateService dateService = new DateService();
|
private final static DateService dateService = new DateService();
|
||||||
|
|
||||||
|
@ -77,9 +77,7 @@ public class ParserModule extends AbstractModule {
|
||||||
public DateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
public DateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||||
throws JsonParseException {
|
throws JsonParseException {
|
||||||
String toParse = json.getAsJsonPrimitive().getAsString();
|
String toParse = json.getAsJsonPrimitive().getAsString();
|
||||||
DateTime toReturn = dateService.iso8601DateParse(toParse);
|
DateTime toReturn = dateService.jodaIso8601DateParse(toParse);
|
||||||
if (toReturn == null) toReturn = new DateTime(toParse);
|
|
||||||
if (toReturn == null) throw new RuntimeException("could not parse: "+toParse);
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue