public @ Nonnull Iterable < Double > doubles ( ) { final JsonArray parent = this ; return ( ) -> { final Iterator < JsonElement > iterator = parent . iterator ( ) ; return new Iterator < Double > ( ) { @ Override public boolean hasNext ( ) { return iterator . hasNext ( ) ; } @ Override public Double next ( ) { return iterator . next ( ) . asDouble ( ) ; } @ Override public void remove ( ) { iterator . remove ( ) ; } } ; } ; }
Convenience method to prevent casting JsonElement to Double when iterating in the common case that you have an array of doubles .