List of usage examples for java.util SortedSet addAll
boolean addAll(Collection<? extends E> c);
From source file:com.blackducksoftware.integration.jira.config.HubJiraConfigController.java
private SortedSet<String> getIssueCreatorCandidates(final PluginSettings settings) { final SortedSet<String> jiraUsernames = new TreeSet<>(); final String groupList = getStringValue(settings, HubJiraConfigKeys.HUB_CONFIG_GROUPS); if (!StringUtils.isBlank(groupList)) { final String[] groupNames = groupList.split(","); for (final String groupName : groupNames) { jiraUsernames.addAll(new JiraServices().getGroupManager().getUserNamesInGroup(groupName)); }// w w w . j av a2 s . c o m } logger.debug("getJiraUsernames(): returning: " + jiraUsernames); return jiraUsernames; }
From source file:org.spongepowered.asm.mixin.transformer.MixinTransformer.java
@Override public byte[] transform(String name, String transformedName, byte[] basicClass) { if (basicClass == null) { return basicClass; }//from w w w .ja v a2 s . c o m this.reEntranceCheck++; if (this.reEntranceCheck > 1) { this.detectReEntrance(); } if (!this.initDone) { this.initConfigs(); this.initDone = true; } try { SortedSet<MixinInfo> mixins = null; for (MixinConfig config : this.configs) { if (transformedName != null && transformedName.startsWith(config.getMixinPackage())) { throw new NoClassDefFoundError(String .format("%s is a mixin class and cannot be referenced directly", transformedName)); } if (config.hasMixinsFor(transformedName)) { if (mixins == null) { mixins = new TreeSet<MixinInfo>(); } // Get and sort mixins for the class mixins.addAll(config.getMixinsFor(transformedName)); } } if (mixins != null) { try { basicClass = this.applyMixins(transformedName, basicClass, mixins); } catch (InvalidMixinException th) { MixinConfig config = th.getMixin().getParent(); this.logger.log(config.isRequired() ? Level.FATAL : Level.WARN, String.format("Mixin failed applying %s -> %s: %s %s", th.getMixin(), transformedName, th.getClass().getName(), th.getMessage()), th); if (config.isRequired()) { throw new MixinApplyError( "Mixin [" + th.getMixin() + "] FAILED for REQUIRED config [" + config + "]", th); } th.printStackTrace(); } } return basicClass; } catch (Exception ex) { throw new MixinTransformerError("An unexpected critical error was encountered", ex); } finally { this.reEntranceCheck--; } }
From source file:net.sourceforge.fenixedu.presentationTier.Action.coordinator.ManageFinalDegreeWorkDispatchAction.java
public ActionForward detailedProposalList(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws FenixActionException, FenixServiceException { final ExecutionDegree executionDegree = getExecutionDegree(request); final SortedSet<Proposal> proposals = new TreeSet<Proposal>(new BeanComparator("proposalNumber")); proposals.addAll(executionDegree.getScheduling().getProposalsSet()); request.setAttribute("proposals", proposals); return mapping.findForward("detailed-proposal-list"); }
From source file:net.pms.dlna.protocolinfo.DeviceProtocolInfo.java
/** * Tries to parse {@code protocolInfoString} and add the resulting * {@link ProtocolInfo} instances.// w w w.ja va 2 s. c om * * @param type The {@link DeviceProtocolInfoSource} that identifies the * source of these {@code protocolInfo}s. * @param protocolInfoString a comma separated string of * {@code protocolInfo} representations whose presence is to be * ensured. * @return {@code true} if this changed as a result of the call. Returns * {@code false} this already contains the specified element(s). */ public boolean add(DeviceProtocolInfoSource<?> type, String protocolInfoString) { if (StringUtils.isBlank(protocolInfoString)) { return false; } String[] elements = protocolInfoString.trim().split(COMMA_SPLIT_REGEX); boolean result = false; setsLock.writeLock().lock(); try { SortedSet<ProtocolInfo> currentSet; if (protocolInfoSets.containsKey(type)) { currentSet = protocolInfoSets.get(type); } else { currentSet = new TreeSet<ProtocolInfo>(); protocolInfoSets.put(type, currentSet); } SortedSet<ProtocolInfo> tempSet = null; for (String element : elements) { try { tempSet = handleSpecialCaseString(element); if (tempSet == null) { // No special handling result |= currentSet.add(new ProtocolInfo(unescapeString(element))); } else { // Add the special handling results result |= currentSet.addAll(tempSet); tempSet = null; } } catch (ParseException e) { LOGGER.warn("Unable to parse protocolInfo from \"{}\", this profile will not be registered: {}", element, e.getMessage()); LOGGER.trace("", e); } } updateImageProfiles(); } finally { setsLock.writeLock().unlock(); } return result; }
From source file:net.sourceforge.fenixedu.presentationTier.Action.coordinator.ManageFinalDegreeWorkDispatchAction.java
private void fillProposalsSpreadSheet(final ExecutionDegree executionDegree, final Spreadsheet spreadsheet) { int maxNumberStudentsPerGroup = 0; final Scheduleing scheduleing = executionDegree.getScheduling(); final SortedSet<Proposal> proposals = new TreeSet<Proposal>(new BeanComparator("proposalNumber")); proposals.addAll(scheduleing.getProposalsSet()); for (final Proposal proposal : proposals) { final Row row = spreadsheet.addRow(); row.setCell(proposal.getProposalNumber().toString()); if (proposal.getGroupAttributed() != null) { row.setCell("Atribuido"); } else if (proposal.getStatus() != null) { row.setCell(proposal.getStatus().getKey()); } else {/*from w w w . ja v a 2s . c om*/ row.setCell(""); } row.setCell(proposal.getTitle()); row.setCell(proposal.getOrientator().getIstUsername()); row.setCell(proposal.getOrientator().getName()); if (proposal.getCoorientator() != null) { row.setCell(proposal.getCoorientator().getIstUsername()); row.setCell(proposal.getCoorientator().getName()); } else { row.setCell(""); row.setCell(""); } if (proposal.getOrientatorsCreditsPercentage() != null) { row.setCell(proposal.getOrientatorsCreditsPercentage().toString()); } else { row.setCell(""); } if (proposal.getCoorientatorsCreditsPercentage() != null) { row.setCell(proposal.getCoorientatorsCreditsPercentage().toString()); } else { row.setCell(""); } row.setCell(proposal.getCompanionName()); row.setCell(proposal.getCompanionMail()); if (proposal.getCompanionPhone() != null) { row.setCell(proposal.getCompanionPhone().toString()); } else { row.setCell(""); } row.setCell(proposal.getCompanyName()); row.setCell(proposal.getCompanyAdress()); row.setCell(proposal.getFraming()); row.setCell(proposal.getObjectives()); row.setCell(proposal.getDescription()); row.setCell(proposal.getRequirements()); row.setCell(proposal.getDeliverable()); row.setCell(proposal.getUrl()); final StringBuilder branches = new StringBuilder(); boolean appendSeperator = false; for (final Branch branch : proposal.getBranchesSet()) { if (appendSeperator) { branches.append(", "); } else { appendSeperator = true; } branches.append(branch.getName()); } row.setCell(branches.toString()); if (proposal.getMinimumNumberOfGroupElements() != null) { row.setCell(proposal.getMinimumNumberOfGroupElements().toString()); } else { row.setCell(""); } if (proposal.getMaximumNumberOfGroupElements() != null) { row.setCell(proposal.getMaximumNumberOfGroupElements().toString()); } else { row.setCell(""); } if (proposal.getDegreeType() == null) { row.setCell(applicationResources.getMessage("label.both")); } else { row.setCell(enumerationResources.getMessage(proposal.getDegreeType().getName())); } row.setCell(proposal.getObservations()); row.setCell(proposal.getLocation()); if (proposal.getGroupAttributed() != null) { int i = 0; for (final GroupStudent groupStudent : proposal.getGroupAttributed().getGroupStudentsSet()) { final Registration registration = groupStudent.getRegistration(); row.setCell(registration.getNumber().toString()); row.setCell(registration.getPerson().getName()); maxNumberStudentsPerGroup = Math.max(maxNumberStudentsPerGroup, ++i); } } else if (proposal.getGroupAttributedByTeacher() != null) { int i = 0; for (final GroupStudent groupStudent : proposal.getGroupAttributedByTeacher() .getGroupStudentsSet()) { final Registration registration = groupStudent.getRegistration(); row.setCell(registration.getNumber().toString()); row.setCell(registration.getPerson().getName()); maxNumberStudentsPerGroup = Math.max(maxNumberStudentsPerGroup, ++i); } } } for (int i = 0; i < maxNumberStudentsPerGroup; i++) { spreadsheet.setHeader("Nmero aluno " + (i + 1)); spreadsheet.setHeader("Nome aluno " + (i + 1)); } }
From source file:org.onebusaway.nyc.vehicle_tracking.impl.particlefilter.ParticleFilter.java
/** * Finds the most likely/occurring trip & phase combination among the * particles, then chooses the particle with highest likelihood of that pair. <br> * /*from w ww. ja v a 2s . c o m*/ * FIXME violates generic particle contract by assuming data is of type * VehicleState * * @param particles */ private void computeBestState(Multiset<Particle> particles) { /** * We choose the "most likely" particle over the entire distribution w.r.t * the inferred trip. */ final TObjectDoubleMap<String> tripPhaseToProb = new TObjectDoubleHashMap<String>(); final HashMultimap<String, Particle> particlesIdMap = HashMultimap.create(); final SortedSet<Particle> bestParticles = new TreeSet<Particle>(); String bestId = null; if (!_maxLikelihoodParticle) { double highestTripProb = Double.MIN_VALUE; int index = 0; for (final Multiset.Entry<Particle> pEntry : particles.entrySet()) { final Particle p = pEntry.getElement(); p.setIndex(index++); final double w = FastMath.exp(p.getLogWeight() + FastMath.log(pEntry.getCount())); if (Double.isInfinite(w)) continue; final VehicleState vs = p.getData(); final String tripId = vs.getBlockState() == null ? "NA" : vs.getBlockState().getBlockLocation().getActiveTrip().getTrip().toString(); final String phase = vs.getJourneyState().toString(); final String id = tripId + "." + phase; final double newProb = tripPhaseToProb.adjustOrPutValue(id, w, w); particlesIdMap.put(id, p); /** * Check most likely new trip & phase pairs, then find the most likely * particle(s) within those. */ if (bestId == null || newProb > highestTripProb) { bestId = id; highestTripProb = newProb; } } bestParticles.addAll(particlesIdMap.get(bestId)); } else { bestParticles.addAll(particles); } /** * after we've found the best trip & phase pair, we choose the highest * likelihood particle among those. */ final Particle bestParticle = bestParticles.first(); _mostLikelyParticle = bestParticle.cloneParticle(); }
From source file:net.sourceforge.fenixedu.domain.Degree.java
final private Collection<Coordinator> getCurrentCoordinators(final boolean responsible) { SortedSet<ExecutionYear> years = new TreeSet<ExecutionYear>( new ReverseComparator(ExecutionYear.COMPARATOR_BY_YEAR)); years.addAll(getDegreeCurricularPlansExecutionYears()); ExecutionYear current = ExecutionYear.readCurrentExecutionYear(); for (ExecutionYear year : years) { if (year.isAfter(current)) { continue; }//ww w . j a v a 2s .c om Collection<Coordinator> coordinators = getCoordinators(year, responsible); if (!coordinators.isEmpty()) { return coordinators; } } return Collections.emptyList(); }
From source file:cerrla.LocalCrossEntropyDistribution.java
/** * Modifies the policy values before updating (cutting the values down to * size).//from w w w . ja va 2 s .co m * * @param elites * The policy values to modify. * @param numElite * The minimum number of elite samples. * @param staleValue * The number of policies a sample hangs around for. * @param minValue * The minimum observed value. * @return The policy values that were removed. */ private SortedSet<PolicyValue> preUpdateModification(SortedSet<PolicyValue> elites, int numElite, int staleValue, double minValue) { // Firstly, remove any policy values that have been around for more // than N steps // Make a backup - just in case the elites are empty afterwards SortedSet<PolicyValue> backup = new TreeSet<PolicyValue>(elites); // Only remove stuff if the elites are a representative solution if (!ProgramArgument.GLOBAL_ELITES.booleanValue()) { int iteration = policyGenerator_.getPoliciesEvaluated(); for (Iterator<PolicyValue> iter = elites.iterator(); iter.hasNext();) { PolicyValue pv = iter.next(); if (iteration - pv.getIteration() >= staleValue) { if (ProgramArgument.RETEST_STALE_POLICIES.booleanValue()) policyGenerator_.retestPolicy(pv.getPolicy()); iter.remove(); } } } if (elites.isEmpty()) elites.addAll(backup); SortedSet<PolicyValue> tailSet = null; if (elites.size() > numElite) { // Find the N_E value Iterator<PolicyValue> pvIter = elites.iterator(); PolicyValue currentPV = null; for (int i = 0; i < numElite; i++) currentPV = pvIter.next(); // Iter at N_E value. Remove any values less than N_E's value tailSet = new TreeSet<PolicyValue>(elites.tailSet(new PolicyValue(null, currentPV.getValue(), -1))); elites.removeAll(tailSet); } return tailSet; }
From source file:au.org.ala.delta.editor.slotfile.model.VOCharacterAdaptor.java
protected ControllingInfo checkApplicability(VOItemDesc item, VOCharBaseDesc charBase, int recurseLevel, List<Integer> testedControlledChars) { int controllingId = 0; if (item == null || charBase == null || charBase.getNControlling() == 0) { return new ControllingInfo(); }//from www .j av a2 s . com boolean unknownOk = false; List<Integer> controlling = charBase.readControllingInfo(); if (controlling != null && controlling.size() > 1) { Collections.sort(controlling, new CompareCharNos(false)); } List<Integer> controllingChars = new ArrayList<Integer>(); SortedSet<Integer> controllingStates = new TreeSet<Integer>(); List<Integer> newContStates = new ArrayList<Integer>(); int testCharId = VOUID_NULL; controlling.add(VOUID_NULL); // Append dummy value, to ease handling of // the last element // Loop through all controlling attributes which directly control this // character... for (Integer i : controlling) { int newContCharId = 0; if (i == VOUID_NULL) { newContCharId = VOUID_NULL; } else { VOControllingDesc contAttrDesc = (VOControllingDesc) ((DeltaVOP) charBase.getVOP()) .getDescFromId(i); newContStates = contAttrDesc.readStateIds(); Collections.sort(newContStates); newContCharId = contAttrDesc.getCharId(); } if (newContCharId == testCharId) { // / Build up all relevant controlling attributes under the // control of a // / single controlling character, merging the state lists as we // go.... controllingStates.addAll(newContStates); } else { // Do checks when changing controlling state if (testCharId != VOUID_NULL) { VOCharBaseDesc testCharBase = getDescFromId(testCharId); if (!CharType.isMultistate(testCharBase.getCharType())) { throw new RuntimeException("Controlling characters must be multistate!"); } controllingId = testCharId; // If the controlling character is coded, see whether it // makes us inapplicable if (item.hasAttribute(controllingId)) { Attribute attrib = item.readAttribute(controllingId); List<Integer> codedStates = new ArrayList<Integer>(); short[] pseudoValues = new short[] { 0 }; attrib.getEncodedStates(testCharBase, codedStates, pseudoValues); // If controlling character is "variable", we are NOT // controlled if ((pseudoValues[0] & VOItemDesc.PSEUDO_VARIABLE) == 0) { if (codedStates.isEmpty()) { // If there are no states for the controlling // character, // but it is explicitly coded with the "unknown" // pseudo-value, // allow the controlled character to also be // unknown. if ((pseudoValues[0] & VOItemDesc.PSEUDO_UNKNOWN) != 0) { unknownOk = true; } else { return new ControllingInfo(ControlledStateType.Inapplicable, controllingId); } } else if (controllingStates.containsAll(codedStates)) { return new ControllingInfo(ControlledStateType.Inapplicable, controllingId); } } } else if (testCharBase.getUncodedImplicit() != VOCharBaseDesc.STATEID_NULL) { // if the controlling character is not encoded, see if // there is an implicit value for it if (controllingStates.contains(testCharBase.getUncodedImplicit())) { return new ControllingInfo(ControlledStateType.Inapplicable, controllingId); } } else { return new ControllingInfo(ControlledStateType.Inapplicable, controllingId); // /// This should probably be handled as a somewhat // special case, // /// so the user can be pointed in the right direction } } controllingId = VOUID_NULL; testCharId = newContCharId; if (testCharId != VOUID_NULL) { controllingChars.add(testCharId); } controllingStates.clear(); controllingStates.addAll(newContStates); } } // Up to this point, nothing has made this character inapplicable. // But it is possible that one of the controlling characters has itself // been made inapplicable. // Is this check really necessary? I suppose it is, but it slows things // down... for (int j : controllingChars) { if (++recurseLevel >= getDeltaMaster().getNContAttrs()) { try { List<Integer> contChars = new ArrayList<Integer>(); getControlledChars(testedControlledChars, _charDesc, contChars, true); } catch (CircularDependencyException ex) { return new ControllingInfo(ControlledStateType.Inapplicable, controllingId); } } VOCharBaseDesc testCharBase = getDescFromId(j); ControllingInfo info = checkApplicability(item, testCharBase, recurseLevel, testedControlledChars); if (info.isInapplicable()) { return info; } } return unknownOk ? new ControllingInfo(ControlledStateType.InapplicableOrUnknown, controllingId) : new ControllingInfo(); }
From source file:net.sourceforge.fenixedu.domain.Enrolment.java
/** * {@inheritDoc}/*from w ww . j a va 2 s .com*/ * * <p> * This method assumes that each Student has at most one non evaluated Thesis and no more that two Thesis. */ @Override final public Thesis getThesis() { Collection<Thesis> theses = getThesesSet(); switch (theses.size()) { case 0: return null; case 1: return theses.iterator().next(); default: SortedSet<Thesis> sortedTheses = new TreeSet<Thesis>(new Comparator<Thesis>() { @Override public int compare(Thesis o1, Thesis o2) { return o2.getCreation().compareTo(o1.getCreation()); } }); sortedTheses.addAll(theses); return sortedTheses.iterator().next(); } }