My Transformer
Updated: Aug 24, 2023
This example shows a customizable Transformer class that enables you to modify the default data transformation logic. By utilizing this functionality, you can implement your own specialized data transformation rules tailored to specific data processing requirements and business logic.
More information on the usage of MyTransformer can be found in Write My Own Transformer.
Java Code Listing
package com.northconcepts.datapipeline.examples.cookbook.customization; import com.northconcepts.datapipeline.core.Field; import com.northconcepts.datapipeline.core.Record; import com.northconcepts.datapipeline.transform.Transformer; public class MyTransformer extends Transformer { public MyTransformer() { } public boolean transform(Record record) throws Throwable { Field creditLimit = record.getField("CreditLimit"); // increase everyone's limit by 10% double newValue = Double.parseDouble(creditLimit.getValueAsString()) * 1.10; creditLimit.setValue(newValue); return true; } }
Code Walkthrough
MyTransformer extends Transformer abstract class and can be customized to apply transformation logic based on our needs. The single abstract method transform(Record record)
must be overridden and should contain that logic implementation. In the given code, for example, the CreditLimit value is increased by 10%.