referencing columns
Lukas Eder
lukas.eder at gmail.com
Mon May 7 10:48:44 UTC 2018
2018-05-04 17:39 GMT+02:00 Douglas Surber <douglas.surber at oracle.com>:
> Your alternative does not include the motion methods directly. In order to
> get to next the app would have to call iterator. Having gotten an iterator
> so it can call next it cannot get back to Row.
>
Added a row() method, which would be useful regardless of the final design.
Akin to JDBC's ResultSet.getStatement() and Statement.getConnection()
public interface Column {
public <T> T get(Class<T> type);
public SqlType sqlType();
public <T> Class<T> javaType();
public String id();
public int index();
public Row row();
}
> No doubt you can write some odd things, but with a little care in the spec
> I think it would all be well and simply defined.
>
Sure, this can be specified. But I don't really see the value of the type
yet, compared to possible alternatives. E.g. slice (probably not such a
frequent use-case) could be achieved by adding columnStream() method:
public interface Row extends Iterable<Column>{
public long rowNumber();
public Row cancel();
public Column at(String id);
public Column at(int index);
public Stream<Column> columnStream(); // Added this method
// forEach, iterator, spliterator
}
Now you could call
row.columnStream().skip(3).limit(5).forEach(c -> { ... });
"Luckily", the skip() method looks as if it were 1-based, too :)
Of course, I wish Iterable itself had a stream() method, so we would get
this for "free", but that decision has been postponed since Java 8 for a
couple of times - I forgot why. Something related to generic specialisation
/ Valhalla.
Lukas
More information about the jdbc-spec-discuss
mailing list