public static String fixup(String spec) { String fixed = instance.fix(spec); if (!fixed.equals(spec)) { logger.warn(spec + "' was preprocessed to '" + fixed + "'. Please change to the new one to avoid this warning."); } return fixed; }
public String fix(String spec) { // Fixup curve ctors. These are not HOF, so local matching will work fine. However, they could occur multiple // times within an HOF, so multiple replace is necessary. Matcher matcher = oldcurve.matcher(spec); StringBuilder out = new StringBuilder(spec.length()); int start = 0; while (matcher.find()) { out.append(spec.substring(start, matcher.start())); String replacement = fixCurveCall(matcher.group("name"), matcher.group("args")); out.append(replacement); start = matcher.end(); } out.append(spec.substring(start)); return out.toString(); }
/** * Instantiate an optional data mapping function if possible. * * @param flowSpec The VirtData specifier for the mapping function * @param <T> The parameterized return type of the function * @return An optional function which will be empty if the function could not be resolved. */ public static <T> Optional<DataMapper<T>> getOptionalMapper(String flowSpec) { flowSpec = CompatibilityFixups.fixup(flowSpec); VirtDataDSL.ParseResult parseResult = VirtDataDSL.parse(flowSpec); if (parseResult.throwable != null) { throw new RuntimeException(parseResult.throwable); } VirtDataFlow flow = parseResult.flow; VirtDataComposer composer = new VirtDataComposer(); Optional<ResolvedFunction> resolvedFunction = composer.resolveFunctionFlow(flow); return resolvedFunction.map(ResolvedFunction::getFunctionObject).map(DataMapperFunctionMapper::map); }
flowSpec = CompatibilityFixups.fixup(flowSpec); VirtDataDSL.ParseResult parseResult = VirtDataDSL.parse(flowSpec); if (parseResult.throwable != null) {
public static <T> Optional<T> getOptionalFunction(String flowSpec, Class<? extends T> functionType) { flowSpec = CompatibilityFixups.fixup(flowSpec);