[#3760] Add Record.intoList()

This commit is contained in:
lukaseder 2014-11-11 18:21:58 +01:00
parent 8fa9878f42
commit 83cebee0eb
2 changed files with 22 additions and 0 deletions

View File

@ -46,6 +46,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLData;
import java.sql.Statement;
import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
@ -683,6 +684,21 @@ public interface Record extends Attachable, Comparable<Record> {
*/
Object[] intoArray();
/**
* Convert this record into a list.
* <p>
* The resulting list has the same number of elements as this record has
* fields. The resulting array contains data as such:
* <p>
* <code><pre>
* // For arbitrary values of i
* record.getValue(i) == record.intoList().get(i)
* </pre></code>
* <p>
* This is the same as calling <code>Arrays.asList(intoArray())</code>
*/
List<Object> intoList();
/**
* Return this record as a name/value map.
* <p>

View File

@ -55,6 +55,7 @@ import static org.jooq.impl.Utils.settings;
import java.lang.reflect.Method;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collection;
import java.util.LinkedHashMap;
@ -523,6 +524,11 @@ abstract class AbstractRecord extends AbstractStore implements Record {
return into(Object[].class);
}
@Override
public final List<Object> intoList() {
return Arrays.asList(intoArray());
}
@Override
public final Map<String, Object> intoMap() {
Map<String, Object> map = new LinkedHashMap<String, Object>();