readProperties(in, builder); } else if (GEOMETRY_NAME.equals(name)) { builder.withGeometry(gson.fromJson(in, Geometry.class)); } else if (ID_NAME.equals(name)) { builder.withId(Optional.ofNullable(in.nextString())); } else { return builder.build();
private void readProperties(JsonReader in, Feature.Builder builder) throws IOException { if(in.peek() == JsonToken.NULL) { in.nextNull(); builder.withProperties(Collections.emptyMap()); } else { in.beginObject(); while (in.hasNext()) { String name = in.nextName(); JsonElement value = jsonParser.parse(in); builder.withProperty(name, value); } in.endObject(); } }
readProperties(in, builder); } else if (GEOMETRY_NAME.equals(name)) { builder.withGeometry(gson.fromJson(in, Geometry.class)); } else if (ID_NAME.equals(name)) { builder.withId(Optional.ofNullable(in.nextString())); } else { return builder.build();
public Builder withId(String id) { return withId(Optional.of(id)); }
public static Builder builder() { return new Builder(); }
public static Feature featureWithGeometry(Geometry<?> geometry) { return Feature.builder().withGeometry(Point.from(12.3, 45.3)).build(); }
public Builder withId(String id) { return withId(Optional.of(id)); }
public static Builder builder(Feature feature) { return builder().withGeometry(feature.geometry).withProperties(feature.properties).withId(feature.id); }
public static Builder builder() { return new Builder(); }
public static Builder builder(Feature feature) { return builder().withGeometry(feature.geometry).withProperties(feature.properties).withId(feature.id); }
public static Feature featureWithProperties(Map<String, JsonElement> properties) { return Feature.builder().withGeometry(Point.from(12.3, 45.3)).withProperties(properties).build(); }
public static Feature featureWithId(String id) { return Feature.builder().withGeometry(Point.from(12.3, 45.3)).withId(id).build(); }
private void readProperties(JsonReader in, Feature.Builder builder) throws IOException { if(in.peek() == JsonToken.NULL) { in.nextNull(); builder.withProperties(Collections.emptyMap()); } else { in.beginObject(); while (in.hasNext()) { String name = in.nextName(); JsonElement value = jsonParser.parse(in); builder.withProperty(name, value); } in.endObject(); } }
/** * Build a {@link Feature} with the given {@link Geometry}. * * @param geometry The Geometry to build Feature from * * @return An instance of Feature */ public static Feature of(Geometry<?> geometry) { return builder().withGeometry(geometry).build(); }
/** * Build a {@link Feature} with the given {@link Geometry}. * * @param geometry The Geometry to build Feature from * * @return An instance of Feature */ public static Feature of(Geometry<?> geometry) { return builder().withGeometry(geometry).build(); }