@Override public double getAsDouble(String name) { return map.getAsJsonPrimitive(name).getAsDouble(); }
private void extractPrimitive(EntityData.Value.Builder value, JsonElement element) { JsonPrimitive primitive = element.getAsJsonPrimitive(); if (primitive.isNumber()) { value.addDouble(primitive.getAsDouble()); value.addFloat(primitive.getAsFloat()); try { value.addInteger(primitive.getAsInt()); value.addLong(primitive.getAsLong()); } catch (NumberFormatException e) { value.addInteger(0); value.addLong(0); } } if (primitive.isBoolean()) { value.addBoolean(primitive.getAsBoolean()); } if (primitive.isString()) { value.addString(primitive.getAsString()); } } }
@Override public double nextDouble() throws IOException { JsonToken token = peek(); if (token != JsonToken.NUMBER && token != JsonToken.STRING) { throw new IllegalStateException( "Expected " + JsonToken.NUMBER + " but was " + token + locationString()); } double result = ((JsonPrimitive) peekStack()).getAsDouble(); if (!isLenient() && (Double.isNaN(result) || Double.isInfinite(result))) { throw new NumberFormatException("JSON forbids NaN and infinities: " + result); } popStack(); if (stackSize > 0) { pathIndices[stackSize - 1]++; } return result; }
@Override protected Double nullUnsafeFromNumber(JsonPrimitive primitive) { return primitive.getAsDouble(); }
@Override protected Double nullUnsafeFromNumber(JsonPrimitive primitive) { return primitive.getAsDouble(); }
@Override protected Double nullUnsafeFromNumber(JsonPrimitive primitive) { return primitive.getAsDouble(); }
@Override protected Double nullUnsafeFromNumber(JsonPrimitive primitive) { return primitive.getAsDouble(); }
protected Double jsonAsDouble(JsonElement element, String field) throws SchemaViolationError { if (!element.isJsonPrimitive() || !element.getAsJsonPrimitive().isNumber()) { throw new SchemaViolationError(this, field, element); } return element.getAsJsonPrimitive().getAsDouble(); }
@Override public double nextDouble() throws IOException { JsonToken token = peek(); if (token != JsonToken.NUMBER && token != JsonToken.STRING) { throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + token); } double result = ((JsonPrimitive) peekStack()).getAsDouble(); if (!isLenient() && (Double.isNaN(result) || Double.isInfinite(result))) { throw new NumberFormatException("JSON forbids NaN and infinities: " + result); } popStack(); return result; }
@Override public double nextDouble() throws IOException { JsonToken token = peek(); if (token != JsonToken.NUMBER && token != JsonToken.STRING) { throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + token); } double result = ((JsonPrimitive) peekStack()).getAsDouble(); if (!isLenient() && (Double.isNaN(result) || Double.isInfinite(result))) { throw new NumberFormatException("JSON forbids NaN and infinities: " + result); } popStack(); return result; }
@Override public double nextDouble() throws IOException { JsonToken token = peek(); if (token != JsonToken.NUMBER && token != JsonToken.STRING) { throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + token); } double result = ((JsonPrimitive) peekStack()).getAsDouble(); if (!isLenient() && (Double.isNaN(result) || Double.isInfinite(result))) { throw new NumberFormatException("JSON forbids NaN and infinities: " + result); } popStack(); return result; }
@Override public double nextDouble() throws IOException { JsonToken token = peek(); if (token != JsonToken.NUMBER && token != JsonToken.STRING) { throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + token); } double result = ((JsonPrimitive) peekStack()).getAsDouble(); if (!isLenient() && (Double.isNaN(result) || Double.isInfinite(result))) { throw new NumberFormatException("JSON forbids NaN and infinities: " + result); } popStack(); return result; }
/** * Instantiates a new Img eval key. * * @param json the json * @param rs the rs */ protected GramianLayer(@Nonnull final JsonObject json, Map<CharSequence, byte[]> rs) { super(json); this.precision = Precision.valueOf(json.getAsJsonPrimitive("precision").getAsString()); this.alpha = json.getAsJsonPrimitive("alpha").getAsDouble(); }
/** * Instantiates a new Product inputs key. * * @param id the id */ protected SquareActivationLayer(@Nonnull final JsonObject id) { super(id); this.precision = Precision.valueOf(id.getAsJsonPrimitive("precision").getAsString()); this.alpha = id.getAsJsonPrimitive("alpha").getAsDouble(); }
/** * Instantiates a new Product inputs layer. * * @param id the id */ protected SquareActivationLayer(@Nonnull final JsonObject id) { super(id); this.precision = Precision.valueOf(id.getAsJsonPrimitive("precision").getAsString()); this.alpha = id.getAsJsonPrimitive("alpha").getAsDouble(); }
/** * Instantiates a new Img eval layer. * * @param json the json * @param rs the rs */ protected GramianLayer(@Nonnull final JsonObject json, Map<CharSequence, byte[]> rs) { super(json); this.precision = Precision.valueOf(json.getAsJsonPrimitive("precision").getAsString()); this.alpha = json.getAsJsonPrimitive("alpha").getAsDouble(); }
@Override public double nextDouble() throws IOException { JsonToken token = peek(); if (token != JsonToken.NUMBER && token != JsonToken.STRING) { throw new IllegalStateException("Expected " + JsonToken.NUMBER + " but was " + token); } double result = ((JsonPrimitive) peekStack()).getAsDouble(); if (!isLenient() && (Double.isNaN(result) || Double.isInfinite(result))) { throw new NumberFormatException("JSON forbids NaN and infinities: " + result); } popStack(); return result; }
/** * Instantiates a new Activation key. * * @param json the json */ protected ActivationLayer(@Nonnull final JsonObject json) { super(json); mode = json.getAsJsonPrimitive("mode").getAsInt(); setAlpha(json.getAsJsonPrimitive("alpha").getAsDouble()); precision = Precision.valueOf(json.get("precision").getAsString()); }
/** * Instantiates a new Activation layer. * * @param json the json */ protected ActivationLayer(@Nonnull final JsonObject json) { super(json); mode = json.getAsJsonPrimitive("mode").getAsInt(); setAlpha(json.getAsJsonPrimitive("alpha").getAsDouble()); precision = Precision.valueOf(json.get("precision").getAsString()); }
private static Tuple<PropertyKey<?>, PropertyValue<?>> parseKeyValuePair(String identifier, JsonElement element) { if (element.isJsonPrimitive()) { JsonPrimitive primitive = element.getAsJsonPrimitive(); if (primitive.isNumber()) { return new Tuple<>(PropertyKey.createNumber(identifier), new NumberValue(primitive.getAsDouble())); } else if (primitive.isBoolean()) { return new Tuple<>(PropertyKey.createBoolean(identifier), new BooleanValue(primitive.getAsBoolean())); } } return null; }