List of usage examples for java.util HashSet add
public boolean add(E e)
From source file:com.ludgerpeters.acl.UserAclManagerImp.java
public boolean checkUserPermissions(String userId, String permissions[]) { HashSet<String> permissionSet = new HashSet<>(); Arrays.asList(permissions).forEach(s -> { permissionSet.add(s); String[] split = s.split("\\."); IntStream.range(0, split.length).forEach(i -> { String join = ""; for (int j = 0; j < i; j++) { join += split[j] + "."; }//from w w w.j a va 2 s . c o m join += "*"; permissionSet.add(join); }); }); Set<String> userPermissions = userRepository.getPermissions(userId); return permissionSet.stream().anyMatch(userPermissions::contains); }
From source file:org.epsilonlabs.workflow.execution.example.GraphOutput.java
@Override public void onNext(Object o) { // update graph Entry<?, ?> entry = (Entry<?, ?>) o; String key = entry.getKey().toString(); String value = entry.getValue().toString(); if (key.startsWith("[") && key.endsWith("]")) { String[] keys = key.split(","); for (String key1 : keys) { onNext(createEntry(key1, value)); }/*from ww w. j a v a 2 s . c o m*/ return; } if (data.containsKey(key)) { data.get(key).add(value); // dataset.addValue(data.get(key).size(), "null", key); } else { HashSet<String> ret = new HashSet<>(); ret.add(value); data.put(key, ret); // dataset.addValue(data.get(key).size(), "null", key); } // sort every 100 iterations to avoid flicker if (current % 100 == 0) dataset.clear(); LinkedList<Entry<String, HashSet<String>>> list = new LinkedList<>(); list.addAll(data.entrySet()); list.sort(new Comparator<Entry<String, HashSet<String>>>() { @Override public int compare(Entry<String, HashSet<String>> o1, Entry<String, HashSet<String>> o2) { return new Integer(o2.getValue().size()).compareTo(o1.getValue().size()); } }); for (Entry<String, HashSet<String>> e : list) dataset.addValue(e.getValue().size(), "null", e.getKey()); // // current++; if (current % period == 0) notifyObserversOfStatusChange("processed " + current + " elements"); }
From source file:com.thoughtworks.go.config.Agents.java
public Set<String> acceptedUuids() { HashSet<String> uuids = new HashSet<>(); for (AgentConfig agentConfig : this) { uuids.add(agentConfig.getUuid()); }/* w w w .ja v a 2 s . co m*/ return uuids; }
From source file:com.qwazr.graph.test.FullTest.java
@Test public void test000CreateDatabase() throws IOException { HashMap<String, PropertyTypeEnum> node_properties = new HashMap<String, PropertyTypeEnum>(); node_properties.put("type", PropertyTypeEnum.indexed); node_properties.put("date", PropertyTypeEnum.indexed); node_properties.put("name", PropertyTypeEnum.stored); node_properties.put("user", PropertyTypeEnum.stored); HashSet<String> edge_types = new HashSet<String>(); edge_types.add("see"); edge_types.add("buy"); GraphDefinition graphDef = new GraphDefinition(node_properties, edge_types); HttpResponse response = Request.Post(BASE_URL + '/' + TEST_BASE) .bodyString(JsonMapper.MAPPER.writeValueAsString(graphDef), ContentType.APPLICATION_JSON) .connectTimeout(60000).socketTimeout(60000).execute().returnResponse(); Assert.assertEquals(200, response.getStatusLine().getStatusCode()); }
From source file:cross.io.AFragmentCommandServiceLoader.java
/** * Returns the available implementations of {@link AFragmentCommand} as provided * by the Java {@link java.util.ServiceLoader} infrastructure. * * Elements are sorted according to lexical order on their classnames. * * @return the list of available fragment commands *///from ww w . jav a 2 s . c om public List<AFragmentCommand> getAvailableCommands() { ServiceLoader<AFragmentCommand> sl = ServiceLoader.load(AFragmentCommand.class); HashSet<AFragmentCommand> s = new HashSet<>(); for (AFragmentCommand ifc : sl) { s.add(ifc); } return createSortedListFromSet(s, new ClassNameLexicalComparator()); }
From source file:com.ebuddy.cassandra.structure.jackson.CustomTypeResolverBuilderTest.java
private TestPojoWithSet getTestPojoWithoutSubclassedSets() { HashSet<Object> objectSet = new HashSet<Object>(); objectSet.add(1); objectSet.add("X"); HashSet<String> hashSet = new HashSet<String>(); hashSet.add("a"); hashSet.add("b"); Set<String> set = new TreeSet<String>(); set.add("x"); set.add("y"); return new TestPojoWithSet("string", 42L, true, Arrays.asList("l2", "l1", "l3"), objectSet, hashSet, set); }
From source file:it.iit.genomics.cru.igb.bundles.mi.business.MIResult.java
private static String getPositionList(Collection<SeqSymmetry> symmetries) { HashSet<String> positions = new HashSet<>(); for (SeqSymmetry sym : symmetries) { if (sym == null) { continue; }/*from w w w . j a va2 s .c o m*/ if (sym.getSpanCount() == 0) { continue; } SeqSpan span = sym.getSpan(0); positions.add(span.getBioSeq().getId() + ":" + span.getStart() + "-" + span.getEnd()); } return StringUtils.join(positions, ";"); }
From source file:de.kaiserpfalzEdv.office.core.security.impl.SecurityTicket.java
public Set<String> getRoles() { HashSet<String> result = new HashSet<>(); account.getRoles().forEach(t -> result.add(t.getDisplayNumber())); return Collections.unmodifiableSet(result); }
From source file:org.osiam.resource_server.resources.helper.AttributesRemovalHelper.java
private ObjectWriter getObjectWriter(ObjectMapper mapper, String[] fieldsToReturn) { if (fieldsToReturn.length != 0) { mapper.addMixInAnnotations(Object.class, PropertyFilterMixIn.class); HashSet<String> givenFields = new HashSet<String>(); givenFields.add("schemas"); for (String field : fieldsToReturn) { givenFields.add(field);//from w w w . j ava 2 s .com } String[] finalFieldsToReturn = givenFields.toArray(new String[givenFields.size()]); FilterProvider filters = new SimpleFilterProvider().addFilter("filter properties by name", SimpleBeanPropertyFilter.filterOutAllExcept(finalFieldsToReturn)); return mapper.writer(filters); } return mapper.writer(); }
From source file:edu.harvard.i2b2.analysis.queryClient.CRCQueryClient.java
public static String getlldString(ArrayList<TimelineRow> tlrows, String patientRefId, int minPatient, int maxPatient, boolean bDisplayAll, boolean writeFile, boolean displayDemographics, ExplorerC explorer) {/* w w w . jav a 2 s . c o m*/ try { HashSet<String> conceptPaths = new HashSet<String>(); // HashSet<String> providerPaths = new HashSet<String>(); // HashSet<String> visitPaths = new HashSet<String>(); ArrayList<PDOItem> items = new ArrayList<PDOItem>(); for (int i = 0; i < tlrows.size(); i++) { for (int j = 0; j < tlrows.get(i).pdoItems.size(); j++) { PDOItem pdoItem = tlrows.get(i).pdoItems.get(j); String path = pdoItem.fullPath; if (conceptPaths.contains(path)) { continue; } conceptPaths.add(path); // for(int k=0; k<pdoItem.valDisplayProperties.size(); k++) // { items.add(pdoItem); // } } } PDORequestMessageModel pdoFactory = new PDORequestMessageModel(); String pid = null; if (patientRefId.equalsIgnoreCase("All")) { pid = "-1"; } else { pid = patientRefId; } String xmlStr = pdoFactory.requestXmlMessage(items, pid, new Integer(minPatient), new Integer(maxPatient), false); // explorer.lastRequestMessage(xmlStr); String result = null;// sendPDOQueryRequestREST(xmlStr); if (System.getProperty("webServiceMethod").equals("SOAP")) { result = CRCQueryClient.sendPDOQueryRequestSOAP(xmlStr); } else { result = CRCQueryClient.sendPDOQueryRequestREST(xmlStr); } if (result == null || result.equalsIgnoreCase("memory error")) { return result; } explorer.lastResponseMessage(result); return TimelineFactory.generateTimelineData(result, tlrows, writeFile, bDisplayAll, displayDemographics); } /* * catch(org.apache.axis2.AxisFault e) { e.printStackTrace(); * java.awt.EventQueue.invokeLater(new Runnable() { public void run() { * JOptionPane.showMessageDialog(null, * "Trouble with connection to the remote server, " + * "this is often a network error, please try again", "Network Error", * JOptionPane.INFORMATION_MESSAGE); } }); * * return null; } */ catch (Exception e) { e.printStackTrace(); return null; } }