com.rapleaf.jack.queries.Records Maven / Gradle / Ivy
package com.rapleaf.jack.queries;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Stream;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.rapleaf.jack.AttributesWithId;
import com.rapleaf.jack.GenericDatabases;
import com.rapleaf.jack.ModelWithId;
import com.rapleaf.jack.tracking.QueryStatistics;
public class Records implements Iterable {
private final List records;
private QueryStatistics queryStatistics;
Records() {
this.records = Lists.newArrayList();
}
void addRecord(Record record) {
records.add(record);
}
void addStatistics(QueryStatistics statistics) {
this.queryStatistics = statistics;
}
public boolean isEmpty() {
return records.isEmpty();
}
public int size() {
return records.size();
}
public Record get(int index) {
return records.get(index);
}
public List gets(Column column) {
List results = Lists.newArrayList();
for (Record record : records) {
results.add(record.get(column));
}
return results;
}
public List getInts(Column column) {
List results = Lists.newArrayList();
for (Record record : records) {
results.add(record.getInt(column));
}
return results;
}
public List getIntsFromLongs(Column column) {
List results = Lists.newArrayList();
for (Record record : records) {
results.add(record.getIntFromLong(column));
}
return results;
}
public List getLongs(Column column) {
List results = Lists.newArrayList();
for (Record record : records) {
results.add(record.getLong(column));
}
return results;
}
public List getStrings(Column column) {
List results = Lists.newArrayList();
for (Record record : records) {
results.add(record.getString(column));
}
return results;
}
public List getByteArrays(Column column) {
List results = Lists.newArrayList();
for (Record record : records) {
results.add(record.getByteArray(column));
}
return results;
}
public List getDoubles(Column column) {
List results = Lists.newArrayList();
for (Record record : records) {
results.add(record.getDouble(column));
}
return results;
}
public List getBooleans(Column column) {
List results = Lists.newArrayList();
for (Record record : records) {
results.add(record.getBoolean(column));
}
return results;
}
public List getAttributes(AbstractTable tableType) {
List results = Lists.newArrayList();
for (Record record : records) {
results.add(record.getAttributes(tableType));
}
return results;
}
public List getModels(AbstractTable tableType, D databases) {
List results = Lists.newArrayList();
for (Record record : records) {
results.add(record.getModel(tableType, databases));
}
return results;
}
public QueryStatistics getQueryStatistics() {
return queryStatistics;
}
public Stream stream() {
return records.stream();
}
@Override
public Iterator iterator() {
return records.iterator();
}
public List getRecords() {
return records;
}
@Override
public String toString() {
return getClass().getSimpleName() +
"{" +
"records: " + Joiner.on(", ").join(records) +
", statistics: " + queryStatistics.toString() +
"}";
}
@Override
public int hashCode() {
return records.hashCode();
}
@Override
public boolean equals(Object that) {
return that instanceof Records && ((Records)that).records.equals(this.records);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy