List of usage examples for java.util TreeSet TreeSet
public TreeSet()
From source file:org.ngrinder.perftest.service.TagService.java
/** * Add tags./* w ww. j a va 2 s.c om*/ * * @param user user * @param tags tag string list * @return inserted tags */ @Transactional public SortedSet<Tag> addTags(User user, String[] tags) { if (ArrayUtils.isEmpty(tags)) { return new TreeSet<Tag>(); } Specifications<Tag> spec = Specifications.where(lastModifiedOrCreatedBy(user)).and(valueIn(tags)); List<Tag> foundTags = tagRepository.findAll(spec); SortedSet<Tag> allTags = new TreeSet<Tag>(foundTags); for (String each : tags) { Tag newTag = new Tag(StringUtils.trimToEmpty(StringUtils.replace(each, ",", ""))); if (allTags.contains(newTag)) { continue; } if (!foundTags.contains(newTag) && !allTags.contains(newTag)) { allTags.add(saveTag(user, newTag)); } } return allTags; }
From source file:org.jnap.core.assets.HandlebarsAssetsHandler.java
@Override public void handle() { final Handlebars handlebars = new Handlebars(); try {/* ww w. j a v a2 s .c o m*/ Resource[] resources = this.resourceResolver.getResources(source); Resource destRes = new ServletContextResource(servletContext, destination); resetResource(destRes); BufferedWriter writer = new BufferedWriter( new FileWriterWithEncoding(destRes.getFile(), this.encoding, true)); writer.write("(function() {"); writer.write(IOUtils.LINE_SEPARATOR); writer.write("var template = Handlebars.template, "); writer.write("templates = Handlebars.templates = Handlebars.templates || {};"); writer.write(IOUtils.LINE_SEPARATOR); final Set<String> templateNames = new TreeSet<String>(); for (Resource resource : resources) { Template template = handlebars .compile(StringUtils.trimToEmpty(IOUtils.toString(resource.getInputStream()))); final String templateName = FilenameUtils.getBaseName(resource.getFilename()); templateNames.add(templateName); writer.write("templates[\"" + templateName + "\"] = "); writer.write("template("); writer.write(template.toJavaScript()); writer.write(");"); writer.write(IOUtils.LINE_SEPARATOR); } writer.write(IOUtils.LINE_SEPARATOR); if (this.bindToBackboneView) { writer.write("$(function() {"); writer.write(IOUtils.LINE_SEPARATOR); for (String templateName : templateNames) { writer.write(format("if (window[\"{0}\"]) {0}.prototype.template " + "= templates[\"{0}\"];", templateName)); writer.write(IOUtils.LINE_SEPARATOR); } writer.write("});"); writer.write(IOUtils.LINE_SEPARATOR); } writer.write("})();"); IOUtils.closeQuietly(writer); } catch (Exception e) { e.printStackTrace(); } }