org.solovyev.android.db.ListMapper Maven / Gradle / Ivy
package org.solovyev.android.db;
import android.database.Cursor;
import org.jetbrains.annotations.NotNull;
import org.solovyev.common.Converter;
import java.util.ArrayList;
import java.util.List;
/**
* User: serso
* Date: 6/3/12
* Time: 4:43 PM
*/
public class ListMapper implements Converter> {
@NotNull
private final Converter elementMapper;
public ListMapper(@NotNull Converter elementMapper) {
this.elementMapper = elementMapper;
}
@NotNull
@Override
public List convert(@NotNull Cursor cursor) {
final List result = new ArrayList();
if (cursor.getCount() > 0) {
while (!cursor.isLast()) {
cursor.moveToNext();
result.add(elementMapper.convert(cursor));
}
}
return result;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy