-
Notifications
You must be signed in to change notification settings - Fork 2
Added custom message property #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,21 @@ | |
import io.cdap.cdap.api.plugin.PluginConfig; | ||
import io.cdap.cdap.etl.api.FailureCollector; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public class HelloWorldBatchSourceConfig extends PluginConfig { | ||
|
||
@Name(PluginConstants.PROPERTY_NAME_FREQUENCY) | ||
@Description("Number of times the plugin says hello world.") | ||
public Integer frequency; | ||
|
||
|
||
@Name(PluginConstants.PROPERTY_NAME_USER_MESSAGE) | ||
@Description("Custom message") | ||
@Nullable | ||
public String message; | ||
Comment on lines
+18
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's keep these consistent, userMessage is more appropriate. |
||
|
||
|
||
public void validate(FailureCollector failureCollector) { | ||
if (frequency != null && frequency < 1) { | ||
failureCollector.addFailure("Property cannot be lower than 1.", "Use a frequency value of equal to or more than 1.").withConfigProperty(PluginConstants.PROPERTY_NAME_FREQUENCY); | ||
|
@@ -21,5 +30,6 @@ public void validate(FailureCollector failureCollector) { | |
public int getFrequency() { | ||
return frequency == null ? PluginConstants.PROPERTY_DEFAULT_FREQUENCY : frequency; | ||
} | ||
public String getMessage(){ return (message == null || message.isEmpty()) ? PluginConstants.PROPERTY_CONFIG_DEFAULT_MESSAGE: message; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fix formatting ! |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,10 @@ public class HelloWorldInputFormatProvider implements InputFormatProvider { | |
|
||
public HelloWorldInputFormatProvider(HelloWorldBatchSourceConfig config) { | ||
configMap = new HashMap<>(); | ||
|
||
configMap.put(PluginConstants.PROPERTY_CONFIG_KEY_FREQUENCY, Integer.toString(config.getFrequency())); | ||
configMap.put(PluginConstants.PROPERTY_CONFIG_KEY_MESSAGE, config.getMessage()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PROPERTY_CONFIG_KEY_USER_MESSAGE There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done sir |
||
|
||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep the default message same as before for backwards compatibility!