List of usage examples for java.util LinkedHashSet LinkedHashSet
public LinkedHashSet()
From source file:cc.kave.commons.pointsto.evaluation.ContextSampler.java
public List<Context> sample(Path contextsDirectory, int number) throws IOException { Map<ZipArchive, Integer> registry = buildRegistry(contextsDirectory); try {// w ww .j a v a 2 s .c om int totalNumContexts = registry.values().stream().mapToInt(Integer::intValue).sum(); LinkedHashSet<Integer> contextIndices = new LinkedHashSet<>(); if (totalNumContexts < number) { for (int i = 0; i < totalNumContexts; ++i) { contextIndices.add(i); } } else { for (int i = 0; i < number; ++i) { int index; do { index = rndGenerator.nextInt(totalNumContexts); } while (contextIndices.contains(index)); contextIndices.add(index); } } List<Context> contexts = new ArrayList<>(number); for (Integer index : contextIndices) { Context ctxt = getContext(registry, index); if (ctxt == null) { ctxt = new Context(); } contexts.add(ctxt); } return contexts; } finally { closeRegistry(registry); } }
From source file:org.eclipse.virgo.ide.bundlor.ui.internal.actions.RunBundlorActionDelegate.java
public void run(IAction action) { Set<IJavaProject> projects = new LinkedHashSet<IJavaProject>(); Iterator<IProject> iter = selected.iterator(); while (iter.hasNext()) { IProject project = iter.next();// w w w. ja v a 2 s . c om if (FacetUtils.isBundleProject(project)) { projects.add(JdtUtils.getJavaProject(project)); } } for (final IJavaProject javaProject : projects) { BundlorUiPlugin.runBundlorOnProject(javaProject); } }
From source file:de.xwic.appkit.core.util.CollectionUtil.java
/** * if parameter is null, set won't contain anything * * @param set/*from w w w . j ava2 s . c om*/ * @return */ public static <E> Set<E> newSet(final Collection<E> collection) { final Set<E> set = new LinkedHashSet<E>(); if (!CollectionUtil.isEmpty(collection)) { set.addAll(collection); } return set; }
From source file:vaeke.restcountries.v0.service.CountryV0Service.java
public List<Country> getByCodeList(List<String> codes) { Set<Country> set = new LinkedHashSet<>(); for (String code : codes) { final Country country = getByAlpha(code); if (null != country) { set.add(country);// w ww .j a v a 2s. c om } } return new ArrayList<>(set); }
From source file:vaeke.restcountries.v1.service.JsonFileCountryService.java
@Override public List<Country> getByCodeList(List<String> codes) { Set<Country> set = new LinkedHashSet<>(); for (String code : codes) { final Country country = getByAlpha(code); if (null != country) { set.add(country);// www . j av a2 s. c om } } return new ArrayList<>(set); }
From source file:org.owasp.dependencytrack.model.RolesTest.java
@Test @Transactional/* w ww . j a v a 2 s . co m*/ public void testObject() throws Exception { LinkedHashSet<Permissions> perms = new LinkedHashSet<>(); Permissions p1 = new Permissions("dosomething"); Permissions p2 = new Permissions("dosomethingelse"); perms.add(p1); perms.add(p2); LinkedHashSet<User> users = new LinkedHashSet<>(); User u1 = new User(); u1.setUsername("Fred"); User u2 = new User(); u2.setUsername("Barney"); users.add(u1); users.add(u2); Roles r1 = new Roles("Role 1"); r1.setId(1); r1.setPerm(perms); r1.setUsr(users); Roles r2 = new Roles(); r2.setRole("Role 2"); r2.setId(1); r2.setPerm(perms); r2.setUsr(users); assertEquals(new Integer(1), r1.getId()); assertEquals("Role 1", r1.getRole()); assertEquals("Role 2", r2.getRole()); assertEquals(2, r1.getPerm().size()); assertEquals(2, r1.getUsr().size()); assertEquals("dosomething", r1.getPerm().iterator().next().getPermissionname()); assertEquals("Fred", r1.getUsr().iterator().next().getUsername()); }
From source file:com.smhdemo.common.report.service.TextService.java
@Override public Long addText(Text vo) throws BaseException { byte[] reportFile = vo.getTextEntity(); if (reportFile != null && reportFile.length > 0) { InputStream in = new ByteArrayInputStream(reportFile); TextDesignUtil rd = new TextDesignUtil(in); List<JRParameter> paramList = rd.getParameters(); Set<Parameter> icSet = new LinkedHashSet<Parameter>(); if (!paramList.isEmpty()) { for (JRParameter param : paramList) { Parameter ic = getParameterValue(param); icSet.add(ic);//ww w. j a va 2s .c o m } vo.setParameters(icSet); } } textDao.persist(vo); return vo.getId(); }
From source file:eu.itesla_project.modules.histo.cache.TwoLevelsHistoDbCache.java
@Override public List<String> listUrls() throws IOException { Set<String> urls = new LinkedHashSet<>(); urls.addAll(cache1.listUrls());/* ww w.ja v a2 s . c om*/ urls.addAll(cache2.listUrls()); return new ArrayList<>(urls); }
From source file:com.wavemaker.tools.apidocs.tools.parser.scanner.FilterableModelScanner.java
public FilterableModelScanner() { substitutes = new LinkedHashSet<>(); adapters = new LinkedHashSet<>(); packageAdapters = new HashSet<>(); // excludeType(Object.class); // excluding object model by default }
From source file:com.github.jknack.amd4j.Shim.java
/** * Set a shim dependencies./*from w w w . j a v a 2 s.c om*/ * * @param deps the shim dependencies. * @return This shim object. */ Shim setDeps(final Collection<String> deps) { this.deps = new LinkedHashSet<String>(); if (deps != null) { this.deps.addAll(deps); } return this; }