List of usage examples for java.util SortedSet isEmpty
boolean isEmpty();
From source file:org.artifactory.maven.MavenModelUtils.java
public static Metadata buildReleasesMavenMetadata(String organization, String module, SortedSet<String> sortedVersions) { Metadata metadata = new Metadata(); metadata.setGroupId(organization);//from w ww .j a v a 2s . co m metadata.setArtifactId(module); if (!sortedVersions.isEmpty()) { metadata.setVersion(sortedVersions.first()); Versioning versioning = new Versioning(); metadata.setVersioning(versioning); versioning.setVersions(Lists.newArrayList(sortedVersions)); versioning.setLastUpdatedTimestamp(new Date()); versioning.setLatest(sortedVersions.last()); versioning.setRelease(sortedVersions.last()); } return metadata; }
From source file:edu.brown.utils.CollectionUtil.java
/** * Return the last item in an Iterable/*from w w w . j a v a 2s .co m*/ * * @param <T> * @param items * @return */ public static <T> T last(Iterable<T> items) { T last = null; if (items instanceof List<?>) { List<T> list = (List<T>) items; last = (list.isEmpty() ? null : list.get(list.size() - 1)); } else if (items instanceof SortedSet<?>) { SortedSet<T> set = (SortedSet<T>) items; last = (set.isEmpty() ? null : set.last()); } else { for (T t : items) { last = t; } } return (last); }
From source file:edu.brown.utils.CollectionUtil.java
/** * Return the ith element of a set. Super lame * /*from w ww .j av a 2 s .c o m*/ * @param <T> * @param items * @param idx * @return */ public static <T> T get(Iterable<T> items, int idx) { if (items == null) { return (null); } else if (items instanceof List<?>) { return ((List<T>) items).get(idx); } else if (items instanceof ListOrderedSet<?>) { return ((ListOrderedSet<T>) items).get(idx); } else if (items instanceof SortedSet<?> && idx == 0) { SortedSet<T> set = (SortedSet<T>) items; return (set.isEmpty() ? null : set.first()); } int ctr = 0; for (T t : items) { if (ctr++ == idx) return (t); } return (null); }
From source file:com.ngdata.hbaseindexer.util.zookeeper.ZkLock.java
/** * Try to get a lock, waits until this succeeds. * * @param lockPath path in ZooKeeper below which the ephemeral lock nodes will be created. This path should * exist prior to calling this method. * * @return a string identifying this lock, needs to be supplied to {@link ZkLock#unlock}. *///from w w w . j a v a 2 s .c o m public static String lock(final ZooKeeperItf zk, final String lockPath) throws ZkLockException { if (zk.isCurrentThreadEventThread()) { throw new RuntimeException("ZkLock should not be used from within the ZooKeeper event thread."); } try { final long threadId = Thread.currentThread().getId(); // Quote from ZK lock recipe: // 1. Call create( ) with a pathname of "_locknode_/lock-" and the sequence and ephemeral flags set. zk.retryOperation(new ZooKeeperOperation<String>() { @Override public String execute() throws KeeperException, InterruptedException { return zk.create(lockPath + "/lock-" + threadId + "-", null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL); } }); while (true) { // Quote from ZK lock recipe: // 2. Call getChildren( ) on the lock node without setting the watch flag (this is important to avoid // the herd effect). List<ZkLockNode> children = parseChildren(zk.retryOperation(new ZooKeeperOperation<List<String>>() { @Override public List<String> execute() throws KeeperException, InterruptedException { return zk.getChildren(lockPath, null); } })); ZkLockNode myLockNode = null; String myLockName = null; String myLockPath = null; for (ZkLockNode child : children) { // if the child has the same thread id and session id as us, then it is our lock if (child.getThreadId() == threadId) { final String childPath = lockPath + "/" + child.getName(); Stat stat = zk.retryOperation(new ZooKeeperOperation<Stat>() { @Override public Stat execute() throws KeeperException, InterruptedException { return zk.exists(childPath, false); } }); if (stat != null && stat.getEphemeralOwner() == zk.getSessionId()) { if (myLockName != null) { // We have found another lock node which belongs to us. // This means that the lock creation above was executed twice, which can occur // in case of connection loss. Delete this node to avoid that otherwise it would // never be released. zk.retryOperation(new ZooKeeperOperation<Object>() { @Override public Object execute() throws KeeperException, InterruptedException { try { zk.delete(childPath, -1); } catch (KeeperException.NoNodeException e) { // ignore } return null; } }); } else { myLockNode = child; myLockName = child.getName(); myLockPath = childPath; } } } } if (myLockName == null) { throw new ZkLockException("Unexpected problem: did not find our lock node."); } // Idea to use SortedSets seen in a ZK recipe SortedSet<ZkLockNode> sortedChildren = new TreeSet<ZkLockNode>(children); SortedSet<ZkLockNode> lowerThanMe = sortedChildren.headSet(myLockNode); // Quote from ZK lock recipe: // 3. If the pathname created in step 1 has the lowest sequence number suffix, the client has the lock // and the client exits the protocol. if (lowerThanMe.isEmpty()) { // We have the lock return myLockPath; } // Quote from ZK lock recipe: // 4. The client calls exists( ) with the watch flag set on the path in the lock directory with the // next lowest sequence number. final String pathToWatch = lockPath + "/" + lowerThanMe.last().name; final Object condition = new Object(); final MyWatcher watcher = new MyWatcher(pathToWatch, condition); Stat stat = zk.retryOperation(new ZooKeeperOperation<Stat>() { @Override public Stat execute() throws KeeperException, InterruptedException { return zk.exists(pathToWatch, watcher); } }); if (stat == null) { // Quote from ZK lock recipe: // 5a. if exists( ) returns false, go to step 2. // This means (I think) that the lock was removed (explicitly or through session expiration) between // the moment we queried for the children and the moment we called exists() // If the node does not exist, the watcher will still be left, does not seem so tidy, hopefully // this situation does not occur often. // Let's log it to keep an eye on it LogFactory.getLog(ZkLock.class).warn("Next lower lock node does not exist: " + pathToWatch); } else { // Quote from ZK lock recipe: // 5b. Otherwise, wait for a notification for the pathname from the previous step before going // to step 2. synchronized (condition) { while (!watcher.gotNotified) { condition.wait(); } } } } } catch (Throwable t) { throw new ZkLockException("Error obtaining lock, path: " + lockPath, t); } }
From source file:com.aurel.track.exchange.docx.exporter.AssembleWordprocessingMLPackage.java
/** * Gets the WordprocessingMLPackage from report beans * @param reportBeans//ww w . java 2 s . com * @return */ private static void assembleWordMLPackage(WordprocessingMLPackage wordMLPackage, List<ReportBean> reportBeansList, Set<Integer> explicitItemIDs, Integer personID, Locale locale, Map<Integer, String> outlineStylesMap, int headingLevel, int pheading1No, SortedMap<String, ImageOrTableCaption> imageCaptionMap, SortedMap<String, ImageOrTableCaption> tableCaptionMap, boolean highlightInlineContent, String inlineContentStyleID, boolean inlineContentStyleIsParagraphStyle, PreprocessImage preprocessImage, PreprocessTable preprocessTable) { MainDocumentPart mainDocumentPart = wordMLPackage.getMainDocumentPart(); String styleId = outlineStylesMap.get(Integer.valueOf(headingLevel)); int heading1No = pheading1No; if (styleId == null) { //fall back to last heading style styleId = outlineStylesMap.get(Integer.valueOf(9)); } for (ReportBean reportBean : reportBeansList) { TWorkItemBean workItemBean = reportBean.getWorkItemBean(); Integer workItemID = workItemBean.getObjectID(); String title = workItemBean.getSynopsis(); if (title != null) { mainDocumentPart.addObject(addHeaderParagraphOfText(mainDocumentPart, workItemID, title, styleId)); } if (headingLevel == 0) { heading1No++; preprocessImage.setChapterNo(heading1No); preprocessTable.setChapterNo(heading1No); //reset the image counter after a new Heading 1 preprocessImage.setCounterWithinChapter(0); //reset the table counter after a new Heading 1 preprocessTable.setCounterWithinChapter(0); } List<Integer> itemIDs = new LinkedList<Integer>(); String description = workItemBean.getDescription(); if (description != null && !"".equals(description)) { //remove HTML headers description = removeHtmlHeadings(description); if (highlightInlineContent) { List<Section> sections = new LinkedList<AssembleWordprocessingMLPackage.Section>(); exportDescription(description, itemIDs, sections, false); for (Section section : sections) { String content = section.getContent(); boolean inline = section.isInline(); List<Object> contents = transformHTMLContent(wordMLPackage, content, title, workItemID, personID, imageCaptionMap, tableCaptionMap, preprocessImage, preprocessTable); if (contents != null) { mainDocumentPart.getContent().addAll(contents); if (inline) { new InlineStyleUtil().addInlineStyle(contents, locale, inlineContentStyleID, inlineContentStyleIsParagraphStyle); } } } } else { description = exportDescription(description, itemIDs); List<Object> contents = transformHTMLContent(wordMLPackage, description, title, workItemID, personID, imageCaptionMap, tableCaptionMap, preprocessImage, preprocessTable); if (contents != null) { mainDocumentPart.getContent().addAll(contents); } } } //add image attachments //gather the report bean links List<ReportBean> reportBeansWithLinks = new LinkedList<ReportBean>(); SortedSet<ReportBeanLink> reportBeanLinks = reportBean.getReportBeanLinksSet(); if (reportBeanLinks != null && !reportBeanLinks.isEmpty()) { reportBeansWithLinks.add(reportBean); } //gather the links of the inline items int[] workItemIDs = GeneralUtils.createIntArrFromIntegerList(itemIDs); if (workItemIDs != null && workItemIDs.length > 0) { List<ReportBean> internalReportBeans = LoadItemIDListItems.getReportBeansByWorkItemIDs(workItemIDs, false, personID, locale, false, false, false, false, false, false, false, true, false); if (internalReportBeans != null) { for (ReportBean internalReportBean : internalReportBeans) { SortedSet<ReportBeanLink> internalReportBeanLinks = internalReportBean .getReportBeanLinksSet(); if (internalReportBeanLinks != null && !internalReportBeanLinks.isEmpty()) { reportBeansWithLinks.add(internalReportBean); for (ReportBeanLink reportBeanLink : internalReportBeanLinks) { boolean included = reportBeanLink.isLinkedItemIncluded(); if (!included) { Integer linkedItem = reportBeanLink.getWorkItemID(); if (linkedItem != null && explicitItemIDs.contains(linkedItem)) { reportBeanLink.setLinkedItemIncluded(true); } } } } } } } if (!reportBeansWithLinks.isEmpty()) { TableWithBorders.addLinkedItemsTable(reportBeansWithLinks, locale, mainDocumentPart); } List<ReportBean> reportBeanChildrenList = reportBean.getChildren(); if (reportBeanChildrenList != null) { assembleWordMLPackage(wordMLPackage, reportBeanChildrenList, explicitItemIDs, personID, locale, outlineStylesMap, headingLevel + 1, heading1No, imageCaptionMap, tableCaptionMap, highlightInlineContent, inlineContentStyleID, inlineContentStyleIsParagraphStyle, preprocessImage, preprocessTable); } } }
From source file:org.wrml.runtime.format.application.vnd.wrml.design.schema.SchemaDesignFormatter.java
public static ObjectNode createSchemaDesignObjectNode(final ObjectMapper objectMapper, final Schema schema) { final Context context = schema.getContext(); final SyntaxLoader syntaxLoader = context.getSyntaxLoader(); final SchemaLoader schemaLoader = context.getSchemaLoader(); final ObjectNode rootNode = objectMapper.createObjectNode(); final URI schemaUri = schema.getUri(); final Prototype prototype = schemaLoader.getPrototype(schemaUri); rootNode.put(PropertyName.uri.name(), syntaxLoader.formatSyntaxValue(schemaUri)); rootNode.put(PropertyName.title.name(), schema.getTitle()); rootNode.put(PropertyName.description.name(), schema.getDescription()); rootNode.put(PropertyName.version.name(), schema.getVersion()); final String titleSlotName = getTitleSlotName(schemaUri, schemaLoader); if (titleSlotName != null) { rootNode.put(PropertyName.titleSlotName.name(), titleSlotName); }/*from w w w . ja v a 2 s . com*/ final UniqueName uniqueName = schema.getUniqueName(); final ObjectNode uniqueNameNode = objectMapper.createObjectNode(); uniqueNameNode.put(PropertyName.fullName.name(), uniqueName.getFullName()); uniqueNameNode.put(PropertyName.namespace.name(), uniqueName.getNamespace()); uniqueNameNode.put(PropertyName.localName.name(), uniqueName.getLocalName()); rootNode.put(PropertyName.uniqueName.name(), uniqueNameNode); final Set<URI> declaredBaseSchemaUris = prototype.getDeclaredBaseSchemaUris(); if (declaredBaseSchemaUris != null && !declaredBaseSchemaUris.isEmpty()) { final Set<URI> addedBaseSchemaUris = new LinkedHashSet<>(); final ArrayNode baseSchemasNode = objectMapper.createArrayNode(); rootNode.put(PropertyName.baseSchemas.name(), baseSchemasNode); for (final URI baseSchemaUri : declaredBaseSchemaUris) { if (!addedBaseSchemaUris.contains(baseSchemaUri)) { final ObjectNode baseSchemaNode = buildSchemaNode(objectMapper, baseSchemaUri, schemaLoader, addedBaseSchemaUris); baseSchemasNode.add(baseSchemaNode); addedBaseSchemaUris.add(baseSchemaUri); } } } final Set<String> keySlotNames = prototype.getDeclaredKeySlotNames(); if (keySlotNames != null && !keySlotNames.isEmpty()) { final ArrayNode keyPropertyNamesNode = objectMapper.createArrayNode(); for (final String keySlotName : keySlotNames) { keyPropertyNamesNode.add(keySlotName); } if (keyPropertyNamesNode.size() > 0) { rootNode.put(PropertyName.keyPropertyNames.name(), keyPropertyNamesNode); } } final Set<String> allKeySlotNames = prototype.getAllKeySlotNames(); final ArrayNode allKeySlotNamesNode = objectMapper.createArrayNode(); rootNode.put(PropertyName.allKeySlotNames.name(), allKeySlotNamesNode); final ObjectNode keySlotMap = objectMapper.createObjectNode(); rootNode.put(PropertyName.keys.name(), keySlotMap); final String uriSlotName = PropertyName.uri.name(); if (allKeySlotNames.contains(uriSlotName)) { allKeySlotNamesNode.add(uriSlotName); final ObjectNode slot = createSlot(objectMapper, prototype, uriSlotName); keySlotMap.put(uriSlotName, slot); } for (final String keySlotName : allKeySlotNames) { if (!Document.SLOT_NAME_URI.equals(keySlotName)) { allKeySlotNamesNode.add(keySlotName); final ObjectNode slot = createSlot(objectMapper, prototype, keySlotName); keySlotMap.put(keySlotName, slot); } } rootNode.put(PropertyName.keyCount.name(), keySlotMap.size()); final SortedSet<String> allSlotNames = prototype.getAllSlotNames(); if (allSlotNames != null && !allSlotNames.isEmpty()) { final ObjectNode slotMapNode = objectMapper.createObjectNode(); rootNode.put(PropertyName.slots.name(), slotMapNode); final ArrayNode propertyNamesNode = objectMapper.createArrayNode(); for (final String slotName : allSlotNames) { final ProtoSlot protoSlot = prototype.getProtoSlot(slotName); if (protoSlot instanceof LinkProtoSlot) { continue; } if (allKeySlotNames.contains(slotName)) { // Skip key slots (handled separately) continue; } if (protoSlot.getDeclaringSchemaUri().equals(schemaUri)) { propertyNamesNode.add(slotName); } final ObjectNode slotNode = createSlot(objectMapper, prototype, slotName); if (slotNode != null) { slotMapNode.put(slotName, slotNode); } } if (propertyNamesNode.size() > 0) { rootNode.put(PropertyName.propertyNames.name(), propertyNamesNode); } rootNode.put(PropertyName.slotCount.name(), slotMapNode.size()); } final Set<String> comparablePropertyNames = prototype.getComparableSlotNames(); if (comparablePropertyNames != null && !comparablePropertyNames.isEmpty()) { final ArrayNode comparablePropertyNamesNode = objectMapper.createArrayNode(); for (final String comparablePropertyName : comparablePropertyNames) { comparablePropertyNamesNode.add(comparablePropertyName); } if (comparablePropertyNamesNode.size() > 0) { rootNode.put(PropertyName.comparablePropertyNames.name(), comparablePropertyNamesNode); } } final Collection<LinkProtoSlot> linkProtoSlots = prototype.getLinkProtoSlots().values(); if (linkProtoSlots != null && !linkProtoSlots.isEmpty()) { final ArrayNode linkNamesNode = objectMapper.createArrayNode(); final ObjectNode linksMapNode = objectMapper.createObjectNode(); rootNode.put(PropertyName.links.name(), linksMapNode); for (final LinkProtoSlot linkProtoSlot : linkProtoSlots) { if (linkProtoSlot.getDeclaringSchemaUri().equals(schemaUri)) { linkNamesNode.add(linkProtoSlot.getName()); } final ObjectNode linkNode = objectMapper.createObjectNode(); String linkTitle = linkProtoSlot.getTitle(); if (linkTitle == null) { linkTitle = linkProtoSlot.getName(); } linkNode.put(PropertyName.name.name(), linkProtoSlot.getName()); linkNode.put(PropertyName.title.name(), linkTitle); final Method method = linkProtoSlot.getMethod(); final URI linkRelationUri = linkProtoSlot.getLinkRelationUri(); final URI declaringSchemaUri = linkProtoSlot.getDeclaringSchemaUri(); linkNode.put(PropertyName.rel.name(), syntaxLoader.formatSyntaxValue(linkRelationUri)); final Keys linkRelationKeys = context.getApiLoader().buildDocumentKeys(linkRelationUri, schemaLoader.getLinkRelationSchemaUri()); final LinkRelation linkRelation = context.getModel(linkRelationKeys, schemaLoader.getLinkRelationDimensions()); linkNode.put(PropertyName.relationTitle.name(), linkRelation.getTitle()); linkNode.put(PropertyName.description.name(), linkProtoSlot.getDescription()); linkNode.put(PropertyName.method.name(), method.getProtocolGivenName()); linkNode.put(PropertyName.declaringSchemaUri.name(), syntaxLoader.formatSyntaxValue(declaringSchemaUri)); URI requestSchemaUri = linkProtoSlot.getRequestSchemaUri(); if (schemaLoader.getDocumentSchemaUri().equals(requestSchemaUri)) { if (SystemLinkRelation.self.getUri().equals(linkRelationUri) || SystemLinkRelation.save.getUri().equals(linkRelationUri)) { requestSchemaUri = schemaUri; } } if (requestSchemaUri == null && method == Method.Save) { requestSchemaUri = schemaUri; } if (requestSchemaUri != null) { linkNode.put(PropertyName.requestSchemaUri.name(), syntaxLoader.formatSyntaxValue(requestSchemaUri)); final Schema requestSchema = schemaLoader.load(requestSchemaUri); if (requestSchema != null) { linkNode.put(PropertyName.requestSchemaTitle.name(), requestSchema.getTitle()); } } URI responseSchemaUri = linkProtoSlot.getResponseSchemaUri(); if (schemaLoader.getDocumentSchemaUri().equals(responseSchemaUri)) { if (SystemLinkRelation.self.getUri().equals(linkRelationUri) || SystemLinkRelation.save.getUri().equals(linkRelationUri)) { responseSchemaUri = schemaUri; } } if (responseSchemaUri != null) { linkNode.put(PropertyName.responseSchemaUri.name(), syntaxLoader.formatSyntaxValue(responseSchemaUri)); final Schema responseSchema = schemaLoader.load(responseSchemaUri); if (responseSchema != null) { linkNode.put(PropertyName.responseSchemaTitle.name(), responseSchema.getTitle()); } } linksMapNode.put(linkTitle, linkNode); } if (linkNamesNode.size() > 0) { rootNode.put(PropertyName.linkNames.name(), linkNamesNode); } rootNode.put(PropertyName.linkCount.name(), linksMapNode.size()); } return rootNode; }
From source file:net.java.sip.communicator.impl.history.HistoryReaderImpl.java
/** * Used to limit the files if any starting or ending date exist * So only few files to be searched./*from w w w .ja va 2s . co m*/ * * @param filelist Iterator * @param startDate Date * @param endDate Date * @param reverseOrder reverse order of files * @return Vector */ static Vector<String> filterFilesByDate(Iterator<String> filelist, Date startDate, Date endDate, final boolean reverseOrder) { if (startDate == null && endDate == null) { // no filtering needed then just return the same list Vector<String> result = new Vector<String>(); while (filelist.hasNext()) { result.add(filelist.next()); } Collections.sort(result, new Comparator<String>() { public int compare(String o1, String o2) { if (reverseOrder) return o2.compareTo(o1); else return o1.compareTo(o2); } }); return result; } // first convert all files to long TreeSet<Long> files = new TreeSet<Long>(); while (filelist.hasNext()) { String filename = filelist.next(); files.add(Long.parseLong(filename.substring(0, filename.length() - 4))); } TreeSet<Long> resultAsLong = new TreeSet<Long>(); // Temporary fix of a NoSuchElementException if (files.size() == 0) { return new Vector<String>(); } Long startLong; Long endLong; if (startDate == null) startLong = Long.MIN_VALUE; else startLong = startDate.getTime(); if (endDate == null) endLong = Long.MAX_VALUE; else endLong = endDate.getTime(); // get all records inclusive the one before the startdate for (Long f : files) { if (startLong <= f && f <= endLong) { resultAsLong.add(f); } } // get the subset before the start date, to get its last element // if exists if (!files.isEmpty() && files.first() <= startLong) { SortedSet<Long> setBeforeTheInterval = files.subSet(files.first(), true, startLong, true); if (!setBeforeTheInterval.isEmpty()) resultAsLong.add(setBeforeTheInterval.last()); } Vector<String> result = new Vector<String>(); Iterator<Long> iter = resultAsLong.iterator(); while (iter.hasNext()) { Long item = iter.next(); result.add(item.toString() + ".xml"); } Collections.sort(result, new Comparator<String>() { public int compare(String o1, String o2) { if (reverseOrder) return o2.compareTo(o1); else return o1.compareTo(o2); } }); return result; }
From source file:net.sourceforge.fenixedu.presentationTier.docs.academicAdministrativeOffice.ApprovementInfoForEquivalenceProcess.java
public static String getApprovementsInfo(final Registration registration) { final StringBuilder res = new StringBuilder(); final SortedSet<ICurriculumEntry> entries = new TreeSet<ICurriculumEntry>( ICurriculumEntry.COMPARATOR_BY_EXECUTION_PERIOD_AND_NAME_AND_ID); final Map<Unit, String> ids = new HashMap<Unit, String>(); if (registration.isBolonha()) { reportCycles(res, entries, ids, registration); } else {//from w w w . j ava 2 s. c om final ICurriculum curriculum = registration.getCurriculum(); filterEntries(entries, curriculum); reportEntries(res, entries, ids, registration); } entries.clear(); entries.addAll(getExtraCurricularEntriesToReport(registration)); if (!entries.isEmpty()) { reportRemainingEntries(res, entries, ids, registration.getLastStudentCurricularPlan().getExtraCurriculumGroup(), registration); } entries.clear(); entries.addAll(getPropaedeuticEntriesToReport(registration)); if (!entries.isEmpty()) { reportRemainingEntries(res, entries, ids, registration.getLastStudentCurricularPlan().getPropaedeuticCurriculumGroup(), registration); } res.append(getRemainingCreditsInfo(registration.getCurriculum())); res.append(LINE_BREAK); if (!ids.isEmpty()) { res.append(LINE_BREAK).append(getAcademicUnitInfo(ids)); } return res.toString(); }
From source file:com.spotify.heroic.filter.OrFilter.java
static Filter optimize(final SortedSet<Filter> filters) { final SortedSet<Filter> result = new TreeSet<>(); for (final Filter f : filters) { if (f instanceof NotFilter) { // Optimize away expressions which are always true. // Example: foo = bar or !(foo = bar) if (filters.contains(((NotFilter) f).getFilter())) { return TrueFilter.get(); }//from ww w .j a v a2 s. c om } else if (f instanceof StartsWithFilter) { // Optimize away prefixes which encompass each other. // Example: foo ^ hello or foo ^ helloworld -> foo ^ hello if (FilterUtils.containsPrefixedWith(filters, (StartsWithFilter) f, (inner, outer) -> FilterUtils.prefixedWith(outer.getValue(), inner.getValue()))) { continue; } } result.add(f); } if (result.isEmpty()) { return TrueFilter.get(); } if (result.size() == 1) { return result.iterator().next(); } return new OrFilter(ImmutableList.copyOf(result)); }
From source file:org.apache.lens.cube.error.ConflictingFields.java
public ConflictingFields(@NonNull final SortedSet<String> fields) { checkArgument(!fields.isEmpty(), "We should atleast have one conflicting field to create a valid instance."); for (String field : fields) { checkState(field != null, "Conflicting fields must not contain null. Conflicting fields: %s", fields); }//from w ww. java 2 s.c o m this.fields = fields; }