List of usage examples for java.util TreeSet addAll
public boolean addAll(Collection<? extends E> c)
From source file:org.obm.push.contacts.ContactsBackendTest.java
@Test public void sortedByDefaultFolderName() { final String defaultFolderName = DEFAULT_PARENT_BOOK_NAME; Folder f1 = Folder.builder().name("users").uid(-1).ownerLoginAtDomain(user.getLoginAtDomain()).build(); Folder f2 = Folder.builder().name("collected_contacts").uid(2).ownerLoginAtDomain(user.getLoginAtDomain()) .build();//from w w w.j a v a2 s. co m Folder f3 = Folder.builder().name(defaultFolderName).uid(3).ownerLoginAtDomain(user.getLoginAtDomain()) .build(); Folder f4 = Folder.builder().name("my address book").uid(4).ownerLoginAtDomain(user.getLoginAtDomain()) .build(); TreeSet<Folder> treeset = new TreeSet<Folder>(new ComparatorUsingFolderName(defaultFolderName)); treeset.addAll(ImmutableList.of(f1, f2, f3, f4)); assertThat(treeset).hasSize(4); assertThat(treeset).contains(f1, f2, f3, f4); assertThat(treeset.first().getName()).isEqualTo(defaultFolderName); assertThat(treeset.last().getName()).isEqualTo("users"); }
From source file:org.hl7.fhir.instance.conf.ServerConformanceProvider.java
private void handleSearchMethodBinding(ConformanceRestComponent rest, ConformanceRestResourceComponent resource, String resourceName, RuntimeResourceDefinition def, TreeSet<String> includes, SearchMethodBinding searchMethodBinding) { includes.addAll(searchMethodBinding.getIncludes()); List<IParameter> params = searchMethodBinding.getParameters(); List<SearchParameter> searchParameters = new ArrayList<SearchParameter>(); for (IParameter nextParameter : params) { if ((nextParameter instanceof SearchParameter)) { searchParameters.add((SearchParameter) nextParameter); }// w ww . j a va 2 s.c om } sortSearchParameters(searchParameters); if (!searchParameters.isEmpty()) { // boolean allOptional = searchParameters.get(0).isRequired() == false; // // OperationDefinition query = null; // if (!allOptional) { // RestOperation operation = rest.addOperation(); // query = new OperationDefinition(); // operation.setDefinition(new ResourceReferenceDt(query)); // query.getDescriptionElement().setValue(searchMethodBinding.getDescription()); // query.addUndeclaredExtension(false, // ExtensionConstants.QUERY_RETURN_TYPE, new CodeDt(resourceName)); // for (String nextInclude : searchMethodBinding.getIncludes()) { // query.addUndeclaredExtension(false, // ExtensionConstants.QUERY_ALLOWED_INCLUDE, new StringDt(nextInclude)); // } // } for (SearchParameter nextParameter : searchParameters) { String nextParamName = nextParameter.getName(); String chain = null; String nextParamUnchainedName = nextParamName; if (nextParamName.contains(".")) { chain = nextParamName.substring(nextParamName.indexOf('.') + 1); nextParamUnchainedName = nextParamName.substring(0, nextParamName.indexOf('.')); } String nextParamDescription = nextParameter.getDescription(); /* * If the parameter has no description, default to the one from the * resource */ if (StringUtils.isBlank(nextParamDescription)) { RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName); if (paramDef != null) { nextParamDescription = paramDef.getDescription(); } } ConformanceRestResourceSearchParamComponent param = resource.addSearchParam(); param.setName(nextParamUnchainedName); if (StringUtils.isNotBlank(chain)) { param.addChain(chain); } param.setDocumentation(nextParamDescription); if (nextParameter.getParamType() != null) { param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode()); } for (Class<? extends IBaseResource> nextTarget : nextParameter.getDeclaredTypes()) { RuntimeResourceDefinition targetDef = myRestfulServer.getFhirContext() .getResourceDefinition(nextTarget); if (targetDef != null) { ResourceType code; try { code = ResourceType.fromCode(targetDef.getName()); } catch (Exception e) { code = null; } if (code != null) { param.addTarget(code.toCode()); } } } } } }
From source file:org.hl7.fhir.dstu2016may.hapi.rest.server.ServerConformanceProvider.java
private void handleDynamicSearchMethodBinding(ConformanceRestResourceComponent resource, RuntimeResourceDefinition def, TreeSet<String> includes, DynamicSearchMethodBinding searchMethodBinding) { includes.addAll(searchMethodBinding.getIncludes()); List<RuntimeSearchParam> searchParameters = new ArrayList<RuntimeSearchParam>(); searchParameters.addAll(searchMethodBinding.getSearchParams()); sortRuntimeSearchParameters(searchParameters); if (!searchParameters.isEmpty()) { for (RuntimeSearchParam nextParameter : searchParameters) { String nextParamName = nextParameter.getName(); // String chain = null; String nextParamUnchainedName = nextParamName; if (nextParamName.contains(".")) { // chain = nextParamName.substring(nextParamName.indexOf('.') + 1); nextParamUnchainedName = nextParamName.substring(0, nextParamName.indexOf('.')); }/*from ww w.ja va 2 s . c om*/ String nextParamDescription = nextParameter.getDescription(); /* * If the parameter has no description, default to the one from the resource */ if (StringUtils.isBlank(nextParamDescription)) { RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName); if (paramDef != null) { nextParamDescription = paramDef.getDescription(); } } ConformanceRestResourceSearchParamComponent param = resource.addSearchParam(); param.setName(nextParamName); // if (StringUtils.isNotBlank(chain)) { // param.addChain(chain); // } param.setDocumentation(nextParamDescription); // param.setType(nextParameter.getParamType()); } } }
From source file:org.unitime.timetable.test.BatchStudentSectioningLoader.java
private Offering loadOffering(InstructionalOffering io, Hashtable courseTable, Hashtable classTable) { sLog.debug("Loading offering " + io.getCourseName()); if (!io.hasClasses()) { sLog.debug(" -- offering " + io.getCourseName() + " has no class"); return null; }// ww w .j a va2 s . c o m Offering offering = new Offering(io.getUniqueId().longValue(), io.getCourseName()); boolean unlimited = false; for (Iterator i = io.getInstrOfferingConfigs().iterator(); i.hasNext();) { InstrOfferingConfig ioc = (InstrOfferingConfig) i.next(); if (ioc.isUnlimitedEnrollment().booleanValue()) unlimited = true; } for (Iterator i = io.getCourseOfferings().iterator(); i.hasNext();) { CourseOffering co = (CourseOffering) i.next(); int projected = (co.getProjectedDemand() == null ? 0 : co.getProjectedDemand().intValue()); int limit = co.getInstructionalOffering().getLimit().intValue(); if (unlimited) limit = -1; if (co.getReservation() != null) limit = co.getReservation(); Course course = new Course(co.getUniqueId().longValue(), co.getSubjectAreaAbbv(), co.getCourseNbr(), offering, limit, projected); courseTable.put(co.getUniqueId(), course); sLog.debug(" -- created course " + course); } Hashtable class2section = new Hashtable(); Hashtable ss2subpart = new Hashtable(); for (Iterator i = io.getInstrOfferingConfigs().iterator(); i.hasNext();) { InstrOfferingConfig ioc = (InstrOfferingConfig) i.next(); if (!ioc.hasClasses()) { sLog.debug(" -- config " + ioc.getName() + " has no class"); continue; } Config config = new Config(ioc.getUniqueId().longValue(), (ioc.isUnlimitedEnrollment() ? -1 : ioc.getLimit()), ioc.getCourseName() + " [" + ioc.getName() + "]", offering); sLog.debug(" -- created config " + config); TreeSet subparts = new TreeSet(new SchedulingSubpartComparator()); subparts.addAll(ioc.getSchedulingSubparts()); for (Iterator j = subparts.iterator(); j.hasNext();) { SchedulingSubpart ss = (SchedulingSubpart) j.next(); String sufix = ss.getSchedulingSubpartSuffix(); Subpart parentSubpart = (ss.getParentSubpart() == null ? null : (Subpart) ss2subpart.get(ss.getParentSubpart())); if (ss.getParentSubpart() != null && parentSubpart == null) { sLog.error(" -- subpart " + ss.getSchedulingSubpartLabel() + " has parent " + ss.getParentSubpart().getSchedulingSubpartLabel() + ", but the appropriate parent subpart is not loaded."); } Subpart subpart = new Subpart(ss.getUniqueId().longValue(), ss.getItype().getItype().toString() + sufix, ss.getItypeDesc().trim() + (sufix == null || sufix.length() == 0 ? "" : " (" + sufix + ")"), config, parentSubpart); subpart.setAllowOverlap(ss.isStudentAllowOverlap()); ss2subpart.put(ss, subpart); sLog.debug(" -- created subpart " + subpart); for (Iterator k = ss.getClasses().iterator(); k.hasNext();) { Class_ c = (Class_) k.next(); int limit = c.getClassLimit(); if (ioc.isUnlimitedEnrollment().booleanValue()) limit = -1; if (!c.isEnabledForStudentScheduling()) limit = 0; Section parentSection = (c.getParentClass() == null ? null : (Section) class2section.get(c.getParentClass())); if (c.getParentClass() != null && parentSection == null) { sLog.error(" -- class " + c.getClassLabel() + " has parent " + c.getParentClass().getClassLabel() + ", but the appropriate parent section is not loaded."); } Section section = loadSection(subpart, parentSection, c, limit); class2section.put(c, section); classTable.put(c.getUniqueId(), section); sLog.debug(" -- created section " + section); } } } return offering; }
From source file:org.hl7.fhir.dstu3.hapi.rest.server.ServerCapabilityStatementProvider.java
private void handleDynamicSearchMethodBinding(CapabilityStatementRestResourceComponent resource, RuntimeResourceDefinition def, TreeSet<String> includes, DynamicSearchMethodBinding searchMethodBinding) { includes.addAll(searchMethodBinding.getIncludes()); List<RuntimeSearchParam> searchParameters = new ArrayList<RuntimeSearchParam>(); searchParameters.addAll(searchMethodBinding.getSearchParams()); sortRuntimeSearchParameters(searchParameters); if (!searchParameters.isEmpty()) { for (RuntimeSearchParam nextParameter : searchParameters) { String nextParamName = nextParameter.getName(); // String chain = null; String nextParamUnchainedName = nextParamName; if (nextParamName.contains(".")) { // chain = nextParamName.substring(nextParamName.indexOf('.') + 1); nextParamUnchainedName = nextParamName.substring(0, nextParamName.indexOf('.')); }/*from w ww .ja va 2s. c o m*/ String nextParamDescription = nextParameter.getDescription(); /* * If the parameter has no description, default to the one from the resource */ if (StringUtils.isBlank(nextParamDescription)) { RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName); if (paramDef != null) { nextParamDescription = paramDef.getDescription(); } } CapabilityStatementRestResourceSearchParamComponent param = resource.addSearchParam(); param.setName(nextParamName); // if (StringUtils.isNotBlank(chain)) { // param.addChain(chain); // } param.setDocumentation(nextParamDescription); // param.setType(nextParameter.getParamType()); } } }
From source file:com.linkedin.pinot.common.restlet.PinotRestletApplication.java
protected void attachRoutesForClass(Router router, Class<? extends ServerResource> clazz) { TreeSet<String> pathsOrderedByLength = new TreeSet<String>( ComparatorUtils.chainedComparator(new Comparator<String>() { @Override/* w ww .ja v a 2 s. c o m*/ public int compare(String left, String right) { int leftLength = left.length(); int rightLength = right.length(); return leftLength < rightLength ? -1 : (leftLength == rightLength ? 0 : 1); } }, ComparatorUtils.NATURAL_COMPARATOR)); for (Method method : clazz.getDeclaredMethods()) { Annotation annotationInstance = method.getAnnotation(Paths.class); if (annotationInstance != null) { pathsOrderedByLength.addAll(Arrays.asList(((Paths) annotationInstance).value())); } } for (String routePath : pathsOrderedByLength) { LOGGER.info("Attaching route {} -> {}", routePath, clazz.getSimpleName()); attachRoute(router, routePath, clazz); } }
From source file:org.hl7.fhir.dstu3.hapi.rest.server.ServerCapabilityStatementProvider.java
private void handleSearchMethodBinding(CapabilityStatementRestComponent rest, CapabilityStatementRestResourceComponent resource, String resourceName, RuntimeResourceDefinition def, TreeSet<String> includes, SearchMethodBinding searchMethodBinding) { includes.addAll(searchMethodBinding.getIncludes()); List<IParameter> params = searchMethodBinding.getParameters(); List<SearchParameter> searchParameters = new ArrayList<SearchParameter>(); for (IParameter nextParameter : params) { if ((nextParameter instanceof SearchParameter)) { searchParameters.add((SearchParameter) nextParameter); }/* w ww.ja v a2 s . c o m*/ } sortSearchParameters(searchParameters); if (!searchParameters.isEmpty()) { // boolean allOptional = searchParameters.get(0).isRequired() == false; // // OperationDefinition query = null; // if (!allOptional) { // RestOperation operation = rest.addOperation(); // query = new OperationDefinition(); // operation.setDefinition(new ResourceReferenceDt(query)); // query.getDescriptionElement().setValue(searchMethodBinding.getDescription()); // query.addUndeclaredExtension(false, ExtensionConstants.QUERY_RETURN_TYPE, new CodeDt(resourceName)); // for (String nextInclude : searchMethodBinding.getIncludes()) { // query.addUndeclaredExtension(false, ExtensionConstants.QUERY_ALLOWED_INCLUDE, new StringDt(nextInclude)); // } // } for (SearchParameter nextParameter : searchParameters) { String nextParamName = nextParameter.getName(); String chain = null; String nextParamUnchainedName = nextParamName; if (nextParamName.contains(".")) { chain = nextParamName.substring(nextParamName.indexOf('.') + 1); nextParamUnchainedName = nextParamName.substring(0, nextParamName.indexOf('.')); } String nextParamDescription = nextParameter.getDescription(); /* * If the parameter has no description, default to the one from the resource */ if (StringUtils.isBlank(nextParamDescription)) { RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName); if (paramDef != null) { nextParamDescription = paramDef.getDescription(); } } CapabilityStatementRestResourceSearchParamComponent param = resource.addSearchParam(); param.setName(nextParamUnchainedName); if (StringUtils.isNotBlank(chain)) { param.addChain(chain); } if (nextParameter.getParamType() == RestSearchParameterTypeEnum.REFERENCE) { for (String nextWhitelist : new TreeSet<String>(nextParameter.getQualifierWhitelist())) { if (nextWhitelist.startsWith(".")) { param.addChain(nextWhitelist.substring(1)); } } } param.setDocumentation(nextParamDescription); if (nextParameter.getParamType() != null) { param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode()); } for (Class<? extends IBaseResource> nextTarget : nextParameter.getDeclaredTypes()) { RuntimeResourceDefinition targetDef = myServerConfiguration.getFhirContext() .getResourceDefinition(nextTarget); if (targetDef != null) { ResourceType code; try { code = ResourceType.fromCode(targetDef.getName()); } catch (FHIRException e) { code = null; } if (code != null) { param.addTarget(targetDef.getName()); } } } } } }
From source file:net.spfbl.data.White.java
public static synchronized TreeSet<String> dropAll() { TreeSet<String> set = SET.clear(); set.addAll(CIDR.clear()); set.addAll(REGEX.clear());/*www. j a va 2 s . com*/ set.addAll(WHOIS.clear()); CHANGED = true; return set; }
From source file:org.hl7.fhir.dstu2016may.hapi.rest.server.ServerConformanceProvider.java
private void handleSearchMethodBinding(ConformanceRestComponent rest, ConformanceRestResourceComponent resource, String resourceName, RuntimeResourceDefinition def, TreeSet<String> includes, SearchMethodBinding searchMethodBinding) { includes.addAll(searchMethodBinding.getIncludes()); List<IParameter> params = searchMethodBinding.getParameters(); List<SearchParameter> searchParameters = new ArrayList<SearchParameter>(); for (IParameter nextParameter : params) { if ((nextParameter instanceof SearchParameter)) { searchParameters.add((SearchParameter) nextParameter); }//from w w w. j a v a 2s . c o m } sortSearchParameters(searchParameters); if (!searchParameters.isEmpty()) { // boolean allOptional = searchParameters.get(0).isRequired() == false; // // OperationDefinition query = null; // if (!allOptional) { // RestOperation operation = rest.addOperation(); // query = new OperationDefinition(); // operation.setDefinition(new ResourceReferenceDt(query)); // query.getDescriptionElement().setValue(searchMethodBinding.getDescription()); // query.addUndeclaredExtension(false, ExtensionConstants.QUERY_RETURN_TYPE, new CodeDt(resourceName)); // for (String nextInclude : searchMethodBinding.getIncludes()) { // query.addUndeclaredExtension(false, ExtensionConstants.QUERY_ALLOWED_INCLUDE, new StringDt(nextInclude)); // } // } for (SearchParameter nextParameter : searchParameters) { String nextParamName = nextParameter.getName(); String chain = null; String nextParamUnchainedName = nextParamName; if (nextParamName.contains(".")) { chain = nextParamName.substring(nextParamName.indexOf('.') + 1); nextParamUnchainedName = nextParamName.substring(0, nextParamName.indexOf('.')); } String nextParamDescription = nextParameter.getDescription(); /* * If the parameter has no description, default to the one from the resource */ if (StringUtils.isBlank(nextParamDescription)) { RuntimeSearchParam paramDef = def.getSearchParam(nextParamUnchainedName); if (paramDef != null) { nextParamDescription = paramDef.getDescription(); } } ConformanceRestResourceSearchParamComponent param = resource.addSearchParam(); param.setName(nextParamUnchainedName); if (StringUtils.isNotBlank(chain)) { param.addChain(chain); } if (nextParameter.getParamType() == RestSearchParameterTypeEnum.REFERENCE) { for (String nextWhitelist : new TreeSet<String>(nextParameter.getQualifierWhitelist())) { if (nextWhitelist.startsWith(".")) { param.addChain(nextWhitelist.substring(1)); } } } param.setDocumentation(nextParamDescription); if (nextParameter.getParamType() != null) { param.getTypeElement().setValueAsString(nextParameter.getParamType().getCode()); } for (Class<? extends IBaseResource> nextTarget : nextParameter.getDeclaredTypes()) { RuntimeResourceDefinition targetDef = myServerConfiguration.getFhirContext() .getResourceDefinition(nextTarget); if (targetDef != null) { ResourceType code; try { code = ResourceType.fromCode(targetDef.getName()); } catch (FHIRException e) { code = null; } if (code != null) { param.addTarget(targetDef.getName()); } } } } } }
From source file:net.spfbl.data.White.java
public static synchronized TreeSet<String> getAll() throws ProcessException { TreeSet<String> whiteSet = SET.getAll(); whiteSet.addAll(CIDR.getAll()); whiteSet.addAll(REGEX.getAll());//from w w w.j av a 2 s .c om whiteSet.addAll(WHOIS.getAll()); return whiteSet; }