Java Code Examples for org.eclipse.collections.api.list.ImmutableList#size()

The following examples show how to use org.eclipse.collections.api.list.ImmutableList#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogHandler.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
private void logErrorMessages(final Report report) {
    ImmutableList<String> errorMessages = report.getErrorMessages();
    if (errorPosition < errorMessages.size()) {
        errorLogger.logEachLine(errorMessages.subList(errorPosition, errorMessages.size()).castToList());
        errorPosition = errorMessages.size();
    }
}
 
Example 2
Source File: LogHandler.java    From warnings-ng-plugin with MIT License 5 votes vote down vote up
private void logInfoMessages(final Report report) {
    ImmutableList<String> infoMessages = report.getInfoMessages();
    if (infoPosition < infoMessages.size()) {
        logger.logEachLine(infoMessages.subList(infoPosition, infoMessages.size()).castToList());
        infoPosition = infoMessages.size();
    }
}
 
Example 3
Source File: AbstractEnvironmentEnricher.java    From obevo with Apache License 2.0 5 votes vote down vote up
private Schema convertCfgToSchema(ImmutableHierarchicalConfiguration object, final Platform systemDbPlatform, final int schemaNameValidation) {
    String schemaName = object.getString("name");
    if (schemaNameValidation >= 2) {
        validateSchemaName(schemaName);
    }
    boolean readOnly = object.getBoolean("readOnly", false);

    MutableSetMultimap<String, String> excludedNameMap = Multimaps.mutable.set.empty();

    ImmutableList<ImmutableHierarchicalConfiguration> excludes = iterConfig(object, "excludes");
    if (!excludes.isEmpty()) {
        if (excludes.size() > 1) {
            throw new IllegalArgumentException("Only expecting 1 excludes element under <schema>");
        }
        ImmutableHierarchicalConfiguration excludesConfig = excludes.get(0);
        if (excludesConfig != null) {
            for (ChangeType changeType : systemDbPlatform.getChangeTypes()) {
                ImmutableList<String> excludedNames = iterListString(excludesConfig, changeType.getName().toLowerCase());
                if (excludedNames.notEmpty()) {
                    excludedNameMap.putAll(changeType.getName(), excludedNames);
                }

                ImmutableList<String> excludedPatterns = iterListString(excludesConfig, changeType.getName().toLowerCase() + "Pattern");
                if (excludedPatterns.notEmpty()) {
                    throw new IllegalArgumentException("The <objectType>Pattern element is deprecated. Use just the <objectType> element w/ wildcards (% or *)");
                }
            }

            if (iterListString(excludesConfig, "procedure").notEmpty() || iterListString(excludesConfig, "procedurePattern").notEmpty()) {
                throw new IllegalArgumentException("The procedure and procedurePattern elements are no longer supported. Use <sp> only, with wildcards (% or *) if  needed");
            }
        }
    }

    return new Schema(schemaName, systemDbPlatform.getObjectExclusionPredicateBuilder().add(excludedNameMap.toImmutable()), readOnly);
}
 
Example 4
Source File: TextMarkupDocumentReaderOld.java    From obevo with Apache License 2.0 4 votes vote down vote up
private ImmutableList<TextMarkupDocumentSection> parseString(String text, MutableList<String> elementsToCheck, boolean recurse,
        String elementPrefix) {
    MutableList<TextMarkupDocumentSection> sections = Lists.mutable.empty();
    while (true) {
        int earliestIndex = Integer.MAX_VALUE;

        for (String firstLevelElement : elementsToCheck) {
            int index = text.indexOf(elementPrefix + " " + firstLevelElement, 1);
            if (index != -1 && index < earliestIndex) {
                earliestIndex = index;
            }
        }

        if (earliestIndex == Integer.MAX_VALUE) {
            sections.add(new TextMarkupDocumentSection(null, text));
            break;
        } else {
            sections.add(new TextMarkupDocumentSection(null, text.substring(0, earliestIndex)));
            text = text.substring(earliestIndex);
        }
    }
    for (TextMarkupDocumentSection section : sections) {
        MutableMap<String, String> attrs = Maps.mutable.empty();
        MutableSet<String> toggles = Sets.mutable.empty();
        String content = StringUtils.chomp(section.getContent());

        String[] contents = content.split("\\r?\\n", 2);
        String firstLine = contents[0];

        for (String elementToCheck : elementsToCheck) {
            if (firstLine.startsWith(elementPrefix + " " + elementToCheck)) {
                section.setName(elementToCheck);
                String[] args = StringUtils.splitByWholeSeparator(firstLine, " ");
                for (String arg : args) {
                    if (arg.contains("=")) {
                        String[] attr = arg.split("=");
                        if (attr.length > 2) {
                            throw new IllegalArgumentException("Cannot mark = multiple times in a parameter - "
                                    + firstLine);
                        }
                        String attrVal = attr[1];
                        if (attrVal.startsWith("\"") && attrVal.endsWith("\"")) {
                            attrVal = attrVal.substring(1, attrVal.length() - 1);
                        }
                        attrs.put(attr[0], attrVal);
                    } else {
                        toggles.add(arg);
                    }
                }
                if (contents.length > 1) {
                    content = contents[1];
                } else {
                    content = null;
                }
            }
        }
        section.setAttrs(attrs.toImmutable());
        section.setToggles(toggles.toImmutable());

        if (!recurse) {
            section.setContent(content);
        } else if (content != null) {
            ImmutableList<TextMarkupDocumentSection> subsections = this.parseString(content, this.secondLevelElements, false, "//");
            if (subsections.size() == 1) {
                section.setContent(content);
            } else {
                section.setContent(subsections.get(0).getContent());
                section.setSubsections(subsections.subList(1, subsections.size()));
            }
        } else {
            section.setContent(null);
        }
    }

    return sections.toImmutable();
}
 
Example 5
Source File: TextMarkupDocumentReader.java    From obevo with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<TextMarkupDocumentSection> valueOf(Pair<String, String> outerSection) {
    String currentSectionName = outerSection.getOne();
    if (currentSectionName == null) {
        return Lists.mutable.with(new TextMarkupDocumentSection(null, outerSection.getTwo()));
    } else {
        String[] contents = outerSection.getTwo().split("\\r?\\n", 2);
        String firstLine = contents[0];
        firstLine = firstLine.replaceFirst(elementPrefix + " " + currentSectionName, "");

        Pair<ImmutableMap<String, String>, ImmutableSet<String>> attrsTogglesPair = parseAttrsAndToggles(firstLine);
        ImmutableMap<String, String> attrs = attrsTogglesPair.getOne();
        ImmutableSet<String> toggles = attrsTogglesPair.getTwo();

        String sectionContent = contents.length > 1 ? contents[1] : null;
        if (singleLineElements.contains(currentSectionName)) {
            TextMarkupDocumentSection metadataSection = new TextMarkupDocumentSection(currentSectionName, null, attrs.toImmutable());
            metadataSection.setToggles(toggles.toImmutable());
            return Lists.mutable.with(metadataSection, new TextMarkupDocumentSection(null, sectionContent));
        } else {
            ImmutableList<TextMarkupDocumentSection> finalsubsections = Lists.immutable.empty();
            String finalContent;
            if (!recurse) {
                finalContent = sectionContent;
            } else if (sectionContent != null) {
                ImmutableList<TextMarkupDocumentSection> subsections = parseString(sectionContent, secondLevelElements, false, "//");
                if (subsections.size() == 1) {
                    finalContent = sectionContent;
                } else {
                    finalContent = subsections.get(0).getContent();
                    finalsubsections = subsections.subList(1, subsections.size());
                }
            } else {
                finalContent = null;
            }

            TextMarkupDocumentSection section = new TextMarkupDocumentSection(currentSectionName, finalContent, attrs.toImmutable());
            section.setToggles(toggles.toImmutable());
            section.setSubsections(finalsubsections);
            return Lists.mutable.with(section);
        }
    }
}