GeoPoint, for instance, has two components: the GeoPoint interface, which is useful when users implement their own class, and the ImmutableGeoPoint class, useful when they just want to create an instance. From Java9 on, Java started to offer factory methods on its standard interfaces for similar purposes: see List.of and Map.of for example, which create an immutable instance of List or Map, respectively. Maybe we should follow a similar pattern for our classes, such as GeoPoint, GeoPolygon, GeoBoundingBox, BeanReference? (there may be more) |