Java Code Examples for org.eclipse.collections.api.list.MutableList#isEmpty()
The following examples show how to use
org.eclipse.collections.api.list.MutableList#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: BaselineValidatorMain.java From obevo with Apache License 2.0 | 6 votes |
private void validateNoBaselineBreaks(DbDeployerAppContext appContext, Predicate<? super CompareBreak> breakIgnorePredicate) { MutableList<CompareBreak> sortedCompareBreaks = this.calculateBaselineBreaks(appContext).toList().sortThis( Comparators.fromFunctions( CompareBreak.TO_COMPARE_SUBJECT, Functions.chain(CompareBreak.TO_CLAZZ, CLASS_TO_NAME), Functions.chain(Functions.getToClass(), CLASS_TO_NAME) )); MutableList<CompareBreak> relevantBreaks = sortedCompareBreaks.reject(breakIgnorePredicate); LOG.info("Found " + relevantBreaks.size() + " breaks"); if (!relevantBreaks.isEmpty()) { throw new IllegalArgumentException( "Found some mismatches between your change alters (LEFT) and your baseline files (RIGHT). Please review:\n" + relevantBreaks.makeString("\n")); } }
Example 2
Source File: AbstractMain.java From obevo with Apache License 2.0 | 6 votes |
private RichIterable<EnvType> getRequestedEnvironments(String sourcePath, String... envNames) { MutableCollection<EnvType> environments = getRequestedSystem(sourcePath); MutableList<EnvType> requestedEnvs = Lists.mutable.empty(); if (envNames == null || envNames.length == 0) { requestedEnvs.add(readSingleEnvironment(environments, sourcePath)); } else { for (EnvType sysEnv : environments) { for (String envPattern : envNames) { if (Pattern.compile(RegexUtil.convertWildcardPatternToRegex(envPattern)) .matcher(sysEnv.getName()) .matches()) { requestedEnvs.add(sysEnv); } } } } if (requestedEnvs.isEmpty()) { throw new IllegalArgumentException("No environment with name/s " + Lists.mutable.with(envNames).makeString("(", ",", ")") + " found"); } return requestedEnvs; }
Example 3
Source File: FastListMultimap2.java From alibaba-rsocket-broker with Apache License 2.0 | 5 votes |
public boolean removeAllSameValue(K key, V value) { MutableList<V> collection = this.map.get(key); if (collection == null) { return false; } int originSize = collection.size(); boolean changed = collection.removeIf(Predicate.isEqual(value)); if (changed) { this.totalSize = this.totalSize - (originSize - collection.size()); if (collection.isEmpty()) { this.map.remove(key); } } return changed; }
Example 4
Source File: DbDataComparisonUtil.java From obevo with Apache License 2.0 | 5 votes |
private ComparisonResult compare(String table, ComparisonCommand comparisonCommand) { DbDataSource leftDbDs = comparisonCommand.getLeftDs(); leftDbDs.init(); DbDataSource rightDbDs = comparisonCommand.getRightDs(); rightDbDs.init(); try { DbMetadataManager leftDbMetaManager = dbPlatform.getDbMetadataManager(); leftDbMetaManager.setDataSource(leftDbDs.getDs()); DbMetadataManager rightdbMetaManager = dbPlatform.getDbMetadataManager(); rightdbMetaManager.setDataSource(rightDbDs.getDs()); DaTable left = leftDbMetaManager.getTableInfo(new PhysicalSchema(leftDbDs.getSchema()), table); DaTable right = rightdbMetaManager.getTableInfo(new PhysicalSchema(rightDbDs.getSchema()), table); if (left == null) { return new ComparisonResult(comparisonCommand, null, ComparisonResultType.ONLY_ON_RIGHT_SIDE); } else if (right == null) { return new ComparisonResult(comparisonCommand, null, ComparisonResultType.ONLY_ON_LEFT_SIDE); } MutableList<String> keyCols = getKeyCols(left); if (keyCols.isEmpty()) { keyCols = getKeyCols(right); } QueryDataSource leftCatoDs = CatoBaseUtil.createQueryDataSource(leftDbDs.getName() + "-" + table, leftDbDs .getDs().getConnection(), String.format("select * from %s..%s", leftDbDs.getSchema(), table)); QueryDataSource rightCatoDs = CatoBaseUtil.createQueryDataSource(rightDbDs.getName() + "-" + table, rightDbDs .getDs().getConnection(), String.format("select * from %s..%s", rightDbDs.getSchema(), table)); CatoComparison comp = CatoBaseUtil.compare(table + "-" + leftDbDs.getName() + "-" + rightDbDs.getName(), leftCatoDs, rightCatoDs, keyCols); return new ComparisonResult(comparisonCommand, comp, isComparisonLegit(comp)); } catch (Exception exc) { return new ComparisonResult(comparisonCommand, null, ComparisonResultType.EXCEPTION); } }
Example 5
Source File: EnvironmentFactory.java From obevo with Apache License 2.0 | 5 votes |
public <E extends Environment> ImmutableCollection<E> readFromSourcePath(String sourcePath, String... envNames) { EnvironmentLocator dbEnvironmentLocator = new EnvironmentLocator(); ImmutableCollection<E> environments = dbEnvironmentLocator.readSystem(sourcePath); MutableList<E> requestedEnvs = Lists.mutable.empty(); for (E env : environments) { if (envNames == null || envNames.length == 0) { requestedEnvs.add(env); } else { for (String envPattern : envNames) { if (Pattern.compile(RegexUtil.convertWildcardPatternToRegex(envPattern)) .matcher(env.getName()) .matches()) { requestedEnvs.add(env); } } } } if (requestedEnvs.isEmpty()) { throw new IllegalArgumentException("No environment with name/s " + Lists.mutable.with(envNames).makeString("(", ",", ")") + " found"); } return requestedEnvs.toImmutable(); }
Example 6
Source File: SqlTokenParser.java From obevo with Apache License 2.0 | 4 votes |
public MutableList<SqlToken> parseTokens(String str) { str += "\n"; // to handle case where last line entry is // ending comment MutableList<SqlToken> tokens = Lists.mutable.empty(); SqlTokenParserImpl parser = new SqlTokenParserImpl(new StringReader(str)); boolean inToken = false; List<String> queuedTokens = new ArrayList<String>(); for (Token token = parser.getNextToken(); token.kind != SqlTokenParserImplConstants.EOF; token = parser.getNextToken()) { SqlTokenType tokenType; switch (token.kind) { case SqlTokenParserImplConstants.OTHER: inToken = true; queuedTokens.add(token.image); break; case SqlTokenParserImplConstants.DOUBLE_QUOTE_STRING: case SqlTokenParserImplConstants.SINGLE_QUOTE_STRING: tokenType = SqlTokenType.STRING; this.processToken(inToken, queuedTokens, tokens, tokenType, token); inToken = false; break; case SqlTokenParserImplConstants.WHITESPACE: tokenType = SqlTokenType.WHITESPACE; this.processToken(inToken, queuedTokens, tokens, tokenType, token); inToken = false; break; case SqlTokenParserImplConstants.SINGLE_LINE_COMMENT1: case SqlTokenParserImplConstants.SINGLE_LINE_COMMENT2: case SqlTokenParserImplConstants.MULTI_LINE_COMMENT: tokenType = SqlTokenType.COMMENT; this.processToken(inToken, queuedTokens, tokens, tokenType, token); inToken = false; break; default: throw new IllegalArgumentException("Not expecting this token type: " + token.kind); } } if (inToken) { String queuedTokenStr = StringUtils.join(queuedTokens, ""); queuedTokens.clear(); tokens.add(new SqlToken(SqlTokenType.TOKEN, queuedTokenStr)); } if (!tokens.isEmpty()) { int lastIndex = tokens.size() - 1; SqlToken lastToken = tokens.get(lastIndex); String lastText = lastToken.getText(); if (!lastText.isEmpty() && lastText.charAt(lastText.length() - 1) == '\n') { lastText = lastText.substring(0, lastText.length() - 1); if (lastText.isEmpty()) { tokens.remove(lastIndex); } else { tokens.set(lastIndex, new SqlToken(lastToken.getTokenType(), lastText)); } } } return tokens; }
Example 7
Source File: MultiLineStringSplitter.java From obevo with Apache License 2.0 | 4 votes |
@Override public MutableList<String> valueOf(String inputString) { inputString += "\n"; // add sentinel to facilitate line split MutableList<SqlToken> sqlTokens = this.tokenParser.parseTokens(inputString); sqlTokens = this.collapseWhiteSpaceAndTokens(sqlTokens); MutableList<String> finalSplitStrings = Lists.mutable.empty(); String currentSql = ""; for (SqlToken sqlToken : sqlTokens) { if (sqlToken.getTokenType() == SqlTokenType.COMMENT || sqlToken.getTokenType() == SqlTokenType.STRING) { currentSql += sqlToken.getText(); } else { String pattern = splitOnWholeLine ? "(?i)^" + this.splitToken + "$" : this.splitToken; MutableList<String> splitStrings = Lists.mutable.with(Pattern.compile(pattern, Pattern.MULTILINE).split(sqlToken.getText())); if (splitStrings.isEmpty()) { // means that we exactly match finalSplitStrings.add(currentSql); currentSql = ""; } else if (splitStrings.size() == 1) { currentSql += sqlToken.getText(); } else { splitStrings.set(0, currentSql + splitStrings.get(0)); if (splitOnWholeLine) { if (splitStrings.size() > 1) { splitStrings.set(0, StringUtils.chomp(splitStrings.get(0))); for (int i = 1; i < splitStrings.size(); i++) { String newSql = splitStrings.get(i); if (newSql.startsWith("\n")) { newSql = newSql.replaceFirst("^\n", ""); } else if (newSql.startsWith("\r\n")) { newSql = newSql.replaceFirst("^\r\n", ""); } // Chomping the end of each sql due to the split of the GO statement if (i < splitStrings.size() - 1) { newSql = StringUtils.chomp(newSql); } splitStrings.set(i, newSql); } } } finalSplitStrings.addAll(splitStrings.subList(0, splitStrings.size() - 1)); currentSql = splitStrings.getLast(); } } } if (!currentSql.isEmpty()) { finalSplitStrings.add(currentSql); } // accounting for the sentinel if (finalSplitStrings.getLast().isEmpty()) { finalSplitStrings.remove(finalSplitStrings.size() - 1); } else { finalSplitStrings.set(finalSplitStrings.size() - 1, StringUtils.chomp(finalSplitStrings.getLast())); } return finalSplitStrings; }