Skip to content

Commit

Permalink
Mark as deprecated PluginParameter and add a getBuilder method
Browse files Browse the repository at this point in the history
  • Loading branch information
hmiguim committed May 22, 2024
1 parent ccce0d2 commit 37133d2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package org.roda.core.data.v2.jobs;

import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -17,6 +18,7 @@
* @author Miguel Guimarães <[email protected]>
*/
public class PluginParameter implements Serializable {
@Serial
private static final long serialVersionUID = -431821437136556726L;
private String id = null;
private String name = null;
Expand All @@ -26,7 +28,7 @@ public class PluginParameter implements Serializable {
private boolean mandatory = true;
private boolean readonly = false;
private String description = null;
private RenderingHints renderingHings = null;
private RenderingHints renderingHints = null;

/**
* Constructs an empty {@link PluginParameter}.
Expand All @@ -40,6 +42,7 @@ public PluginParameter() {
*
* @param builder
* {@link PluginParameterBuilder}
*
*/
public PluginParameter(PluginParameterBuilder builder) {
this.id = builder.id;
Expand All @@ -62,9 +65,7 @@ public PluginParameter(PluginParameterBuilder builder) {
* @param mandatory
* @param readonly
* @param description
*/

/**
*
* @deprecated It will be removed in the next major version. Due to
* maintainability, a constructor shouldn't have to many arguments.
* Use instead the builder
Expand Down Expand Up @@ -93,8 +94,7 @@ public PluginParameter(String id, String name, PluginParameterType type, String
* @param mandatory
* @param readonly
* @param description
*/
/**
*
* @deprecated It will be removed in the next major version. Due to
* maintainability, a constructor shouldn't have to many arguments.
* Use instead the builder
Expand All @@ -118,12 +118,16 @@ public PluginParameter(String id, String name, PluginParameterType type, String
*
* @param parameter
* the {@link PluginParameter} to clone.
* @deprecated It will be removed in the next major version. Due to
* maintainability, a constructor shouldn't have to many arguments.
* Use instead the builder
* {@link #PluginParameter(PluginParameterBuilder)}
*/
public PluginParameter(PluginParameter parameter) {
this(new PluginParameterBuilder(parameter.getId(), parameter.getName(), parameter.getType())
.withDescription(parameter.getDescription()).withDefaultValue(parameter.getDefaultValue())
.withPossibleValues(parameter.getPossibleValues()).isReadOnly(parameter.isReadonly())
.isMandatory(parameter.isMandatory()));
.withDescription(parameter.getDescription()).withDefaultValue(parameter.getDefaultValue())
.withPossibleValues(parameter.getPossibleValues()).isReadOnly(parameter.isReadonly())
.isMandatory(parameter.isMandatory()));
}

/**
Expand Down Expand Up @@ -325,18 +329,18 @@ public void setDescription(String description) {
}

/**
* @return the renderingHings
* @return the renderingHints
*/
public RenderingHints getRenderingHings() {
return renderingHings;
public RenderingHints getRenderingHints() {
return renderingHints;
}

/**
* @param renderingHings
* the renderingHings to set
* @param renderingHints
* the renderingHints to set
*/
public void setRenderingHings(RenderingHints renderingHings) {
this.renderingHings = renderingHings;
public void setRenderingHints(RenderingHints renderingHints) {
this.renderingHints = renderingHints;
}

public enum PluginParameterType {
Expand Down Expand Up @@ -424,6 +428,11 @@ public enum PluginParameterType {
CONVERSION
}

public static PluginParameterBuilder getBuilder(final String id, final String name,
final PluginParameter.PluginParameterType type) {
return new PluginParameterBuilder(id, name, type);
}

public static class PluginParameterBuilder {

// required parameters
Expand All @@ -432,13 +441,13 @@ public static class PluginParameterBuilder {
private final PluginParameter.PluginParameterType type;

// optional parameters
private String defaultValue;
private String defaultValue = "";
private List<String> possibleValues = new ArrayList<>();
private boolean mandatory = true;
private boolean readOnly = false;
private String description = null;

public PluginParameterBuilder(String id, String name, PluginParameter.PluginParameterType type) {
private PluginParameterBuilder(String id, String name, PluginParameter.PluginParameterType type) {
this.id = id;
this.name = name;
this.type = type;
Expand Down Expand Up @@ -473,5 +482,4 @@ public PluginParameterBuilder withDescription(String description) {
return this;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public abstract class AbstractConvertPlugin<T extends IsRODAObject> extends Abst
"Do not process files that have a different format from the indicated."));

pluginParameters.put(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP,
new PluginParameter.PluginParameterBuilder(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP, "Outcome",
PluginParameter.getBuilder(RodaConstants.PLUGIN_PARAMS_REPRESENTATION_OR_DIP, "Outcome",
PluginParameterType.CONVERSION)
.withDescription(
"A conversion can create a representation or a dissemination. Please choose which option to output")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ActionLogCleanerPlugin extends AbstractPlugin<Void> {

static {
pluginParameters.put(RodaConstants.PLUGIN_PARAMS_DELETE_OLDER_THAN_X_DAYS,
new PluginParameter.PluginParameterBuilder(RodaConstants.PLUGIN_PARAMS_DELETE_OLDER_THAN_X_DAYS,
PluginParameter.getBuilder(RodaConstants.PLUGIN_PARAMS_DELETE_OLDER_THAN_X_DAYS,
"Delete older than X days", PluginParameterType.INTEGER).withDefaultValue("90").isMandatory(false)
.isReadOnly(false).withDescription("The plugin will delete all logs older than the specified number of days.")
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ private String getValuesString(List<String> values) {

private void createSelectAipLayout() {
AipIdPluginParameterRenderingHints renderingHints = null;
if (parameter.getRenderingHings() instanceof AipIdPluginParameterRenderingHints) {
renderingHints = (AipIdPluginParameterRenderingHints) parameter.getRenderingHings();
if (parameter.getRenderingHints() instanceof AipIdPluginParameterRenderingHints) {
renderingHints = (AipIdPluginParameterRenderingHints) parameter.getRenderingHints();
}
Label parameterName = new Label(parameter.getName());
final HorizontalPanel editPanel = new HorizontalPanel();
Expand Down

0 comments on commit 37133d2

Please sign in to comment.