List of usage examples for java.util HashSet add
public boolean add(E e)
From source file:dk.statsbiblioteket.doms.licensemodule.validation.LicenseValidator.java
public static ArrayList<License> filterLicensesWithGroupNamesAndPresentationTypeMustGroup( ArrayList<License> licenses, ArrayList<ConfiguredDomLicenseGroupType> groups, ConfiguredDomLicensePresentationType presentationType) { //Iterator over groups first, since each must be found HashSet<License> filteredSet = new HashSet<License>(); int groupsFound = 0; for (ConfiguredDomLicenseGroupType currentGroup : groups) { String groupKey = currentGroup.getKey(); for (License currentLicense : licenses) { boolean found = Util.domGroupsContainsGroupWithLicense(currentLicense.getLicenseContents(), groupKey, presentationType.getKey()); if (found) { groupsFound++; //Can only happen once for each group due to the break below from inner loop filteredSet.add(currentLicense); break; // Group found, break inner loop }//from w w w.j av a 2s. c o m } } if (groupsFound == groups.size()) { //All groups was matched return new ArrayList<License>(filteredSet); } return new ArrayList<License>(); //Empty list. }
From source file:com.clustercontrol.repository.util.FacilityTreeCache.java
public static Set<String> getChildFacilityIdSet(String facilityId) { // ????????????????????????? // (?????????????????????????) HashMap<String, ArrayList<FacilityTreeItem>> facilityTreeItemCache = getFacilityTreeItemCache(); HashSet<String> childFacilityIdSet = new HashSet<String>(); List<FacilityTreeItem> treeItems = facilityTreeItemCache.get(facilityId); if (treeItems == null) { return childFacilityIdSet; }/*ww w . ja v a 2s .c o m*/ for (FacilityTreeItem treeItem : treeItems) { for (FacilityTreeItem childTreeItem : treeItem.getChildren()) { FacilityInfo childFacilityInfo = childTreeItem.getData(); childFacilityIdSet.add(childFacilityInfo.getFacilityId()); } } return childFacilityIdSet; }
From source file:amie.keys.CSAKey.java
private static HashSet<HashSet<Integer>> subSet(HashSet<HashSet<Integer>> nonKeysInt2, int start, int end) { int counter = 0; Iterator<HashSet<Integer>> it = nonKeysInt2.iterator(); HashSet<HashSet<Integer>> result = new HashSet<>(); while (counter < start) { it.next();// w ww . j a v a2s . c o m ++counter; } while (counter < end) { result.add(it.next()); ++counter; } return result; }
From source file:org.sventon.web.ctrl.ConfigurationFormControllerTest.java
@Test public void onFormSubmitRepositoryAdded() throws Exception { Application application = mock(Application.class); HashSet<RepositoryName> repositoryNames = new HashSet<RepositoryName>(); repositoryNames.add(new RepositoryName("sventon")); repositoryNames.add(new RepositoryName("nordpolen")); when(application.getRepositoryNames()).thenReturn(repositoryNames); ConfigCommand command = new ConfigCommand(); command.setName("nordpolen"); command.setRepositoryUrl("svn://northpole.com/repo"); BindingResult bindingResult = mock(BindingResult.class); when(bindingResult.hasErrors()).thenReturn(false); Model model = new ExtendedModelMap(); ConfigurationFormController controller = new ConfigurationFormController(application); String listConfigView = controller.onFormSubmit(command, bindingResult, model); Map expectedModel = new HashMap(); expectedModel.put("addedRepositories", repositoryNames); expectedModel.put("latestAddedRepository", command.getName()); assertThat(listConfigView, is(LIST_CONFIGS_VIEW_NAME)); assertThat(model.asMap(), is(expectedModel)); }
From source file:fi.helsinki.lib.simplerest.CollectionLogoResource.java
@Post public Representation post(Representation dummy) { HashSet<Method> allowed = new HashSet(); allowed.add(Method.GET); allowed.add(Method.PUT);//from ww w. j a v a 2s .c om allowed.add(Method.DELETE); setAllowedMethods(allowed); return error(null, "Collection logo resource does not allow POST method.", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); }
From source file:fi.helsinki.lib.simplerest.CommunityLogoResource.java
@Post public Representation post(Representation dummy) { HashSet<Method> allowed = new HashSet(); allowed.add(Method.GET); allowed.add(Method.PUT);// w ww . j a v a 2 s.c om allowed.add(Method.DELETE); setAllowedMethods(allowed); return error(null, "Community logo resource does not allow POST method.", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); }
From source file:tv.arte.resteventapi.core.querying.convertion.QueryOpParamGenericConverter.java
/** * {@inheritDoc}/*from www. j av a2 s . c om*/ */ public Set<ConvertiblePair> getConvertibleTypes() { HashSet<GenericConverter.ConvertiblePair> convertibleTypes = new HashSet<GenericConverter.ConvertiblePair>(); convertibleTypes.add(new ConvertiblePair(String.class, QueryOpParamValue.class)); convertibleTypes.add(new ConvertiblePair(QueryOpParamValue.class, String.class)); return convertibleTypes; }
From source file:com.fatminds.vaadin.cmis.property.ArrayListPropertyConverter.java
@Override // TODO preserve ordering public Set<?> format(ArrayList propertyValue) { if (null == propertyValue) { return null; }//w w w . j a v a 2s . c o m HashSet ret = new HashSet(); // Creates some extra hashsets but is a lot clearer this way for (Object o : propertyValue) { ret.add(o); } //log.info("*** FORMAT " + propertyValue + ", RETURN " + ret); return ret; }
From source file:edu.internet2.middleware.shibboleth.common.config.security.StaticPKIXSignatureTrustEngineBeanDefinitionParser.java
/** {@inheritDoc} */ protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { log.info("Parsing configuration for {} trust engine with id: {}", XMLHelper.getXSIType(element).getLocalPart(), element.getAttributeNS(null, "id")); List<Element> childElems = XMLHelper.getChildElementsByTagNameNS(element, SecurityNamespaceHandler.NAMESPACE, "ValidationInfo"); builder.addPropertyValue("PKIXInfo", SpringConfigurationUtils.parseInnerCustomElements(childElems, parserContext)); childElems = XMLHelper.getChildElementsByTagNameNS(element, SecurityNamespaceHandler.NAMESPACE, "TrustedName"); HashSet<String> trustedNames = new HashSet<String>(childElems.size()); for (Element nameElem : childElems) { trustedNames.add(DatatypeHelper.safeTrimOrNullString(nameElem.getTextContent())); }//from w ww . j a v a2s .c om builder.addPropertyValue("trustedNames", trustedNames); childElems = XMLHelper.getChildElementsByTagNameNS(element, SecurityNamespaceHandler.NAMESPACE, "ValidationOptions"); if (childElems.size() > 0) { builder.addPropertyValue("PKIXValidationOptions", SpringConfigurationUtils.parseInnerCustomElement((Element) childElems.get(0), parserContext)); } }
From source file:org.osiam.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<>(); givenFields.add("schemas"); Collections.addAll(givenFields, fieldsToReturn); String[] finalFieldsToReturn = givenFields.toArray(new String[givenFields.size()]); FilterProvider filters = new SimpleFilterProvider().addFilter("filter properties by name", SimpleBeanPropertyFilter.filterOutAllExcept(finalFieldsToReturn)); return mapper.writer(filters); }//from w w w . j av a 2 s . co m return mapper.writer(); }