List of usage examples for java.util List addAll
boolean addAll(Collection<? extends E> c);
From source file:wiki.doc.DocResource.java
public static List<DocId> getAllLinking(List<DocId> docs, DbConnector dbc) { if (docs.size() == 0) { return new ArrayList<>(0); } else if (docs.size() <= 30000) { String inList = getParamList(docs.size()); String sql = "SELECT pages.id FROM pages " + "INNER JOIN links ON links.fromPage = pages.id " + "WHERE links.toPage IN " + inList; Object[] ids = docs.stream().map((doc) -> doc.id).toArray(); return dbc.jdbcTemplate.query(sql, ids, docIdMapper); } else {//from w ww . j av a2s . c om List<DocId> first = getAllLinking(docs.subList(0, 30000), dbc); first.addAll(getAllLinking(docs.subList(30000, docs.size()), dbc)); return first; } }
From source file:wiki.doc.DocResource.java
public static List<DocId> getAllLinkedDocs(List<DocId> docs, DbConnector dbc) { if (docs.size() == 0) { return new ArrayList<>(0); } else if (docs.size() <= 30000) { String inList = getParamList(docs.size()); String sql = "SELECT pages.id FROM pages " + "INNER JOIN links ON links.toPage = pages.id " + "WHERE links.fromPage IN " + inList; Object[] ids = docs.stream().map((doc) -> doc.id).toArray(); return dbc.jdbcTemplate.query(sql, ids, docIdMapper); } else {//from w ww . j av a 2s. co m List<DocId> first = getAllLinkedDocs(docs.subList(0, 30000), dbc); first.addAll(getAllLinkedDocs(docs.subList(30000, docs.size()), dbc)); return first; } }
From source file:com.kevinquan.google.activityrecoginition.model.MotionHelper.java
public static List<MotionSnapshot> parseMotionSnapshots(Cursor result, final boolean sortDescending) { if (!CursorUtils.hasResults(result)) { Log.d(TAG, "No results were provided to parse motion snapshots from"); return new ArrayList<MotionSnapshot>(); }/*from ww w . j a v a 2s. com*/ Hashtable<Long, MotionSnapshot> snapshots = new Hashtable<Long, MotionSnapshot>(); do { Motion thisMotion = new Motion(result); if (thisMotion.getTimestamp() == 0) { Log.w(TAG, "Current motion seems corrupt: " + thisMotion); continue; } if (!snapshots.containsKey(thisMotion.getTimestamp())) { MotionSnapshot snapshot = new MotionSnapshot(thisMotion); snapshots.put(snapshot.getTimestamp(), snapshot); } else { if (!snapshots.get(thisMotion.getTimestamp()).addMotion(thisMotion)) { Log.w(TAG, "Could not add motion to snapshot: " + thisMotion.toString()); } } } while (result.moveToNext()); List<MotionSnapshot> results = new ArrayList<MotionSnapshot>(); results.addAll(snapshots.values()); Collections.sort(results, new Comparator<MotionSnapshot>() { @Override public int compare(MotionSnapshot lhs, MotionSnapshot rhs) { int result = ((Long) lhs.getTimestamp()).compareTo((Long) rhs.getTimestamp()); return sortDescending ? -1 * result : result; } }); return results; }
From source file:Main.java
public static <T> List<T> appendAllList(List<T> list, Collection<? extends T> c) { if (list == null) { list = new ArrayList<T>(1); }/* ww w. j ava2s . c om*/ if (c != null && c.size() > 0) { list.addAll(c); } return list; }
From source file:es.emergya.consultas.FlotaConsultas.java
@Transactional public static String[] getAllFilter() { List<String> res = new ArrayList<String>(); res.add("");//from w w w.j av a2 s. co m res.addAll(flotaHome.getAllNamesHabilitadas()); return res.toArray(new String[0]); }
From source file:es.emergya.consultas.FlotaConsultas.java
public static Flota[] getAllHabilitadas() { List<Flota> res = new ArrayList<Flota>(); // res.add(null); res.addAll(flotaHome.getAllHabilitadas()); return res.toArray(new Flota[0]); }
From source file:gumga.framework.application.GumgaUntypedRepository.java
public static List<Field> getTodosAtributos(Class classe) throws SecurityException { List<Field> aRetornar = new ArrayList<>(); if (!classe.getSuperclass().equals(Object.class)) { aRetornar.addAll(getTodosAtributos(classe.getSuperclass())); }//w w w . j av a 2s.c o m aRetornar.addAll(Arrays.asList(classe.getDeclaredFields())); return aRetornar; }
From source file:Main.java
public static LinkedHashMap<String, String> convertBeans(Object bean) { if (bean == null) return null; try {//from ww w . j a v a 2 s . c o m LinkedHashMap<String, String> returnMap = new LinkedHashMap<String, String>(); Class<? extends Object> clazz = bean.getClass(); List<Field> fleids = new ArrayList<Field>(); for (Class<?> c = clazz; c != Object.class; c = c.getSuperclass()) { fleids.addAll(Arrays.asList(c.getDeclaredFields())); } for (Field field : fleids) { String value = ""; field.setAccessible(true); try { Object result = field.get(bean); if (result == null) continue; value = result.toString(); } catch (IllegalAccessException e) { e.printStackTrace(); } // MLogUtil.e("field.getName() "+field.getName()); // MLogUtil.e("value "+value); returnMap.put(field.getName(), value); field.setAccessible(false); } return returnMap; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:com.firewallid.util.FIUtils.java
public static <U, V extends Number> List<Tuple2<U, Double>> sumList(List<Tuple2<U, V>> l1, List<Tuple2<U, V>> l2) { l1.addAll(l2); List<Tuple2<U, Double>> sum = l1.parallelStream() .collect(Collectors/*from ww w . j a va 2 s.c o m*/ .groupingBy(data -> data._1(), Collectors.mapping(data -> data._2(), Collectors.toList()))) .entrySet().parallelStream() .map(data -> new Tuple2<>(data.getKey(), data.getValue().parallelStream().mapToDouble(value -> value.doubleValue()).sum())) .collect(Collectors.toList()); return sum; }
From source file:Main.java
public static Map<String, String> convertBean(Object bean) { if (bean == null) return null; try {/* w ww . ja v a 2 s .co m*/ Class<? extends Object> clazz = bean.getClass(); Map<String, String> returnMap = new HashMap<String, String>(); List<Field> fleids = new ArrayList<Field>(); for (Class<?> c = clazz; c != Object.class; c = c.getSuperclass()) { fleids.addAll(Arrays.asList(c.getDeclaredFields())); } for (Field field : fleids) { String value = ""; field.setAccessible(true); try { Object result = field.get(bean); if (result == null) continue; value = result.toString(); } catch (IllegalAccessException e) { e.printStackTrace(); } // MLogUtil.e("field.getName() "+field.getName()); // MLogUtil.e("value "+value); returnMap.put(field.getName(), value); field.setAccessible(false); } return returnMap; } catch (Exception e) { e.printStackTrace(); return null; } }