当前位置: 首页>>代码示例>>Java>>正文


Java ImmutableList.notEmpty方法代码示例

本文整理汇总了Java中org.eclipse.collections.api.list.ImmutableList.notEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableList.notEmpty方法的具体用法?Java ImmutableList.notEmpty怎么用?Java ImmutableList.notEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.collections.api.list.ImmutableList的用法示例。


在下文中一共展示了ImmutableList.notEmpty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateStructureNew

import org.eclipse.collections.api.list.ImmutableList; //导入方法依赖的package包/类
@Override
protected void validateStructureNew(TextMarkupDocument doc) {
    ImmutableList<TextMarkupDocumentSection> docSections = doc.getSections();

    if (docSections.isEmpty() || docSections.noneSatisfy(Predicates.attributeEqual(TextMarkupDocumentSection.TO_NAME, TextMarkupDocumentReader.TAG_CHANGE))) {
        throw new IllegalArgumentException("No //// " + TextMarkupDocumentReader.TAG_CHANGE + " sections found; at least one is required");
    }

    if (!(TextMarkupDocumentReader.TAG_CHANGE.equals(docSections.get(0).getName()) || TextMarkupDocumentReader.TAG_METADATA.equals(docSections.get(0).getName()))) {
        throw new IllegalArgumentException("First content of the file must be the //// CHANGE line, " +
                "or a //// " + TextMarkupDocumentReader.TAG_METADATA + " line, " +
                "or just a blank line");
    }

    if (TextMarkupDocumentReader.TAG_METADATA.equals(docSections.get(0).getName())) {
        docSections = docSections.subList(1, docSections.size());
    }

    ImmutableList<TextMarkupDocumentSection> badSections = docSections.reject(Predicates.attributeEqual(TextMarkupDocumentSection.TO_NAME, TextMarkupDocumentReader.TAG_CHANGE));
    if (badSections.notEmpty()) {
        throw new IllegalArgumentException("File structure for incremental file must be optionally a //// " + TextMarkupDocumentReader.TAG_METADATA + " section followed only by //// " + TextMarkupDocumentReader.TAG_CHANGE + " sections. Instead, found this section in between: " + badSections);
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:24,代码来源:TableChangeParser.java

示例2: validateAttributes

import org.eclipse.collections.api.list.ImmutableList; //导入方法依赖的package包/类
private void validateAttributes(TextMarkupDocument doc) {
    ImmutableList<String> disallowedSections = doc.getSections().collect(TextMarkupDocumentSection.TO_NAME).select(Predicates.in(disallowedSectionNames));

    if (disallowedSections.notEmpty()) {
        throw new IllegalArgumentException("Found these disallowed sections: " + disallowedSections);
    }

    for (TextMarkupDocumentSection section : doc.getSections()) {
        ImmutableSet<String> disallowedAttrs = section.getAttrs().keysView().toSet().toImmutable().difference(allowedAttrs);
        ImmutableSet<String> disallowedToggles = section.getToggles().difference(allowedToggles);

        MutableList<String> errorMessages = Lists.mutable.empty();
        if (disallowedAttrs.notEmpty()) {
            errorMessages.add("Following attributes are not allowed in the " + section.getName() + " section: " + disallowedAttrs);
        }
        if (disallowedToggles.notEmpty()) {
            errorMessages.add("Following toggles are not allowed in the " + section.getName() + " section: " + disallowedToggles);
        }
        if (errorMessages.notEmpty()) {
            throw new IllegalArgumentException("Found " + errorMessages.size() + " errors in the input: " + errorMessages.makeString(";;; "));
        }
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:24,代码来源:AbstractDbChangeFileParser.java

示例3: setupUsers

import org.eclipse.collections.api.list.ImmutableList; //导入方法依赖的package包/类
private void setupUsers(Connection conn, PhysicalSchema schema, boolean failOnSetupException) {
    MutableSet<String> existingUsers;
    try {
        existingUsers = ListAdapter.adapt(jdbc.query(conn, schema.getPhysicalName() + "..sp_helpuser", new ColumnListHandler<String>("Users_name"))).toSet();
    } catch (DataAccessException e) {
        if (failOnSetupException) {
            throw e;
        } else {
            LOG.warn("User validation query failed; continuing w/ deployment per configuration", e);
            deployMetricsCollector.addMetric(DeployMetrics.WARNINGS_PREFIX + ".aseUserValidationQueryFailure", true);
            return;
        }
    }

    ImmutableList<User> missingUsers = env.getUsers().select(Predicates.attributeNotIn(User.TO_NAME, existingUsers));
    if (missingUsers.notEmpty()) {
        String errorMessage = "Specified users " + missingUsers.collect(User.TO_NAME).makeString("[", ",", "]") + " do not exist in database " + schema.getPhysicalName() + "; please create the users or remove from your configuration (or rely on groups instead for permissions)";
        if (failOnSetupException) {
            throw new IllegalArgumentException(errorMessage);
        } else {
            LOG.warn(errorMessage);
            LOG.warn("Will proceed with deployment as you have configured this to just be a warning");
            deployMetricsCollector.addMetric(DeployMetrics.WARNINGS_PREFIX + ".usersInConfigButNotInDb", errorMessage);
        }
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:27,代码来源:AseEnvironmentInfraSetup.java

示例4: validateStructureNew

import org.eclipse.collections.api.list.ImmutableList; //导入方法依赖的package包/类
@Override
protected void validateStructureNew(TextMarkupDocument doc) {
    String allowedSectionString = Sets.immutable.with(TextMarkupDocumentReader.TAG_METADATA, TextMarkupDocumentReader.TAG_BODY, TextMarkupDocumentReader.TAG_DROP_COMMAND).collect(StringFunctions.prepend("//// ")).makeString(", ");

    ImmutableList<TextMarkupDocumentSection> docSections = doc.getSections();
    if (docSections.isEmpty()) {
        throw new IllegalArgumentException("No content defined");
    }

    ImmutableList<TextMarkupDocumentSection> disallowedSections = docSections.reject(Predicates.attributeIn(TextMarkupDocumentSection.TO_NAME, Sets.immutable.with(null, TextMarkupDocumentReader.TAG_METADATA, TextMarkupDocumentReader.TAG_DROP_COMMAND, TextMarkupDocumentReader.TAG_BODY)));
    if (disallowedSections.notEmpty()) {
        throw new IllegalArgumentException("Only allowed 1 content section and at most 1 of these [" + allowedSectionString + "]; instead, found these disallowed sections: " + disallowedSections);
    }

    ImmutableList<String> sectionNames = docSections.collect(TextMarkupDocumentSection.TO_NAME);
    MutableBag<String> duplicateSections = sectionNames.toBag().selectByOccurrences(IntPredicates.greaterThan(1));
    if (duplicateSections.notEmpty()) {
        throw new IllegalArgumentException("Only allowed 1 content section and at most 1 of these [" + allowedSectionString + "]; instead, found these extra sections instances: " + duplicateSections.toSet());
    }

    int metadataIndex = sectionNames.indexOf(TextMarkupDocumentReader.TAG_METADATA);
    int contentIndex = sectionNames.indexOf(null);
    int dropIndexIndex = sectionNames.indexOf(TextMarkupDocumentReader.TAG_DROP_COMMAND);

    if (metadataIndex != -1 && contentIndex != -1 && metadataIndex > contentIndex) {
        throw new IllegalArgumentException("Improper section ordering: " + TextMarkupDocumentReader.TAG_METADATA + " section must come before the content section");
    } else if (contentIndex != -1 && dropIndexIndex != -1 && contentIndex > dropIndexIndex) {
        throw new IllegalArgumentException("Improper section ordering: content section must come before the " + TextMarkupDocumentReader.TAG_DROP_COMMAND + " section");
    }

}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:32,代码来源:RerunnableChangeParser.java

示例5: validateChangeTypes

import org.eclipse.collections.api.list.ImmutableList; //导入方法依赖的package包/类
protected void validateChangeTypes(ImmutableList<ChangeType> changeTypes, final ChangeTypeBehaviorRegistry changeTypeBehaviorRegistry) {
    ImmutableList<ChangeType> unenrichedChangeTypes = changeTypes.reject(new Predicate<ChangeType>() {
        @Override
        public boolean accept(ChangeType changeType) {
            return changeTypeBehaviorRegistry.getChangeTypeBehavior(changeType.getName()) != null;
        }
    });
    if (unenrichedChangeTypes.notEmpty()) {
        throw new IllegalStateException("The following change types were not enriched: " + unenrichedChangeTypes);
    }

    CollectionUtil.verifyNoDuplicates(changeTypes, ChangeType.TO_NAME, "Not expecting multiple ChangeTypes with the same name");

}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:15,代码来源:DbDeployerAppContextImpl.java

示例6: determineRollbackForSchema

import org.eclipse.collections.api.list.ImmutableList; //导入方法依赖的package包/类
@VisibleForTesting
boolean determineRollbackForSchema(final String deployVersion, ImmutableCollection<DeployExecution> deployExecutions) {
    logDeployExecutions(deployExecutions, "deploy executions");

    ImmutableList<DeployExecution> activeDeployments = getActiveDeployments(deployExecutions);

    logDeployExecutions(activeDeployments, "filtered active deploy executions");

    if (activeDeployments == null || activeDeployments.isEmpty()) {
        return false;
    }

    if (getDeployVersion(activeDeployments.getLast()).equals(deployVersion)) {
        return false;
    }

    ImmutableList<DeployExecution> deploymentsExcludingTheLast = activeDeployments.subList(0, activeDeployments.size() - 1);

    ImmutableList<DeployExecution> rollbackIndicativeDeployments = deploymentsExcludingTheLast.select(new Predicate<DeployExecution>() {
        @Override
        public boolean accept(DeployExecution pastDeployment) {
            return getDeployVersion(pastDeployment).equals(deployVersion);
        }
    });
    logDeployExecutions(rollbackIndicativeDeployments, "deploy executions that indicate a rollback");
    return rollbackIndicativeDeployments.notEmpty();
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:28,代码来源:DefaultRollbackDetector.java

示例7: convertCfgToSchema

import org.eclipse.collections.api.list.ImmutableList; //导入方法依赖的package包/类
private Function<HierarchicalConfiguration, Schema> convertCfgToSchema(final DbPlatform systemDbPlatform, final int schemaNameValidation) {
    return new Function<HierarchicalConfiguration, Schema>() {
        private static final long serialVersionUID = 1L;

        @Override
        public Schema valueOf(HierarchicalConfiguration object) {
            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<HierarchicalConfiguration> excludes = iterConfig(object, "excludes");
            if (!excludes.isEmpty()) {
                if (excludes.size() > 1) {
                    throw new IllegalArgumentException("Only expecting 1 excludes element under <schema>");
                }
                HierarchicalConfiguration excludesConfig = excludes.get(0);
                if (excludesConfig != null) {
                    for (ChangeType changeType : systemDbPlatform.getChangeTypes()) {
                        ImmutableList<String> excludedNames = iterString(excludesConfig, changeType.getName().toLowerCase());
                        if (excludedNames.notEmpty()) {
                            excludedNameMap.putAll(changeType.getName(), excludedNames);
                        }

                        ImmutableList<String> excludedPatterns = iterString(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 (iterString(excludesConfig, "procedure").notEmpty() || iterString(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);
        }
    };
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:45,代码来源:DbEnvironmentXmlEnricher.java

示例8: setupEnvInfra

import org.eclipse.collections.api.list.ImmutableList; //导入方法依赖的package包/类
@Override
public void setupEnvInfra(boolean failOnSetupException) {
    LOG.info("Verifying existence of DB2 groups prior to deployment");

    ImmutableSet<String> existingGroups;
    Connection conn = null;
    try {
        conn = ds.getConnection();
        existingGroups = Sets.immutable
                .withAll(jdbc.query(conn, "select ROLENAME from sysibm.SYSROLES", new ColumnListHandler<String>()))
                .newWithAll(jdbc.query(conn, "select GRANTEE from sysibm.SYSDBAUTH", new ColumnListHandler<String>()))
                .collect(StringFunctions.trim());  // db2 sometimes has whitespace in its return results that needs trimming
    } catch (Exception e) {
        if (failOnSetupException) {
            if (e instanceof RuntimeException) {
                throw (RuntimeException)e;
            }
            throw new RuntimeException(e);
        } else {
            LOG.warn("Group validation query failed; continuing w/ deployment per configuration", e);
            deployMetricsCollector.addMetric(DeployMetrics.WARNINGS_PREFIX + ".db2GroupValidationQueryFailure", true);
            return;
        }
    } finally {
        DbUtils.closeQuietly(conn);
    }

    LOG.info("Groups from DB: {}", existingGroups);

    ImmutableList<String> groupNames = env.getGroups().collect(Group.TO_NAME);
    LOG.info("Groups from system-config: {}", groupNames);

    // Do difference comparison in a case insensitive manner (convert all to lowercase)
    ImmutableList<String> missingGroups = groupNames.select(Predicates.attributeNotIn(StringFunctions.toLowerCase(), existingGroups.collect(StringFunctions.toLowerCase())));

    if (missingGroups.notEmpty()) {
        String errorMessage = "The following groups were not found in your DB2 server (checked against sysibm.SYSROLES and sysibm.SYSDBAUTH): " + missingGroups;
        if (failOnSetupException) {
            throw new IllegalArgumentException(errorMessage);
        } else {
            LOG.warn(errorMessage);
            LOG.warn("Will proceed with deployment as you have configured this to just be a warning");
            deployMetricsCollector.addMetric(DeployMetrics.WARNINGS_PREFIX + ".db2GroupsInConfigButNotInDb", errorMessage);
        }
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:47,代码来源:Db2EnvironmentInfraSetup.java


注:本文中的org.eclipse.collections.api.list.ImmutableList.notEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。