Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
refactor: Removing unused constructors now that we use Jackson
Browse files Browse the repository at this point in the history
everywhere
  • Loading branch information
Delawen committed Aug 16, 2023
1 parent b52a5ea commit 1a1e1c5
Show file tree
Hide file tree
Showing 18 changed files with 169 additions and 289 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.kaoto.backend.camel.model.deployment.kamelet.step;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.kaoto.backend.camel.KamelHelper;
import io.kaoto.backend.model.parameter.Parameter;
import io.kaoto.backend.model.step.Step;

Expand All @@ -14,36 +15,27 @@ public class BeanStep extends EIPStep {
public static final String BEAN_TYPE_LABEL = "beanType";
public static final String BEAN_TYPE_LABEL2 = "bean-type";
public static final String SCOPE_LABEL = "scope";
public static final String DESCRIPTION_LABEL = "description";
public static final String ID_LABEL = "id";

@JsonProperty(REF_LABEL)
private String ref;

@JsonProperty(METHOD_LABEL)
private String method;

@JsonProperty(BEAN_TYPE_LABEL)
@JsonAlias(BEAN_TYPE_LABEL2)
private String beanType;

@JsonProperty(SCOPE_LABEL)
private String scope;

@JsonProperty(KamelHelper.DESCRIPTION)
private String description;

public BeanStep() {
}

@JsonCreator
public BeanStep(final @JsonProperty(REF_LABEL) String ref,
final @JsonProperty(METHOD_LABEL) String method,
final @JsonProperty(BEAN_TYPE_LABEL) String beanType,
final @JsonProperty(BEAN_TYPE_LABEL2) String beanType2,
final @JsonProperty(SCOPE_LABEL) String scope,
final @JsonProperty(DESCRIPTION_LABEL) String description,
final @JsonProperty(ID_LABEL) String id) {
setRef(ref);
setMethod(method);
setDescription(description);
setBeanType(beanType != null ? beanType : beanType2);
setScope(scope);
setId(id);
}

public BeanStep(Step step) {
super(step);
}
Expand All @@ -59,8 +51,8 @@ public BeanStep(Map<String, Object> map) {
if (map.containsKey(SCOPE_LABEL)) {
this.setScope(String.valueOf(map.get(SCOPE_LABEL)));
}
if (map.containsKey(DESCRIPTION_LABEL)) {
this.setDescription(String.valueOf(map.get(DESCRIPTION_LABEL)));
if (map.containsKey(KamelHelper.DESCRIPTION)) {
this.setDescription(String.valueOf(map.get(KamelHelper.DESCRIPTION)));
}
if (map.containsKey(ID_LABEL)) {
this.setId(String.valueOf(map.get(ID_LABEL)));
Expand Down Expand Up @@ -89,7 +81,7 @@ public Map<String, Object> getRepresenterProperties() {
properties.put(BEAN_TYPE_LABEL, this.getBeanType());
}
if (this.getDescription() != null) {
properties.put(DESCRIPTION_LABEL, this.getDescription());
properties.put(KamelHelper.DESCRIPTION, this.getDescription());
}
return properties;
}
Expand All @@ -111,7 +103,7 @@ protected void assignAttribute(final Parameter parameter) {
case BEAN_TYPE_LABEL2:
this.setBeanType(parameter.getValue().toString());
break;
case DESCRIPTION_LABEL:
case KamelHelper.DESCRIPTION:
this.setDescription(parameter.getValue().toString());
break;
case ID_LABEL:
Expand Down Expand Up @@ -140,7 +132,7 @@ protected void assignProperty(final Parameter parameter) {
case ID_LABEL:
parameter.setValue(this.getId());
break;
case DESCRIPTION_LABEL:
case KamelHelper.DESCRIPTION:
parameter.setValue(this.getDescription());
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;

import io.kaoto.backend.api.metadata.catalog.StepCatalog;
Expand All @@ -20,6 +20,7 @@ public class CircuitBreaker extends EIPStep {

public static final String STEPS_LABEL = KamelHelper.STEPS;
public static final String ON_FALLBACK_LABEL = "on-fallback";
public static final String ON_FALLBACK_LABEL2 = "onFallback";
public static final String RESILIENCE_4_J_CONFIGURATION_LABEL = "resilience-4j-configuration";
public static final String FAULT_TOLERANCE_CONFIGURATION_LABEL = "fault-tolerance-configuration";
public static final String CONFIGURATION_LABEL = "configuration";
Expand All @@ -31,12 +32,15 @@ public class CircuitBreaker extends EIPStep {
private List<FlowStep> steps;

@JsonProperty(ON_FALLBACK_LABEL)
@JsonAlias(ON_FALLBACK_LABEL2)
private GenericFlowWithSteps onFallback;

@JsonProperty(RESILIENCE_4_J_CONFIGURATION_LABEL)
@JsonAlias(RESILIENCE_4_J_CONFIGURATION_LABEL2)
private Map<String, String> resilience4jConfiguration;

@JsonProperty(FAULT_TOLERANCE_CONFIGURATION_LABEL)
@JsonAlias(FAULT_TOLERANCE_CONFIGURATION_LABEL2)
private Map<String, String> faultToleranceConfiguration;

@JsonProperty(CONFIGURATION_LABEL)
Expand All @@ -49,24 +53,6 @@ public CircuitBreaker() {
super();
}

@JsonCreator
public CircuitBreaker(
final @JsonProperty(STEPS_LABEL) List<FlowStep> steps,
final @JsonProperty(ON_FALLBACK_LABEL) GenericFlowWithSteps onFallback,
final @JsonProperty(RESILIENCE_4_J_CONFIGURATION_LABEL) Map<String, String> resilience4jConfiguration,
final @JsonProperty(FAULT_TOLERANCE_CONFIGURATION_LABEL) Map<String, String> faultToleranceConfiguration,
final @JsonProperty(CONFIGURATION_LABEL) String configuration,
final @JsonProperty(DESCRIPTION_LABEL) Map<String, String> description,
final @JsonProperty("id") String id) {
super();
setSteps(steps);
setOnFallback(onFallback);
setResilience4jConfiguration(resilience4jConfiguration);
setFaultToleranceConfiguration(faultToleranceConfiguration);
setConfiguration(configuration);
setDescription(description);
setId(id);
}

public CircuitBreaker(final Step step, final KamelPopulator kameletPopulator) {
super(step);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.kaoto.backend.camel.model.deployment.kamelet.step;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.kaoto.backend.camel.KamelHelper;
import io.kaoto.backend.model.parameter.Parameter;
import io.kaoto.backend.model.step.Step;

Expand All @@ -9,7 +11,7 @@

public class ClaimCheck extends EIPStep {

public static final String DESCRIPTION_LABEL = "description";
public static final String DESCRIPTION_LABEL = KamelHelper.DESCRIPTION;
public static final String OPERATION_LABEL = "operation";
public static final String KEY_LABEL = "key";
public static final String FILTER_LABEL = "filter";
Expand All @@ -28,9 +30,11 @@ public class ClaimCheck extends EIPStep {
private String filter;

@JsonProperty(AGGREGATION_STRATEGY_LABEL)
@JsonAlias(AGGREGATION_STRATEGY_LABEL2)
private String aggregationStrategy;

@JsonProperty(AGGREGATION_STRATEGY_METHOD_NAME_LABEL)
@JsonAlias(AGGREGATION_STRATEGY_METHOD_NAME_LABEL2)
private String aggregationStrategyMethodName;

@JsonProperty(DESCRIPTION_LABEL)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.kaoto.backend.camel.model.deployment.kamelet.step;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.kaoto.backend.camel.KamelHelper;
import io.kaoto.backend.model.parameter.Parameter;
import io.kaoto.backend.model.step.Step;

Expand All @@ -12,7 +13,7 @@ public class ConvertBodyTo extends EIPStep {
public static final String TYPE_LABEL = "type";
public static final String MANDATORY_LABEL = "mandatory";
public static final String CHARSET_LABEL = "charset";
public static final String DESCRIPTION_LABEL = "description";
public static final String DESCRIPTION_LABEL = KamelHelper.DESCRIPTION;

@JsonProperty(TYPE_LABEL)
private String type;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.kaoto.backend.camel.model.deployment.kamelet.step;

import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.kaoto.backend.camel.KamelHelper;
import io.kaoto.backend.camel.model.deployment.kamelet.expression.Expression;
import io.kaoto.backend.model.parameter.Parameter;
import io.kaoto.backend.model.step.Step;
Expand All @@ -16,18 +18,21 @@ public class Delay extends EIPStep {
public static final String CALLER_RUNS_WHEN_REJECTED_LABEL2 = "caller-runs-when-rejected";
public static final String EXECUTOR_SERVICE_LABEL = "executorService";
public static final String EXECUTOR_SERVICE_LABEL2 = "executor-service";
public static final String DESCRIPTION_LABEL = "description";
public static final String DESCRIPTION_LABEL = KamelHelper.DESCRIPTION;

@JsonProperty(EXPRESSION_LABEL)
private Expression expression;

@JsonProperty(ASYNC_DELAYED_LABEL2)
@JsonAlias(ASYNC_DELAYED_LABEL2)
private Boolean asyncDelayed;

@JsonProperty(CALLER_RUNS_WHEN_REJECTED_LABEL2)
@JsonAlias(CALLER_RUNS_WHEN_REJECTED_LABEL)
private Boolean callerRunsWhenRejected;

@JsonProperty(EXECUTOR_SERVICE_LABEL2)
@JsonAlias(EXECUTOR_SERVICE_LABEL)
private Map<String, String> executorService;

@JsonProperty(DESCRIPTION_LABEL)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.kaoto.backend.camel.model.deployment.kamelet.step;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonDeserializer;
Expand All @@ -20,10 +19,8 @@ public class EnrichFlowStep implements FlowStep {

public static final String LABEL = "enrich";

@JsonCreator
public EnrichFlowStep(final @JsonProperty(LABEL) Enrich enrich) {
setEnrich(enrich);
}
@JsonProperty(LABEL)
private Enrich enrich;

public EnrichFlowStep() {
//Needed for serialization
Expand All @@ -33,8 +30,6 @@ public EnrichFlowStep(Step step) {
setEnrich(new Enrich(step));
}

private Enrich enrich;

@Override
public Map<String, Object> getRepresenterProperties() {
Map<String, Object> properties = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.kaoto.backend.camel.model.deployment.kamelet.step;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.kaoto.backend.camel.KamelHelper;
import io.kaoto.backend.model.parameter.Parameter;
import io.kaoto.backend.model.step.Step;

Expand All @@ -12,43 +13,34 @@ public class LogStep extends EIPStep {
public static final String MESSAGE = "message";
public static final String MARKER = "marker";
public static final String LOGGER = "logger";
public static final String DESCRIPTION = "description";
public static final String LOGGING_LEVEL = "logging-level";
public static final String LOG_NAME = "log-name";
public static final String LOGGING_LEVEL1 = "loggingLevel";
public static final String LOG_NAME1 = "logName";

@JsonProperty(MESSAGE)
private String message;

@JsonProperty(LOGGING_LEVEL)
@JsonAlias(LOGGING_LEVEL1)
private String loggingLevel;

@JsonProperty(LOG_NAME)
@JsonAlias(LOG_NAME1)
private String logName;

@JsonProperty(MARKER)
private String marker;

@JsonProperty(LOGGER)
private String logger;

@JsonProperty(KamelHelper.DESCRIPTION)
private String description;

public LogStep() {
}

@JsonCreator
public LogStep(final @JsonProperty(MESSAGE) String message,
final @JsonProperty(MARKER) String marker,
final @JsonProperty(LOGGER) String logger,
final @JsonProperty(DESCRIPTION) String description,
final @JsonProperty(LOGGING_LEVEL) String loggingLevel,
final @JsonProperty(LOG_NAME) String logName,
final @JsonProperty(LOGGING_LEVEL1) String loggingLevel2,
final @JsonProperty(LOG_NAME1) String logName2,
final @JsonProperty("id") String id) {
setMessage(message);
setMarker(marker);
setLogger(logger);
setDescription(description);
setLoggingLevel(loggingLevel != null ? loggingLevel : loggingLevel2);
setLogName(logName != null ? logName : logName2);
setId(id);
}

public LogStep(Step step) {
super(step);
}
Expand All @@ -64,8 +56,8 @@ public LogStep(Map<String, Object> map) {
if (map.containsKey(LOGGER)) {
this.setLogger(String.valueOf(map.get(LOGGER)));
}
if (map.containsKey(DESCRIPTION)) {
this.setDescription(String.valueOf(map.get(DESCRIPTION)));
if (map.containsKey(KamelHelper.DESCRIPTION)) {
this.setDescription(String.valueOf(map.get(KamelHelper.DESCRIPTION)));
}
if (map.containsKey(LOGGING_LEVEL)) {
this.setLoggingLevel(String.valueOf(map.get(LOGGING_LEVEL)));
Expand Down Expand Up @@ -98,7 +90,7 @@ public Map<String, Object> getRepresenterProperties() {
properties.put(LOGGER, this.getLogger());
}
if (this.description != null) {
properties.put(DESCRIPTION, this.getDescription());
properties.put(KamelHelper.DESCRIPTION, this.getDescription());
}
return properties;
}
Expand All @@ -124,7 +116,7 @@ protected void assignAttribute(final Parameter parameter) {
case LOGGER:
this.setLogger(parameter.getValue().toString());
break;
case DESCRIPTION:
case KamelHelper.DESCRIPTION:
this.setDescription(parameter.getValue().toString());
break;
default:
Expand Down Expand Up @@ -153,7 +145,7 @@ protected void assignProperty(final Parameter parameter) {
case LOGGER:
parameter.setValue(this.getLogger());
break;
case DESCRIPTION:
case KamelHelper.DESCRIPTION:
parameter.setValue(this.getDescription());
break;
default:
Expand Down
Loading

0 comments on commit 1a1e1c5

Please sign in to comment.