Java Code Examples for org.eclipse.collections.api.block.function.Function#valueOf()
The following examples show how to use
org.eclipse.collections.api.block.function.Function#valueOf() .
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: SameSchemaDbChecksumDao.java From obevo with Apache License 2.0 | 6 votes |
public SameSchemaDbChecksumDao(SqlExecutor sqlExecutor, DbMetadataManager dbMetadataManager, DbPlatform platform, ImmutableSet<PhysicalSchema> physicalSchemas, String tableSqlSuffix, ChangeTypeBehaviorRegistry changeTypeBehaviorRegistry) { this.sqlExecutor = sqlExecutor; this.jdbc = sqlExecutor.getJdbcTemplate(); this.dbMetadataManager = dbMetadataManager; this.platform = platform; this.physicalSchemas = physicalSchemas; this.tableSqlSuffix = tableSqlSuffix; this.changeTypeBehaviorRegistry = changeTypeBehaviorRegistry; Function<String, String> convertDbObjectName = platform.convertDbObjectName(); this.checksumTableName = convertDbObjectName.valueOf(SCHEMA_CHECKSUM_TABLE_NAME); this.objectTypeColumnName = convertDbObjectName.valueOf("OBJECTTYPE"); this.objectName1ColumnName = convertDbObjectName.valueOf("OBJECTNAME1"); this.objectName2ColumnName = convertDbObjectName.valueOf("OBJECTNAME2"); this.checksumColumnName = convertDbObjectName.valueOf("CHECKSUM"); this.timeUpdatedColumnName = convertDbObjectName.valueOf("TIME_UPDATED"); }
Example 2
Source File: ArgsParser.java From obevo with Apache License 2.0 | 6 votes |
public <T> T parse(String[] args, T inputArgs, Function<? super T, String> validationFunction) { try { List<String> extraArgs = Args.parse(inputArgs, args); if (extraArgs.size() > 0) { printUsageAndExit(inputArgs, "Passed in unnecessary args: " + StringUtils.join(extraArgs, "; ")); } String validationMessage = validationFunction.valueOf(inputArgs); if (validationMessage != null) { printUsageAndExit(inputArgs, validationMessage); } } catch (IllegalArgumentException exc) { printUsageAndExit(inputArgs, ExceptionUtils.getStackTrace(exc)); } LOG.info("Arguments parsed: " + inputArgs.toString()); return inputArgs; }
Example 3
Source File: SameSchemaDeployExecutionDao.java From obevo with Apache License 2.0 | 5 votes |
public SameSchemaDeployExecutionDao(SqlExecutor sqlExecutor, DbMetadataManager dbMetadataManager, DbPlatform platform, ImmutableSet<PhysicalSchema> physicalSchemas, String tableSqlSuffix, DbEnvironment env, ChangeTypeBehaviorRegistry changeTypeBehaviorRegistry) { this.sqlExecutor = sqlExecutor; this.jdbc = sqlExecutor.getJdbcTemplate(); this.dbMetadataManager = dbMetadataManager; this.platform = platform; this.physicalSchemas = physicalSchemas; this.nextIdBySchema = physicalSchemas.toMap(Functions.<PhysicalSchema>getPassThru(), new Function<PhysicalSchema, MutableInt>() { @Override public MutableInt valueOf(PhysicalSchema object) { return new MutableInt(1); } }).toImmutable(); this.tableSqlSuffix = tableSqlSuffix; this.env = env; this.changeTypeBehaviorRegistry = changeTypeBehaviorRegistry; Function<String, String> convertDbObjectName = platform.convertDbObjectName(); this.deployExecutionTableName = convertDbObjectName.valueOf(DEPLOY_EXECUTION_TABLE_NAME); this.deployExecutionAttributeTableName = convertDbObjectName.valueOf(DEPLOY_EXECUTION_ATTRIBUTE_TABLE_NAME); this.idColName = convertDbObjectName.valueOf("ID"); this.statusColName = convertDbObjectName.valueOf("STATUS"); this.deployTimeColName = convertDbObjectName.valueOf("DEPLOYTIME"); this.executorIdColName = convertDbObjectName.valueOf("EXECUTORID"); this.toolVersionColName = convertDbObjectName.valueOf("TOOLVERSION"); this.initCommandColName = convertDbObjectName.valueOf("INIT_COMMAND"); this.rollbackCommandColName = convertDbObjectName.valueOf("ROLLBACK_COMMAND"); this.requesterIdColName = convertDbObjectName.valueOf("REQUESTERID"); this.reasonColName = convertDbObjectName.valueOf("REASON"); this.productVersionColName = convertDbObjectName.valueOf("PRODUCTVERSION"); this.dbSchemaColName = convertDbObjectName.valueOf("DBSCHEMA"); this.allMainColumns = Lists.immutable.with(idColName, statusColName, deployTimeColName, executorIdColName, toolVersionColName, initCommandColName, rollbackCommandColName, requesterIdColName, reasonColName, dbSchemaColName, productVersionColName); this.deployExecutionIdColName = convertDbObjectName.valueOf("DEPLOYEXECUTIONID"); this.attrNameColName = convertDbObjectName.valueOf("ATTRNAME"); this.attrValueColName = convertDbObjectName.valueOf("ATTRVALUE"); this.allAttrColumns = Lists.immutable.with(deployExecutionIdColName, attrNameColName, attrValueColName); }
Example 4
Source File: CatoTypeConverters.java From obevo with Apache License 2.0 | 5 votes |
public static CatoTypeConverter newCustomTypeConverter(final Function<Object, Object> customConvertor) { return new CatoTypeConverter() { @Override public Object convert(Object data) { return customConvertor.valueOf(data); } }; }
Example 5
Source File: DeepCompareUtil.java From obevo with Apache License 2.0 | 4 votes |
private void compareObjectsInternal(Object key, Object left, Object right, MutableCollection<CompareBreak> breaks) { Class objectClass = left.getClass(); MutableCollection<ClassCompareInfo> classCompareInfos = this.getClassCompareInfos(objectClass); if (classCompareInfos.isEmpty()) { if (!ObjectUtils.equals(left, right)) { breaks.add(new FieldCompareBreak(objectClass, key, left, right, "this", left, right)); } } else { for (ClassCompareInfo<Object> classCompareInfo : classCompareInfos) { for (Pair<String, Function<Object, ?>> functionPair : classCompareInfo.getCompareFunctions()) { Function<Object, ?> function = functionPair.getTwo(); Object leftFuncVal = function.valueOf(left); Object rightFuncVal = function.valueOf(right); if (leftFuncVal == null && rightFuncVal == null) { continue; // no break - continue } else if (leftFuncVal == null ^ rightFuncVal == null) { // XOR - if one of these is null, but not // the other breaks.add(new FieldCompareBreak(objectClass, key, left, right, functionPair.getOne(), leftFuncVal, rightFuncVal)); } else { MutableCollection<ClassCompareInfo> funcClassCompareInfos = this.getClassCompareInfos(leftFuncVal .getClass()); if (funcClassCompareInfos.isEmpty()) { if (!ObjectUtils.equals(leftFuncVal, rightFuncVal)) { breaks.add(new FieldCompareBreak(objectClass, key, left, right, functionPair.getOne(), leftFuncVal, rightFuncVal)); } } else { this.compareObjectsInternal(key, leftFuncVal, rightFuncVal, breaks); } } } for (CollectionFieldCompareInfo collectionCompareInfo : classCompareInfo.getCollectionComparisonInfos()) { this.compareCollectionsInternal(collectionCompareInfo.getElementClass() , (Collection) collectionCompareInfo.getCollectionFieldFunction().valueOf(left) , (Collection) collectionCompareInfo.getCollectionFieldFunction().valueOf(right) , breaks); } } } }
Example 6
Source File: SchemaGenerator.java From obevo with Apache License 2.0 | 4 votes |
MyInput(String name, String type, Multimap<String, String> dependenciesByType, Function<String, String> convertNameFunction) { this.name = convertNameFunction.valueOf(name); this.type = type; this.dependenciesByType = dependenciesByType.collectValues(StringFunctions.toUpperCase()); }
Example 7
Source File: AbstractReveng.java From obevo with Apache License 2.0 | 4 votes |
private MutableList<ChangeEntry> revengFile(SchemaObjectReplacer schemaObjectReplacer, List<Pair<String, RevengPatternOutput>> snippetPatternMatchPairs, String inputSchema, boolean debugLogEnabled) { final MutableList<ChangeEntry> changeEntries = Lists.mutable.empty(); MutableMap<String, AtomicInteger> countByObject = Maps.mutable.empty(); int selfOrder = 0; String candidateObject = "UNKNOWN"; ChangeType candidateObjectType = UnclassifiedChangeType.INSTANCE; for (Pair<String, RevengPatternOutput> snippetPatternMatchPair : snippetPatternMatchPairs) { String sqlSnippet = snippetPatternMatchPair.getOne(); try { sqlSnippet = removeQuotesFromProcxmode(sqlSnippet); // sybase ASE MutableMap<String, Object> debugComments = Maps.mutable.empty(); RevengPattern chosenRevengPattern = null; String secondaryName = null; final RevengPatternOutput patternMatch = snippetPatternMatchPair.getTwo(); debugComments.put("newPatternMatch", patternMatch != null); if (patternMatch != null) { chosenRevengPattern = patternMatch.getRevengPattern(); if (chosenRevengPattern.isShouldBeIgnored()) { continue; } debugComments.put("objectType", patternMatch.getRevengPattern().getChangeType()); // we add this here to allow post-processing to occur on RevengPatterns but still not define the object to write to if (patternMatch.getRevengPattern().getChangeType() != null) { candidateObject = patternMatch.getPrimaryName(); debugComments.put("originalObjectName", candidateObject); candidateObject = chosenRevengPattern.remapObjectName(candidateObject); debugComments.put("secondaryName", patternMatch.getSecondaryName()); if (patternMatch.getSecondaryName() != null) { secondaryName = patternMatch.getSecondaryName(); } if (patternMatch.getRevengPattern().getChangeType().equalsIgnoreCase(UnclassifiedChangeType.INSTANCE.getName())) { candidateObjectType = UnclassifiedChangeType.INSTANCE; } else { candidateObjectType = platform.getChangeType(patternMatch.getRevengPattern().getChangeType()); } } } // Ignore other schemas that may have been found in your parsing (came up during HSQLDB use case) sqlSnippet = schemaObjectReplacer.replaceSnippet(sqlSnippet); AtomicInteger objectOrder2 = countByObject.getIfAbsentPut(candidateObject, new Function0<AtomicInteger>() { @Override public AtomicInteger value() { return new AtomicInteger(0); } }); if (secondaryName == null) { secondaryName = "change" + objectOrder2.getAndIncrement(); } RevEngDestination destination = new RevEngDestination(inputSchema, candidateObjectType, candidateObject, false, Optional.ofNullable(chosenRevengPattern).map(RevengPattern::isKeepLastOnly).orElse(false)); String annotation = chosenRevengPattern != null ? chosenRevengPattern.getAnnotation() : null; MutableList<Function<String, LineParseOutput>> postProcessSqls = chosenRevengPattern != null ? chosenRevengPattern.getPostProcessSqls() : Lists.mutable.<Function<String, LineParseOutput>>empty(); for (Function<String, LineParseOutput> postProcessSql : postProcessSqls) { LineParseOutput lineParseOutput = postProcessSql.valueOf(sqlSnippet); sqlSnippet = lineParseOutput.getLineOutput(); } Integer suggestedOrder = patternMatch != null ? patternMatch.getRevengPattern().getSuggestedOrder() : null; if (debugLogEnabled && debugComments.notEmpty()) { String debugCommentsStr = debugComments.keyValuesView().collect(new Function<Pair<String, Object>, String>() { @Override public String valueOf(Pair<String, Object> object) { return object.getOne() + "=" + object.getTwo(); } }).makeString("; "); sqlSnippet = "-- DEBUG COMMENT: " + debugCommentsStr + "\n" + sqlSnippet; } ChangeEntry change = new ChangeEntry(destination, sqlSnippet + "\nGO", secondaryName, annotation, ObjectUtils.firstNonNull(suggestedOrder, selfOrder++)); postProcessChange.value(change, sqlSnippet); changeEntries.add(change); } catch (RuntimeException e) { throw new RuntimeException("Failed parsing on statement " + sqlSnippet, e); } } return changeEntries; }