List of usage examples for java.util SortedSet size
int size();
From source file:org.tonguetied.web.KeywordValidator.java
/** * This validation method checks if the set of {@link Translation}s for a * {@link Keyword} contains duplicate entries of the business key. * // w w w .j a v a 2 s . co m * @param translations the set of {@link Translation}s to validate * @param errors contextual state about the validation process (never null) */ protected void validateDuplicates(SortedSet<Translation> translations, Errors errors) { Collection<Translation> output; TranslationPredicate predicate; List<FieldError> fieldErrors; if (translations.size() > 1) { for (Translation translation : translations) { predicate = new TranslationPredicate(translation.getBundle(), translation.getCountry(), translation.getLanguage()); output = CollectionUtils.select(translations, predicate); if (output.size() > 1) { final String[] errorArgs = new String[] { getLanguageName(translation.getLanguage()), getCountryName(translation.getCountry()), getBundleName(translation.getBundle()) }; fieldErrors = errors.getFieldErrors(FIELD_TRANSLATIONS); boolean containsError = false; for (FieldError error : fieldErrors) { containsError = containsError || Arrays.equals(error.getArguments(), errorArgs); } if (!containsError) { errors.rejectValue(FIELD_TRANSLATIONS, "error.duplicate.translations", errorArgs, "default"); } } } } }
From source file:ddf.catalog.transformer.input.tika.TikaInputTransformer.java
private List<String> getSupportedMimeTypes() { SortedSet<MediaType> mediaTypes = MediaTypeRegistry.getDefaultRegistry().getTypes(); List<String> mimeTypes = new ArrayList<>(mediaTypes.size()); for (MediaType mediaType : mediaTypes) { String mimeType = mediaType.getType() + "/" + mediaType.getSubtype(); mimeTypes.add(mimeType);/*from www . j a va 2 s. c om*/ } mimeTypes.add("image/jp2"); mimeTypes.add("image/bmp"); LOGGER.debug("supported mime types: {}", mimeTypes); return mimeTypes; }
From source file:uk.gov.phe.gis.thematics.classification.classifiers.precision.rounding.Generic.java
public double[] round(double[] values, double[] excludes) { SortedSet<Double> excludeSet = new TreeSet<Double>(Arrays.asList(ArrayUtils.toObject(excludes))); SortedSet<Double> breakSet = new TreeSet<Double>(); for (double b : values) { double roundedBreak = round(b); if (excludeSet.contains(roundedBreak) == false) { breakSet.add(roundedBreak);/*from w w w. j a v a 2s .c om*/ } } return ArrayUtils.toPrimitive(breakSet.toArray(new Double[breakSet.size()])); }
From source file:com.dbschools.music.assess.SummaryRecord.java
/** * Creates a summary record for the specified musician. * // ww w .j a va 2s.c o m * @param musician the musician * @param nextPiece the next piece the musician is to be tested on */ public SummaryRecord(Musician musician, Piece nextPiece) { musicianId = musician.getId(); SortedSet<Assessment> assessments = new TreeSet<Assessment>(musician.getAssessments()); numAssessments = assessments.size(); Date lastAssessmentTemp = null; int numAssessmentVisits = 0; int numPassesCounter = 0; int numFailuresCounter = 0; Long previousAssTime = null; for (Assessment ass : assessments) { if (ass.isPass()) { ++numPassesCounter; } else { ++numFailuresCounter; } final long assTime = ass.getAssessmentTime().getTime(); if (lastAssessmentTemp == null || assTime > lastAssessmentTemp.getTime()) { lastAssessmentTemp = new Date(ass.getAssessmentTime().getTime()); } // If an hour has passed since the last assessment, consider it a new "visit" if (previousAssTime == null) { ++numAssessmentVisits; } else { if (assTime > previousAssTime + ONE_HOUR) { ++numAssessmentVisits; } } previousAssTime = assTime; } final Instrument primaryInstrumentForMusician = Utils .primaryInstrumentForMusician(musician.getMusicianGroups()); instrument = primaryInstrumentForMusician == null ? null : primaryInstrumentForMusician.getName(); numPasses = numPassesCounter; numFailures = numFailuresCounter; if (lastAssessmentTemp != null) { daysSinceLastAssessment = (int) (((new Date().getTime()) - lastAssessmentTemp.getTime()) / (ONE_HOUR * 24)); } else { daysSinceLastAssessment = null; } if (nextPiece != null && !(nextPiece instanceof NoNextPieceIndicator)) { nextPieceId = nextPiece.getId(); } else { nextPieceId = null; } numVisits = numAssessmentVisits + musician.getRejections().size(); numRejections = musician.getRejections().size(); lastAssessment = lastAssessmentTemp; }
From source file:org.hippoecm.frontend.editor.workflow.model.ReferringDocumentsProvider.java
protected void load() { if (entries == null) { try {/*w w w .jav a 2 s.co m*/ entries = new ArrayList<>(); numResults = 0; final IModel<Node> model = getChainedModel(); SortedSet<Node> nodes = getReferrersSortedByName(model.getObject(), retrieveUnpublished, getLimit()); numResults = nodes.size(); for (Node node : nodes) { entries.add(new JcrNodeModel(node)); } } catch (RepositoryException ex) { log.error(ex.getMessage()); } } }
From source file:com.medvision360.medrecord.spi.tck.RMTestBase.java
protected void assertEqualish(Archetype orig, Archetype other) { assertEquals(orig.getAdlVersion(), other.getAdlVersion()); assertEquals(orig.getArchetypeId(), other.getArchetypeId()); assertEquals(orig.getDescription(), other.getDescription()); SortedSet<String> origPaths = new TreeSet<>(orig.getPathNodeMap().keySet()); SortedSet<String> otherPaths = new TreeSet<>(other.getPathNodeMap().keySet()); assertEquals(origPaths.size(), otherPaths.size()); Iterator<String> origIt = origPaths.iterator(); Iterator<String> otherIt = otherPaths.iterator(); while (origIt.hasNext()) { String origPath = origIt.next(); String otherPath = otherIt.next(); assertEquals(origPath, otherPath); }//from www . ja va 2s. c o m }
From source file:org.eclipse.skalli.commons.StatisticsTest.java
private <T extends StatisticsInfo> void assertInfoSet(Statistics stats, SortedSet<T> info) { assertEquals(info.size(), stats.getSequenceNumber()); assertEquals(info.last().getSequenceNumber() + 1, stats.getSequenceNumber()); assertEquals(info.first().getTimestamp(), stats.getStartDate()); assertEquals(info.last().getTimestamp(), stats.getEndDate()); int i = 0;/*from w w w . jav a2 s . co m*/ for (T next : info) { assertEquals(i, next.getSequenceNumber()); ++i; } }
From source file:org.opennms.ng.dao.support.BottomNAttributeStatisticVisitor.java
/** * <p>getResults</p>//w w w .j av a 2 s . c om * * @return top attribute statistics (up to getCount() number) */ @Override public SortedSet<AttributeStatistic> getResults() { SortedSet<AttributeStatistic> top = new TreeSet<AttributeStatistic>(new AttributeStatisticComparator()); for (AttributeStatistic stat : m_results) { top.add(stat); if (top.size() >= m_count) { break; } } return top; }
From source file:de.shadowhunt.sonar.plugins.ignorecode.model.CoveragePatternTest.java
@Test public void testEmpty() throws Exception { final CoveragePattern pattern = new CoveragePattern("resourcePattern", new TreeSet<Integer>()); final SortedSet<Integer> empty = pattern.getLines(); Assert.assertNotNull("SortedSet must not be null", empty); Assert.assertEquals("SortedSet must not contain any entries", 0, empty.size()); }
From source file:org.gradle.api.tasks.diagnostics.internal.TaskReportRenderer.java
private void writeTask(TaskDetails task, String prefix) { getTextOutput().text(prefix);/*from w ww. ja va 2s .c om*/ getTextOutput().withStyle(Identifier).text(task.getPath()); if (GUtil.isTrue(task.getDescription())) { getTextOutput().withStyle(Description).format(" - %s", task.getDescription()); } if (detail) { SortedSet<Path> sortedDependencies = new TreeSet<Path>(); for (TaskDetails dependency : task.getDependencies()) { sortedDependencies.add(dependency.getPath()); } if (sortedDependencies.size() > 0) { getTextOutput().withStyle(Info).format(" [%s]", CollectionUtils.join(", ", sortedDependencies)); } } getTextOutput().println(); }