package com.google.gson; import com.google.gson.internal.LazilyParsedNumber; import com.google.gson.stream.JsonReader; import com.google.gson.stream.MalformedJsonException; import java.io.IOException; import java.math.BigDecimal; /* loaded from: classes3.dex */ public enum ToNumberPolicy implements ToNumberStrategy { DOUBLE { // from class: com.google.gson.ToNumberPolicy.1 @Override // com.google.gson.ToNumberStrategy public Double readNumber(JsonReader jsonReader) throws IOException { return Double.valueOf(jsonReader.nextDouble()); } }, LAZILY_PARSED_NUMBER { // from class: com.google.gson.ToNumberPolicy.2 @Override // com.google.gson.ToNumberStrategy public Number readNumber(JsonReader jsonReader) throws IOException { return new LazilyParsedNumber(jsonReader.nextString()); } }, LONG_OR_DOUBLE { // from class: com.google.gson.ToNumberPolicy.3 @Override // com.google.gson.ToNumberStrategy public Number readNumber(JsonReader jsonReader) throws IOException, JsonParseException { String nextString = jsonReader.nextString(); try { try { return Long.valueOf(Long.parseLong(nextString)); } catch (NumberFormatException unused) { Double valueOf = Double.valueOf(nextString); if (!valueOf.isInfinite()) { if (valueOf.isNaN()) { } return valueOf; } if (!jsonReader.isLenient()) { throw new MalformedJsonException("JSON forbids NaN and infinities: " + valueOf + "; at path " + jsonReader.getPath()); } return valueOf; } } catch (NumberFormatException e) { throw new JsonParseException("Cannot parse " + nextString + "; at path " + jsonReader.getPath(), e); } } }, BIG_DECIMAL { // from class: com.google.gson.ToNumberPolicy.4 @Override // com.google.gson.ToNumberStrategy public BigDecimal readNumber(JsonReader jsonReader) throws IOException { String nextString = jsonReader.nextString(); try { return new BigDecimal(nextString); } catch (NumberFormatException e) { throw new JsonParseException("Cannot parse " + nextString + "; at path " + jsonReader.getPath(), e); } } } }