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.p5solutions.core.utils.ReflectionUtility.java
/** * Find fields.//w ww . ja v a2 s .c o m * * @param clazz * the clazz * @return the list */ public static List<Field> findFields(Class<?> clazz) { List<Field> array = new ArrayList<Field>(); Field[] fields = clazz.getDeclaredFields(); // add all the fields within this class Collections.addAll(array, fields); // check for super classes and fields Class<?> superClazz = clazz.getSuperclass(); if (!superClazz.equals(Object.class)) { List<Field> superArray = findFields(superClazz); array.addAll(superArray); } return array; }
From source file:com.cloud.network.resource.NccHttpCode.java
public static String cleanPassword(String logString) { String cleanLogString = null; if (logString != null) { cleanLogString = logString;/*from w w w. j a va2 s.com*/ String[] temp = logString.split(","); int i = 0; if (temp != null) { while (i < temp.length) { temp[i] = StringUtils.cleanString(temp[i]); i++; } List<String> stringList = new ArrayList<String>(); Collections.addAll(stringList, temp); cleanLogString = StringUtils.join(stringList, ","); } } return cleanLogString; }
From source file:net.firejack.platform.core.config.meta.construct.ConfigElementFactory.java
private RelationshipConfigElement populateRelationship(String name, String hint, RelationshipType relType, Reference source, Reference target, IFieldElement... fields) { name = WordUtils.capitalize(name);//from w w w. jav a 2 s . c o m RelationshipConfigElement rel = new RelationshipConfigElement(name); //checkElementName(rel); normalizeName(rel); rel.setHint(hint); rel.setType(relType); rel.setSource(source); rel.setTarget(target); if (fields.length != 0) { List<IFieldElement> fieldList = new ArrayList<IFieldElement>(); Collections.addAll(fieldList, fields); rel.setFields(fieldList); } return rel; }
From source file:literarytermsquestionbank.AChristmasCarol.java
private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened // Set window icon this.setIconImage(Toolkit.getDefaultToolkit() .getImage(getClass().getResource("/Resources/Images/book-icon_acc.png"))); // Set custom fonts try {//from w w w .j ava 2s . c o m GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); // Load Gill Sans from resources Font gillSansFontFace = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("/Resources/Fonts/GILLSANS.TTF")); ge.registerFont(gillSansFontFace); tabbedPane.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 14f)); questionLabel.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 18f)); checkButton.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 14f)); youAreViewingLabel.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 18f)); quoteIndexTextField.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 24f)); totalNumberLabel.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 36f)); goButton.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 20f)); randomButton.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 20f)); backButton.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 14f)); clueLabel.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 14f)); passageLabel.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 18f)); exampleLabel.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 18f)); commentsLabel.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 14f)); realAnswerLabel.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 14f)); realAnswerTitleLabel.setFont(gillSansFontFace.deriveFont(Font.PLAIN, 18f)); // Load the FreeStyle Script font from resources Font freeStyleFontFace = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("/Resources/Fonts/FREESCPT.TTF")); ge.registerFont(freeStyleFontFace); salutationLabel.setFont(freeStyleFontFace.deriveFont(Font.PLAIN, 30f)); signatureLabel.setFont(freeStyleFontFace.deriveFont(Font.PLAIN, 30f)); } catch (FontFormatException ex) { Logger.getLogger(RomeoAndJuliet.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(RomeoAndJuliet.class.getName()).log(Level.SEVERE, null, ex); } JSONParser parser = new JSONParser(); try { // This object is the result of parsing the JSON file at the relative filepath as defined above; the JSON file is in the Resources source package. Object quoteObj = parser .parse(new InputStreamReader(getClass().getResourceAsStream("/Resources/Files/db.json"))); // This casts the object to a JSONObject for future manipulation JSONObject jsonObject = (JSONObject) quoteObj; // This array holds all the quotes JSONArray quotesArray = (JSONArray) jsonObject.get("A Christmas Carol"); Iterator<JSONObject> iterator = quotesArray.iterator(); // Using the iterator as declared above, add each JSONObject in the Romeo and Juliet array to the ArrayList while (iterator.hasNext()) { Collections.addAll(quotesList, iterator.next()); totalNumberOfQuotes++; } // Init randomizer Random rand = new Random(); // Generate a random integer between 1 and size of the ArrayList quoteIndex = rand.nextInt(quotesList.size()) + 1; generateQuote(quoteIndex); // This calls a method to generate a quote and display it } catch (Exception e) { // This means something went very wrong when starting the program System.out.println("Uh oh, something bad happened. Possible database corruption."); JOptionPane.showMessageDialog(null, "Something went wrong while starting the app! Please tell Aaron with code 129.", "Uh-oh!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } }
From source file:literarytermsquestionbank.ShortStories.java
private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened // Set window icon this.setIconImage( Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Resources/Images/book-icon_ss.png"))); // Set custom fonts try {// w w w . j a v a 2s . co m GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); // Load Great Vibes from resources Font bradleyFontFace = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("/Resources/Fonts/BRADHITC.TTF")); ge.registerFont(bradleyFontFace); questionLabel.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 30f)); checkButton.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 36f)); stuckLabel.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 24f)); rescueButton.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 18f)); answerLabel.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 18f)); youAreViewingLabel.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 18f)); quoteIndexTextField.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 18f)); totalNumberLabel.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 36f)); goButton.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 18f)); randomButton.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 18f)); previousButton.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 18f)); nextButton.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 18f)); backButton.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 24f)); clueTitleLabel.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 24f)); clueLabel.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 30f)); passageLabel.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 30f)); examplesLabel.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 30f)); commentsLabel.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 30f)); storyLabel.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 20f)); tabbedPane.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 18f)); menuTitleLabel.setFont(bradleyFontFace.deriveFont(Font.PLAIN, 18f)); // Load and set Imprint font face Font imprintFontFace = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("/Resources/Fonts/IMPRISHA.TTF")); ge.registerFont(imprintFontFace); quoteTopLabel.setFont(imprintFontFace.deriveFont(Font.PLAIN, 48f)); quoteBottomLabel.setFont(imprintFontFace.deriveFont(Font.PLAIN, 48f)); } catch (FontFormatException ex) { Logger.getLogger(RomeoAndJuliet.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(RomeoAndJuliet.class.getName()).log(Level.SEVERE, null, ex); } JSONParser parser = new JSONParser(); try { // This object is the result of parsing the JSON file at the relative filepath as defined above; the JSON file is in the Resources source package. Object quoteObj = parser .parse(new InputStreamReader(getClass().getResourceAsStream("/Resources/Files/db.json"))); // This casts the object to a JSONObject for future manipulation JSONObject jsonObject = (JSONObject) quoteObj; // This array holds all the quotes JSONArray quotesArray = (JSONArray) jsonObject.get("Short Stories"); Iterator<JSONObject> iterator = quotesArray.iterator(); // Using the iterator as declared above, add each JSONObject in the Romeo and Juliet array to the ArrayList while (iterator.hasNext()) { Collections.addAll(quotesList, iterator.next()); totalNumberOfQuotes++; } // Init randomizer Random rand = new Random(); // Generate a random integer between 1 and size of the ArrayList quoteIndex = rand.nextInt(quotesList.size()) + 1; generateQuote(quoteIndex); // This calls a method to generate a quote and display it } catch (Exception e) { // This means something went very wrong when starting the program System.out.println("Uh oh, something bad happened. Possible database corruption."); JOptionPane.showMessageDialog(null, "Something went wrong while starting the app! Please tell Aaron with code 129.", "Uh-oh!", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } }
From source file:io.restassured.module.mockmvc.internal.MockMvcRequestSpecificationImpl.java
public MockMvcRequestSpecification resultHandlers(ResultHandler resultHandler, ResultHandler... resultHandlers) { notNull(resultHandler, ResultHandler.class); this.resultHandlers.add(resultHandler); if (resultHandlers != null && resultHandlers.length >= 1) { Collections.addAll(this.resultHandlers, resultHandlers); }/* ww w. ja v a 2s .c om*/ return this; }
From source file:com.evolveum.midpoint.gui.api.util.WebComponentUtil.java
public static <T extends Enum> IModel<List<T>> createReadonlyModelFromEnum(final Class<T> type) { return new AbstractReadOnlyModel<List<T>>() { @Override/*ww w . ja v a 2 s.c o m*/ public List<T> getObject() { List<T> list = new ArrayList<>(); Collections.addAll(list, type.getEnumConstants()); return list; } }; }
From source file:de.cismet.lagis.cidsmigtest.CustomBeanToStringTester.java
/** * DOCUMENT ME!/* ww w .j av a 2 s . c om*/ * * @param object DOCUMENT ME! * * @return DOCUMENT ME! */ public static String getStringOf(final Collection<? extends CidsBean> object) { final StringBuilder sb = new StringBuilder("\n" + tab() + "[Collection |"); if (object != null) { final List<CidsBean> sortedList = new ArrayList<CidsBean>(); Collections.addAll(sortedList, object.toArray(new CidsBean[0])); Collections.sort(sortedList, new Comparator<CidsBean>() { @Override public int compare(final CidsBean o1, final CidsBean o2) { return o1.getMetaObject().getId() - o2.getMetaObject().getId(); } }); for (final CidsBean item : sortedList) { sb.append(getStringOf(item)).append("\n"); } } sb.append("\n").append(untab()).append("]"); return sb.toString(); }
From source file:org.apache.solr.client.solrj.impl.BasicHttpSolrClientTest.java
private Set<String> setOf(String... keys) { Set<String> set = new TreeSet<>(); if (keys != null) { Collections.addAll(set, keys); }//from ww w . ja v a2 s. c o m return set; }
From source file:SwingWorker.java
/** * appends arguments and sends this {@cod Runnable} for the * execution if needed.//from w w w . j av a2s . c om * <p> * This implementation uses {@see #submit} to send this * {@code Runnable} for execution. * @param args the arguments to accumulate */ public final synchronized void add(T... args) { if (componentType == null) { componentType = (Class<T>) args.getClass().getComponentType(); } boolean isSubmitted = true; if (arguments == null) { isSubmitted = false; arguments = new ArrayList<T>(); } Collections.addAll(arguments, args); if (!isSubmitted) { submit(); } }