List of usage examples for java.util LinkedHashSet add
boolean add(E e);
From source file:com.github.rvesse.airline.utils.AirlineUtils.java
public static <T> Set<T> unmodifiableSetCopy(Iterable<T> iterable) { if (iterable == null) return Collections.emptySet(); LinkedHashSet<T> set = new LinkedHashSet<T>(); Iterator<T> iter = iterable.iterator(); while (iter.hasNext()) { set.add(iter.next()); }/*from w ww . ja v a 2 s . com*/ return Collections.unmodifiableSet(set); }
From source file:org.tinygroup.commons.tools.CollectionUtil.java
/** <code>LinkedHashSet</code> */ public static <T, V extends T> LinkedHashSet<T> createLinkedHashSet(V... args) { if (args == null || args.length == 0) { return new LinkedHashSet<T>(); } else {//ww w . j a v a 2 s .co m LinkedHashSet<T> set = new LinkedHashSet<T>(args.length); for (V v : args) { set.add(v); } return set; } }
From source file:ca.uhn.fhir.util.ReflectionUtil.java
public static LinkedHashSet<Method> getDeclaredMethods(Class<?> theClazz) { LinkedHashSet<Method> retVal = new LinkedHashSet<Method>(); for (Method next : theClazz.getDeclaredMethods()) { try {//from ww w.ja va2 s . co m Method method = theClazz.getMethod(next.getName(), next.getParameterTypes()); retVal.add(method); } catch (NoSuchMethodException e) { retVal.add(next); } catch (SecurityException e) { retVal.add(next); } } return retVal; }
From source file:com.shenit.commons.utils.CollectionUtils.java
/** * ?/*from www . j a va 2 s . c o m*/ * @param vals * @return */ public static <T> Set<T> loadSortedSet(T[] vals) { LinkedHashSet<T> set = new LinkedHashSet<>(); for (T v : vals) if (v != null) set.add(v); return set; }
From source file:org.apache.maven.plugin.assembly.format.ReaderFormatter.java
private static Reader createReaderFilter(@Nonnull Reader source, String escapeString, List<String> delimiters, AssemblerConfigurationSource configSource, boolean isPropertiesFile) throws IOException { try {/*w w w . j ava 2 s .c om*/ MavenReaderFilterRequest filterRequest = new MavenReaderFilterRequest(source, true, configSource.getProject(), configSource.getFilters(), isPropertiesFile, null, configSource.getMavenSession(), null); // filterRequest.setInjectProjectBuildFilters(true); filterRequest.setEscapeString(escapeString); // if these are NOT set, just use the defaults, which are '${*}' and '@'. if (delimiters != null && !delimiters.isEmpty()) { LinkedHashSet<String> delims = new LinkedHashSet<String>(); for (String delim : delimiters) { if (delim == null) { // FIXME: ${filter:*} could also trigger this condition. Need a better long-term solution. delims.add("${*}"); } else { delims.add(delim); } } filterRequest.setDelimiters(delims); } else { filterRequest.setDelimiters(filterRequest.getDelimiters()); } filterRequest.setInjectProjectBuildFilters(configSource.isIncludeProjectBuildFilters()); return configSource.getMavenReaderFilter().filter(filterRequest); } catch (MavenFilteringException e) { IOException ioe = new IOException("Error filtering file '" + source + "': " + e.getMessage()); ioe.initCause(e); // plain old Java 5... throw ioe; } }
From source file:org.apache.maven.plugins.assembly.format.ReaderFormatter.java
private static Reader createReaderFilter(@Nonnull Reader source, String escapeString, List<String> delimiters, AssemblerConfigurationSource configSource, boolean isPropertiesFile) throws IOException { try {//from w w w. j a va 2s.c om MavenReaderFilterRequest filterRequest = new MavenReaderFilterRequest(source, true, configSource.getProject(), configSource.getFilters(), isPropertiesFile, configSource.getMavenSession(), null); filterRequest.setEscapeString(escapeString); // if these are NOT set, just use the defaults, which are '${*}' and '@'. if (delimiters != null && !delimiters.isEmpty()) { LinkedHashSet<String> delims = new LinkedHashSet<String>(); for (String delim : delimiters) { if (delim == null) { // FIXME: ${filter:*} could also trigger this condition. Need a better long-term solution. delims.add("${*}"); } else { delims.add(delim); } } filterRequest.setDelimiters(delims); } else { filterRequest.setDelimiters(filterRequest.getDelimiters()); } filterRequest.setInjectProjectBuildFilters(configSource.isIncludeProjectBuildFilters()); return configSource.getMavenReaderFilter().filter(filterRequest); } catch (MavenFilteringException e) { IOException ioe = new IOException("Error filtering file '" + source + "': " + e.getMessage()); ioe.initCause(e); // plain old Java 5... throw ioe; } }
From source file:nl.systemsgenetics.genenetworkbackend.hpo.ImproveHpoPredictionBasedOnChildTerms.java
private static LinkedHashSet<String> readPredictedHpoTermFile(File predictedHpoTermFile) throws FileNotFoundException, IOException { final CSVParser parser = new CSVParserBuilder().withSeparator('\t').withIgnoreQuotations(true).build(); final CSVReader reader = new CSVReaderBuilder(new BufferedReader(new FileReader(predictedHpoTermFile))) .withSkipLines(1).withCSVParser(parser).build(); LinkedHashSet<String> hpos = new LinkedHashSet<>(); String[] nextLine;/*w ww . j a va 2 s. co m*/ while ((nextLine = reader.readNext()) != null) { hpos.add(nextLine[0]); } reader.close(); return hpos; }
From source file:com.offbynull.portmapper.common.NetworkUtils.java
/** * Attempts to put together a list of gateway addresses using pre-set values and running OS-specific processes. * @return a list of possible addresses for gateway device * @throws InterruptedException if interrupted */// w w w .ja v a 2 s . c om public static Set<InetAddress> getPotentialGatewayAddresses() throws InterruptedException { // Ask OS for gateway address String netstatOutput = ""; try { netstatOutput = ProcessUtils.runProcessAndDumpOutput(5000L, "netstat", "-rn"); } catch (IOException ioe) { // NOPMD // do nothing if (Thread.currentThread().isInterrupted()) { throw new InterruptedException(); } } LinkedHashSet<String> strAddresses = new LinkedHashSet<>(RegexUtils.findAllIpv4Addresses(netstatOutput)); // Push in defaults strAddresses.addAll(PRESET_IPV4_GATEWAY_ADDRESSES); LinkedHashSet<InetAddress> addresses = new LinkedHashSet<>(); for (String strAddress : strAddresses) { try { InetAddress addr = InetAddress.getByName(strAddress); if (!addr.isAnyLocalAddress()) { addresses.add(addr); } } catch (UnknownHostException uhe) { // NOPMD // do nothing } } return addresses; }
From source file:azkaban.utils.PropsUtils.java
public static Props resolveProps(Props props) { if (props == null) return null; Props resolvedProps = new Props(); LinkedHashSet<String> visitedVariables = new LinkedHashSet<String>(); for (String key : props.getKeySet()) { String value = props.get(key); visitedVariables.add(key); String replacedValue = resolveVariableReplacement(value, props, visitedVariables); visitedVariables.clear();/*from w ww.ja v a 2 s .c om*/ resolvedProps.put(key, replacedValue); } for (String key : resolvedProps.getKeySet()) { String value = resolvedProps.get(key); String expressedValue = resolveVariableExpression(value); resolvedProps.put(key, expressedValue); } return resolvedProps; }
From source file:com.vaadin.sass.testcases.scss.W3ConformanceTests.java
protected static Collection<URI> scrapeIndexForTests(String url, String regexp, int maxTests, Collection<URI> excludeUrls) throws Exception { URI baseUrl = new URI(url); Document doc = Jsoup.connect(url).timeout(10000).get(); Elements elems = doc.select(String.format("a[href~=%s]", regexp)); LinkedHashSet<URI> tests = new LinkedHashSet<URI>(); for (Element e : elems) { URI testUrl = new URI(e.attr("href")); if (!testUrl.isAbsolute()) { testUrl = baseUrl.resolve(testUrl); }//from www .ja v a 2 s .com if (tests.size() < maxTests) { if (!excludeUrls.contains(testUrl)) { tests.add(testUrl); } } else { break; } } return tests; }