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

The following examples show how to use org.eclipse.collections.api.list.ImmutableList#isEmpty() . 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: AbstractEnvironmentEnricher.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableCollection<E> readSystem(final HierarchicalConfiguration sysCfg, final FileObject sourcePath) {
    final Platform systemDbPlatform = dbPlatformConfiguration.valueOf(sysCfg.getString("type"));

    // Check for dbEnvironments first for backwards-compatibility
    ImmutableList<HierarchicalConfiguration> envConfigs = iterConfigMutable(sysCfg, "environments.dbEnvironment");
    if (envConfigs.isEmpty()) {
        envConfigs = iterConfigMutable(sysCfg, "environments.environment");
    }

    ImmutableList<E> envList = envConfigs.collect(new Function<HierarchicalConfiguration, E>() {
        @Override
        public E valueOf(HierarchicalConfiguration envCfg) {
            E dbEnv = AbstractEnvironmentEnricher.this.createNewEnv();

            // combining the sys and env configurations before passing to downstream methods so that we can support only having env configs passed in
            CombinedConfiguration combinedConfiguration = new CombinedConfiguration(new OverrideCombiner());
            combinedConfiguration.addConfiguration(envCfg);
            combinedConfiguration.addConfiguration(sysCfg);
            combinedConfiguration.setExpressionEngine(sysCfg.getExpressionEngine());

            AbstractEnvironmentEnricher.this.enrich(dbEnv, combinedConfiguration, sourcePath, systemDbPlatform);
            AbstractEnvironmentEnricher.this.createEnv(dbEnv, combinedConfiguration, systemDbPlatform);
            return dbEnv;
        }
    });

    CollectionUtil.verifyNoDuplicates(envList, new Function<E, Object>() {
        @Override
        public Object valueOf(E e) {
            return e.getName();
        }
    }, "Invalid configuration from " + sourcePath + "; not expecting duplicate env names");
    return envList;
}
 
Example 2
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 3
Source File: DefaultRollbackDetector.java    From obevo with Apache License 2.0 5 votes vote down vote up
@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();
}