List of usage examples for java.util Collections addAll
@SafeVarargs public static <T> boolean addAll(Collection<? super T> c, T... elements)
From source file:com.rockagen.commons.util.ClassUtil.java
/** * obtain fields list of specified class If recursively is true, obtain * fields from all class hierarchy// ww w . j a v a 2s.c o m * * @param clazz class * where fields are searching * @param recursively * param * @return array of fields */ public static Field[] getDeclaredFields(Class<?> clazz, boolean recursively) { List<Field> fields = new LinkedList<Field>(); Field[] declaredFields = clazz.getDeclaredFields(); Collections.addAll(fields, declaredFields); Class<?> superClass = clazz.getSuperclass(); if (superClass != null && recursively) { Field[] declaredFieldsOfSuper = getDeclaredFields(superClass, true); if (declaredFieldsOfSuper.length > 0) Collections.addAll(fields, declaredFieldsOfSuper); } return fields.toArray(new Field[fields.size()]); }
From source file:com.cleverCloud.cleverIdea.vcs.CleverCheckoutProvider.java
private List<Application> getApplicationsFromOrga(@NotNull Project project) { CcApi ccApi = CcApi.getInstance(project); String json = ccApi.apiRequest("/self/applications"); assert json != null; List<Application> applicationsList = new ArrayList<>(); Application[] applications = getApplications(json); if (applications != null) Collections.addAll(applicationsList, applications); json = ccApi.apiRequest("/self"); HashMap hashMap;/*from www . j a v a 2 s .c o m*/ try { hashMap = JacksonUtils.jsonToMap(json); } catch (IOException e) { e.printStackTrace(); return null; } String userId = (String) hashMap.get("id"); json = ccApi.apiRequest("/organisations?user=" + userId); ObjectMapper mapper = new ObjectMapper(); Organisation[] organisations; try { organisations = mapper.readValue(json, Organisation[].class); } catch (@NotNull IOException | NullPointerException e) { e.printStackTrace(); return null; } for (Organisation organisation : organisations) { applications = organisation.getChildren(project); if (applications != null) Collections.addAll(applicationsList, applications); } return applicationsList; }
From source file:de.Keyle.MyPet.api.util.inventory.IconMenuItem.java
public IconMenuItem addLoreLine(String line, int position) { Validate.notNull(line, "Lore line cannot be null"); if (line.contains("\n")) { List<String> lore = new LinkedList<>(); Collections.addAll(lore, line.split("\n")); Collections.reverse(lore); for (String l : lore) { this.lore.add(position, l); }// w ww . jav a 2 s . c o m } else { this.lore.add(position, line); } hasChanged = true; return this; }
From source file:org.neo4j.nlp.examples.wikipedia.main.java
private static void trainOnText(String[] text, String[] label) { List<String> labelSet = new ArrayList<>(); List<String> textSet = new ArrayList<>(); Collections.addAll(labelSet, label); Collections.addAll(textSet, text); JsonArray labelArray = new JsonArray(); JsonArray textArray = new JsonArray(); labelSet.forEach((s) -> labelArray.add(new JsonPrimitive(s))); textSet.forEach((s) -> textArray.add(new JsonPrimitive(s))); JsonObject jsonParam = new JsonObject(); jsonParam.add("text", textArray); jsonParam.add("label", labelArray); jsonParam.add("focus", new JsonPrimitive(2)); String jsonPayload = new Gson().toJson(jsonParam); executePost("http://localhost:7474/service/graphify/training", jsonPayload); }
From source file:com.geewhiz.pacify.test.TestUtil.java
private static List<File> getFiles(File folder) { List<File> files = new ArrayList<File>(); Collections.addAll(files, folder.listFiles(new FileFilter() { public boolean accept(File pathName) { return pathName.isFile(); }/*from w w w .j a v a2s. c o m*/ })); for (File subFolder : folder.listFiles(new DirFilter())) { files.addAll(getFiles(subFolder)); } return files; }
From source file:de.thingweb.servient.impl.MultiBindingThingServer.java
protected void init(ResourceBuilder[] bindings) { Collections.addAll(m_bindings, bindings); m_bindings.forEach(resourceBuilder -> resourceBuilder.newResource(Defines.BASE_URL, new HypermediaIndex(new HyperMediaLink("things", Defines.BASE_THING_URL)))); }
From source file:kina.entity.Cells.java
/** * Builds a new Cells object containing the provided cells belonging to <i>table</i>. Sets the * provided table name as the default table. * //from w w w .j a va 2 s. c o m * @param cells the array of Cells we want to use to create the Cells object. */ public Cells(String defaultTableName, Cell... cells) { this.defaultTableName = defaultTableName; if (StringUtils.isEmpty(defaultTableName)) { throw new IllegalArgumentException("table name cannot be null"); } Collections.addAll(getCellsByTable(defaultTableName), cells); }
From source file:org.neo4j.nlp.examples.sentiment.main.java
private static void trainOnText(String[] text, String[] label) { List<String> labelSet = new ArrayList<>(); List<String> textSet = new ArrayList<>(); Collections.addAll(labelSet, label); Collections.addAll(textSet, text); JsonArray labelArray = new JsonArray(); JsonArray textArray = new JsonArray(); labelSet.forEach((s) -> labelArray.add(new JsonPrimitive(s))); textSet.forEach((s) -> textArray.add(new JsonPrimitive(s))); JsonObject jsonParam = new JsonObject(); jsonParam.add("text", textArray); jsonParam.add("label", labelArray); jsonParam.add("focus", new JsonPrimitive(1)); String jsonPayload = new Gson().toJson(jsonParam); System.out.println(executePost("http://localhost:7474/service/graphify/training", jsonPayload)); }
From source file:com.withinet.opaas.controller.system.impl.PaxJavaRunner.java
private String[] createEnvironmentVars(String[] envOptions) { List<String> env = new ArrayList<String>(); Map<String, String> getenv = System.getenv(); for (String key : getenv.keySet()) { env.add(key + "=" + getenv.get(key)); }//from w ww .j a v a2s. co m if (envOptions != null) Collections.addAll(env, envOptions); return env.toArray(new String[env.size()]); }
From source file:com.almende.dht.Bucket.java
/** * Gets the closest nodes.//from w w w.j av a 2 s . com * * @param near * the near * @param limit * the limit * @param filter * the filter * @return the closest nodes */ public List<Node> getClosestNodes(final Key near, final int limit, final Key[] filter) { final Set<Key> set = new HashSet<Key>(filter.length); Collections.addAll(set, filter); return getClosestNodes(near, limit, set); }