コード例 #1
0
ファイル: ResultImpl.java プロジェクト: kxa/jOOQ
  @Override
  public final <E> Map<Record, List<E>> intoGroups(Field<?>[] keys, Class<? extends E> type) {
    if (keys == null) {
      keys = new Field[0];
    }

    Map<Record, List<E>> map = new LinkedHashMap<Record, List<E>>();
    FieldList keyList = new FieldList(keys);

    for (R record : this) {

      @SuppressWarnings("rawtypes")
      Record key = new RecordImpl(keyList);

      for (Field<?> field : keys) {
        Utils.setValue(key, field, record, field);
      }

      List<E> list = map.get(key);
      if (list == null) {
        list = new ArrayList<E>();
        map.put(key, list);
      }

      list.add(record.into(type));
    }

    return map;
  }
コード例 #2
0
ファイル: ResultImpl.java プロジェクト: suhabe/jOOQ
  @Override
  public final <Z extends Record> Result<Z> into(Table<Z> table) {
    Result<Z> list = new ResultImpl<Z>(getConfiguration(), table.fields());

    for (R record : this) {
      list.add(record.into(table));
    }

    return list;
  }
コード例 #3
0
ファイル: ResultImpl.java プロジェクト: kxa/jOOQ
  @Override
  public final <T> List<T> into(Class<? extends T> type) {
    List<T> list = new ArrayList<T>(size());

    for (R record : this) {
      list.add(record.into(type));
    }

    return list;
  }
コード例 #4
0
ファイル: ResultImpl.java プロジェクト: kxa/jOOQ
  @SuppressWarnings("unchecked")
  @Override
  public final <K, E> Map<K, E> intoMap(Field<K> key, Class<? extends E> type) {
    int index = getIndex(key);
    Map<K, E> map = new LinkedHashMap<K, E>();

    for (R record : this) {
      if (map.put((K) record.getValue(index), record.into(type)) != null) {
        throw new InvalidResultException("Key " + key + " is not unique in Result for " + this);
      }
    }

    return map;
  }
コード例 #5
0
ファイル: ResultImpl.java プロジェクト: kxa/jOOQ
  @SuppressWarnings("unchecked")
  @Override
  public final <K, E> Map<K, List<E>> intoGroups(Field<K> key, Class<? extends E> type) {
    int index = getIndex(key);
    Map<K, List<E>> map = new LinkedHashMap<K, List<E>>();

    for (R record : this) {
      K keyVal = (K) record.getValue(index);

      List<E> list = map.get(keyVal);
      if (list == null) {
        list = new ArrayList<E>();
        map.put(keyVal, list);
      }

      list.add(record.into(type));
    }

    return map;
  }
コード例 #6
0
ファイル: ResultImpl.java プロジェクト: kxa/jOOQ
  @Override
  public final <E> Map<List<?>, E> intoMap(Field<?>[] keys, Class<? extends E> type) {
    if (keys == null) {
      keys = new Field[0];
    }

    Map<List<?>, E> map = new LinkedHashMap<List<?>, E>();

    for (R record : this) {
      List<Object> keyValueList = new ArrayList<Object>();
      for (Field<?> key : keys) {
        keyValueList.add(record.getValue(key));
      }

      if (map.put(keyValueList, record.into(type)) != null) {
        throw new InvalidResultException(
            "Key list " + keyValueList + " is not unique in Result for " + this);
      }
    }

    return map;
  }
コード例 #7
0
 @Override
 public final <E> E fetchOneInto(Class<? extends E> clazz) {
   R record = fetchOne();
   return record == null ? null : record.into(clazz);
 }