List of usage examples for java.util LinkedHashSet LinkedHashSet
public LinkedHashSet()
From source file:io.fabric8.vertx.maven.plugin.utils.WebJars.java
/** * Checks whether the given file is a WebJar or not (http://www.webjars.org/documentation). * The check is based on the presence of {@literal META-INF/resources/webjars/} directory in the jar file. * * @param file the file.//from w ww . j a va 2s. c o m * @return {@literal true} if it's a bundle, {@literal false} otherwise. */ public static boolean isWebJar(Log log, File file) { if (file == null) { return false; } Set<String> found = new LinkedHashSet<>(); if (file.isFile() && file.getName().endsWith(".jar")) { JarFile jar = null; try { jar = new JarFile(file); // Fast return if the base structure is not there if (jar.getEntry(WEBJAR_LOCATION) == null) { return false; } Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); Matcher matcher = WEBJAR_REGEX.matcher(entry.getName()); if (matcher.matches()) { found.add(matcher.group(1) + "-" + matcher.group(2)); } } } catch (IOException e) { log.error("Cannot check if the file " + file.getName() + " is a webjar, cannot open it", e); return false; } finally { final JarFile finalJar = jar; IOUtils.closeQuietly(() -> { if (finalJar != null) { finalJar.close(); } }); } for (String lib : found) { log.info("Web Library found in " + file.getName() + " : " + lib); } return !found.isEmpty(); } return false; }
From source file:net.nifheim.beelzebu.coins.common.utils.dependencies.DependencyManager.java
public static void loadAllDependencies() { Set<Dependency> dependencies = new LinkedHashSet<>(); dependencies.addAll(Arrays.asList(Dependency.values())); if (classExists("org.sqlite.JDBC") || core.isBungee()) { dependencies.remove(Dependency.SQLITE_DRIVER); }/*w w w . j av a 2s . com*/ if (classExists("com.mysql.jdbc.Driver")) { dependencies.remove(Dependency.MYSQL_DRIVER); } if (classExists("org.slf4j.Logger") && classExists("org.slf4j.LoggerFactory")) { dependencies.remove(Dependency.SLF4J_API); dependencies.remove(Dependency.SLF4J_SIMPLE); } if (classExists("org.apache.commons.io.FileUtils")) { dependencies.remove(Dependency.COMMONS_IO); } if (!dependencies.isEmpty()) { loadDependencies(dependencies); } }
From source file:de.vandermeer.skb.interfaces.coin.HeadsSuccessWithWarnings.java
/** * Creates a new success coin with given value and warnings. * @param <R> type of the return value * @param <M> the message type for the set * @param value the actual return value/*from w w w .ja v a 2 s. c o m*/ * @return new success coin */ static <R, M> HeadsSuccessWithWarnings<R, M> create(final R value) { return new HeadsSuccessWithWarnings<R, M>() { final Set<M> warningSet = new LinkedHashSet<>(); @Override public R getReturn() { return value; } @Override public Set<M> getWarningMessages() { return this.warningSet; } }; }
From source file:ca.on.oicr.pde.tools.BEDFileUtils.java
/** * Gets the set (no duplicates) of chromosomes from a bed file. * * @param bedFilePath Path to the bed file. * * @return The set of chromosomes (no duplicates) * * @throws FileNotFoundException, IOException *//* w ww . j a va 2s.c o m*/ public static Set<String> getChromosomes(String bedFilePath) throws FileNotFoundException, IOException { Set<String> chrs = new LinkedHashSet<>(); File bedFile = FileUtils.getFile(bedFilePath); try (InputStream is = new FileInputStream(bedFile); AsciiLineReader alr = new AsciiLineReader(is); LineIteratorImpl lineIterator = new LineIteratorImpl(alr);) { BEDCodec bc = new BEDCodec(); while (!bc.isDone(lineIterator)) { BEDFeature bf = bc.decode(lineIterator); if (bf != null) { //see https://github.com/samtools/htsjdk/issues/197 chrs.add(bf.getContig()); } } } return chrs; }
From source file:net.audumla.climate.ClimateDataFactory.java
/** * Replaces the climate data with a readonly version. * * @param cd the existing climate data bean * @return the climate data//from w w w .j ava2 s . c o m */ public static ClimateData convertToReadOnlyClimateData(ClimateData cd) { if (cd == null) { return null; } Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>(); interfaces.addAll(ClassUtils.getAllInterfaces(cd.getClass())); interfaces.remove(WritableClimateData.class); return BeanUtils.convertBean(cd, interfaces.toArray(new Class<?>[interfaces.size()])); }
From source file:com.joyent.manta.client.MantaObjectDepthComparatorTest.java
private static void assertOrdering(final List<MantaObject> sorted) { Set<String> parentDirs = new LinkedHashSet<>(); int index = 0; for (MantaObject obj : sorted) { if (obj.isDirectory()) { String parentDir = Paths.get(obj.getPath()).getParent().toString(); Assert.assertFalse(parentDirs.contains(parentDir), "The parent of this directory was encountered before " + "this directory [index=" + index + "]."); parentDirs.remove(obj.getPath()); } else {/*w w w .j a v a 2 s. c o m*/ String fileParentDir = Paths.get(obj.getPath()).getParent().toString(); Assert.assertFalse(parentDirs.contains(fileParentDir), "Parent directory path was returned before file path. " + "Index [" + index + "] was out of order. " + "Actual sorting:\n" + StringUtils.join(sorted, "\n")); } index++; } }
From source file:io.cortical.retina.model.TestDataHarness.java
/** * Create dummy {@link Fingerprint}.//ww w. j a v a2 s.co m * @param sparsity percentage of on bits * @return dummy fingerprint. */ public static Fingerprint createFingerprint(double sparsity) { Random random = new Random(SEED); Set<Integer> positionSet = new LinkedHashSet<>(); while (positionSet.size() <= ((double) (MAX_POSITION)) * sparsity) { positionSet.add(random.nextInt(MAX_POSITION)); } Integer[] positionsInteger = new Integer[FINGERPRINT_LENGTH]; positionsInteger = positionSet.toArray(positionsInteger); sort(positionsInteger); return new Fingerprint(ArrayUtils.toPrimitive(positionsInteger)); }
From source file:de.tudarmstadt.ukp.dkpro.core.testing.validation.CasValidator.java
public void setChecks(Collection<Class<? extends Check>> aChecks) { checks = new LinkedHashSet<>(); if (aChecks != null) { checks.addAll(aChecks);/* w w w. j a va 2 s . c om*/ } }
From source file:com.asual.summer.core.resource.CompositeResource.java
public List<CompositeResource> getChildren() { if (children == null) { LinkedHashSet<CompositeResource> set = new LinkedHashSet<CompositeResource>(); Map<String, CompositeResource> beans = BeanUtils.getBeansOfType(CompositeResource.class); for (CompositeResource resource : beans.values()) { if (this.equals(resource.getParent())) { set.add(resource);//from ww w . j a va2 s.c om } } children = new ArrayList<CompositeResource>(set); OrderComparator.sort(children); } return children; }
From source file:facebook4j.TargetingParameter.java
public void setLocales(Set<Locale> locales) { this.locales = new LinkedHashSet<String>(); for (Locale locale : locales) { this.locales.add(locale.toString()); }//www . j a va 2 s . c o m }