You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2019/06/17 19:09:45 UTC
[camel] 01/05: Use a dedicated method to cast
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 5c086e3753bfcffdd36e4c63e3d361ca5b43b616
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Jun 14 10:37:24 2019 +0200
Use a dedicated method to cast
---
.../apache/camel/model/ProcessorDefinition.java | 218 ++++++++-------------
1 file changed, 80 insertions(+), 138 deletions(-)
diff --git a/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index d9e0f54..7ee70d0 100644
--- a/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/core/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -230,13 +230,12 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param value the value
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type attribute(QName name, Object value) {
if (otherAttributes == null) {
otherAttributes = new HashMap<>();
}
otherAttributes.put(name, value);
- return (Type) this;
+ return asType();
}
/**
@@ -245,10 +244,9 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param uri the endpoint to send to
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type to(@AsEndpointUri String uri) {
addOutput(new ToDefinition(uri));
- return (Type) this;
+ return asType();
}
/**
@@ -257,12 +255,11 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param uri the dynamic endpoint to send to (resolved using simple language by default)
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type toD(@AsEndpointUri String uri) {
ToDynamicDefinition answer = new ToDynamicDefinition();
answer.setUri(uri);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -273,13 +270,12 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
*
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type toD(@AsEndpointUri String uri, int cacheSize) {
ToDynamicDefinition answer = new ToDynamicDefinition();
answer.setUri(uri);
answer.setCacheSize(cacheSize);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -289,13 +285,12 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param ignoreInvalidEndpoint ignore the invalidate endpoint exception when try to create a producer with that endpoint
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type toD(@AsEndpointUri String uri, boolean ignoreInvalidEndpoint) {
ToDynamicDefinition answer = new ToDynamicDefinition();
answer.setUri(uri);
answer.setIgnoreInvalidEndpoint(ignoreInvalidEndpoint);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -305,10 +300,9 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param args arguments for the string formatting of the uri
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type toF(@AsEndpointUri String uri, Object... args) {
addOutput(new ToDefinition(String.format(uri, args)));
- return (Type) this;
+ return asType();
}
/**
@@ -328,12 +322,11 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param name the service name
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type serviceCall(String name) {
ServiceCallDefinition answer = new ServiceCallDefinition();
answer.setName(name);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -343,13 +336,12 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param uri the endpoint uri to use for calling the service
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type serviceCall(String name, @AsEndpointUri String uri) {
ServiceCallDefinition answer = new ServiceCallDefinition();
answer.setName(name);
answer.setUri(uri);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -358,16 +350,14 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param endpoint the endpoint to send to
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type to(Endpoint endpoint) {
addOutput(new ToDefinition(endpoint));
- return (Type) this;
+ return asType();
}
- @SuppressWarnings("unchecked")
public Type to(EndpointProducerBuilder endpoint) {
addOutput(new ToDefinition(endpoint));
- return (Type) this;
+ return asType();
}
/**
@@ -379,10 +369,9 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param uri the endpoint to send to
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type to(ExchangePattern pattern, @AsEndpointUri String uri) {
addOutput(new ToDefinition(uri, pattern));
- return (Type) this;
+ return asType();
}
/**
@@ -394,10 +383,9 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param endpoint the endpoint to send to
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type to(ExchangePattern pattern, Endpoint endpoint) {
addOutput(new ToDefinition(endpoint, pattern));
- return (Type) this;
+ return asType();
}
/**
@@ -406,12 +394,11 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param uris list of endpoints to send to
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type to(@AsEndpointUri String... uris) {
for (String uri : uris) {
addOutput(new ToDefinition(uri));
}
- return (Type) this;
+ return asType();
}
/**
@@ -420,12 +407,11 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param endpoints list of endpoints to send to
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type to(Endpoint... endpoints) {
for (Endpoint endpoint : endpoints) {
addOutput(new ToDefinition(endpoint));
}
- return (Type) this;
+ return asType();
}
/**
@@ -434,12 +420,11 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param endpoints list of endpoints to send to
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type to(Iterable<Endpoint> endpoints) {
for (Endpoint endpoint : endpoints) {
addOutput(new ToDefinition(endpoint));
}
- return (Type) this;
+ return asType();
}
/**
@@ -451,12 +436,11 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param uris list of endpoints to send to
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type to(ExchangePattern pattern, @AsEndpointUri String... uris) {
for (String uri : uris) {
addOutput(new ToDefinition(uri, pattern));
}
- return (Type) this;
+ return asType();
}
/**
@@ -468,12 +452,11 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param endpoints list of endpoints to send to
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type to(ExchangePattern pattern, Endpoint... endpoints) {
for (Endpoint endpoint : endpoints) {
addOutput(new ToDefinition(endpoint, pattern));
}
- return (Type) this;
+ return asType();
}
/**
@@ -483,12 +466,11 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param endpoints list of endpoints to send to
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type to(ExchangePattern pattern, Iterable<Endpoint> endpoints) {
for (Endpoint endpoint : endpoints) {
addOutput(new ToDefinition(endpoint, pattern));
}
- return (Type) this;
+ return asType();
}
/**
@@ -500,10 +482,9 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param exchangePattern instance of {@link ExchangePattern}
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type setExchangePattern(ExchangePattern exchangePattern) {
addOutput(new SetExchangePatternDefinition(exchangePattern));
- return (Type) this;
+ return asType();
}
/**
@@ -655,7 +636,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param id the id
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type id(String id) {
if (isOutputSupported() && getOutputs().isEmpty()) {
// set id on this
@@ -682,7 +662,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
}
}
- return (Type) this;
+ return asType();
}
/**
@@ -695,7 +675,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param id the route id, should be unique
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type routeId(String id) {
ProcessorDefinition<?> def = this;
@@ -707,7 +686,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
route.setId(id);
}
- return (Type) this;
+ return asType();
}
/**
@@ -716,7 +695,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param group the route group
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type routeGroup(String group) {
ProcessorDefinition<?> def = this;
@@ -725,7 +703,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
route.setGroup(group);
}
- return (Type) this;
+ return asType();
}
/**
@@ -734,7 +712,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param description the route description
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type routeDescription(String description) {
ProcessorDefinition<?> def = this;
@@ -745,7 +722,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
route.setDescription(desc);
}
- return (Type) this;
+ return asType();
}
/**
@@ -848,7 +825,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
PipelineDefinition answer = new PipelineDefinition();
addOutput(answer);
answer.to(uris);
- return (Type) this;
+ return asType();
}
/**
@@ -864,7 +841,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
PipelineDefinition answer = new PipelineDefinition();
addOutput(answer);
answer.to(endpoints);
- return (Type) this;
+ return asType();
}
/**
@@ -880,7 +857,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
PipelineDefinition answer = new PipelineDefinition();
addOutput(answer);
answer.to(endpoints);
- return (Type) this;
+ return asType();
}
/**
@@ -1251,11 +1228,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param message the log message, (you can use {@link org.apache.camel.language.simple.SimpleLanguage} syntax)
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type log(String message) {
LogDefinition answer = new LogDefinition(message);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -1265,12 +1241,11 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param message the log message, (you can use {@link org.apache.camel.language.simple.SimpleLanguage} syntax)
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type log(LoggingLevel loggingLevel, String message) {
LogDefinition answer = new LogDefinition(message);
answer.setLoggingLevel(loggingLevel);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -1281,13 +1256,12 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param message the log message, (you can use {@link org.apache.camel.language.simple.SimpleLanguage} syntax)
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type log(LoggingLevel loggingLevel, String logName, String message) {
LogDefinition answer = new LogDefinition(message);
answer.setLoggingLevel(loggingLevel);
answer.setLogName(logName);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -1298,13 +1272,12 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param message the log message, (you can use {@link org.apache.camel.language.simple.SimpleLanguage} syntax)
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type log(LoggingLevel loggingLevel, Logger logger, String message) {
LogDefinition answer = new LogDefinition(message);
answer.setLoggingLevel(loggingLevel);
answer.setLogger(logger);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -1317,14 +1290,13 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param message the log message, (you can use {@link org.apache.camel.language.simple.SimpleLanguage} syntax)
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type log(LoggingLevel loggingLevel, String logName, String marker, String message) {
LogDefinition answer = new LogDefinition(message);
answer.setLoggingLevel(loggingLevel);
answer.setLogName(logName);
answer.setMarker(marker);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -1337,14 +1309,13 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param message the log message, (you can use {@link org.apache.camel.language.simple.SimpleLanguage} syntax)
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type log(LoggingLevel loggingLevel, Logger logger, String marker, String message) {
LogDefinition answer = new LogDefinition(message);
answer.setLoggingLevel(loggingLevel);
answer.setLogger(logger);
answer.setMarker(marker);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -1906,7 +1877,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
ThrowExceptionDefinition answer = new ThrowExceptionDefinition();
answer.setException(exception);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -1921,7 +1892,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
answer.setExceptionClass(type);
answer.setMessage(message);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -1938,7 +1909,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
RollbackDefinition answer = new RollbackDefinition();
answer.setMarkRollbackOnly(true);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -1958,7 +1929,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
RollbackDefinition answer = new RollbackDefinition();
answer.setMarkRollbackOnlyLast(true);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -1987,7 +1958,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public Type rollback(String message) {
RollbackDefinition answer = new RollbackDefinition(message);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2040,7 +2011,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
return blocks.isEmpty() ? null : blocks.removeLast();
}
- @SuppressWarnings("unchecked")
public Type startupOrder(int startupOrder) {
ProcessorDefinition<?> def = this;
@@ -2049,7 +2019,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
route.startupOrder(startupOrder);
}
- return (Type) this;
+ return asType();
}
/**
@@ -2057,11 +2027,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
*
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type stop() {
StopDefinition stop = new StopDefinition();
addOutput(stop);
- return (Type) this;
+ return asType();
}
/**
@@ -2167,11 +2136,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param processor the custom {@link Processor}
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type process(Processor processor) {
ProcessDefinition answer = new ProcessDefinition(processor);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2182,12 +2150,11 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param ref reference to a {@link Processor} to lookup in the registry
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type process(String ref) {
ProcessDefinition answer = new ProcessDefinition();
answer.setRef(ref);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2212,7 +2179,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param bean the bean to invoke, or a reference to a bean if the type is a String
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type bean(Object bean) {
BeanDefinition answer = new BeanDefinition();
if (bean instanceof String) {
@@ -2221,7 +2187,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
answer.setBean(bean);
}
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2232,7 +2198,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param method the method name to invoke on the bean (can be used to avoid ambiguity)
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type bean(Object bean, String method) {
BeanDefinition answer = new BeanDefinition();
if (bean instanceof String) {
@@ -2242,7 +2207,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
}
answer.setMethod(method);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2255,7 +2220,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* the multi parameter
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type bean(Object bean, boolean cache) {
BeanDefinition answer = new BeanDefinition();
if (bean instanceof String) {
@@ -2265,7 +2229,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
}
answer.setCache(cache);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2279,7 +2243,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* the multi parameter
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type bean(Object bean, String method, boolean cache) {
BeanDefinition answer = new BeanDefinition();
if (bean instanceof String) {
@@ -2290,7 +2253,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
answer.setMethod(method);
answer.setCache(cache);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2300,12 +2263,11 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param beanType the bean class, Camel will instantiate an object at runtime
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type bean(Class<?> beanType) {
BeanDefinition answer = new BeanDefinition();
answer.setBeanType(beanType);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2316,13 +2278,12 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param method the method name to invoke on the bean (can be used to avoid ambiguity)
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type bean(Class<?> beanType, String method) {
BeanDefinition answer = new BeanDefinition();
answer.setBeanType(beanType);
answer.setMethod(method);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2336,14 +2297,13 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* the multi parameter
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type bean(Class<?> beanType, String method, boolean cache) {
BeanDefinition answer = new BeanDefinition();
answer.setBeanType(beanType);
answer.setMethod(method);
answer.setCache(cache);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2366,11 +2326,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param expression the expression used to set the body
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type setBody(Expression expression) {
SetBodyDefinition answer = new SetBodyDefinition(expression);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2388,7 +2347,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
}
});
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2406,7 +2365,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
}
});
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2416,11 +2375,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param expression the expression used to set the body
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type transform(Expression expression) {
TransformDefinition answer = new TransformDefinition(expression);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2442,11 +2400,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param expression the expression used as the script.
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type script(Expression expression) {
ScriptDefinition answer = new ScriptDefinition(expression);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2470,7 +2427,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
public Type setFaultBody(Expression expression) {
SetFaultBodyDefinition answer = new SetFaultBodyDefinition(expression);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2493,11 +2450,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param expression the expression used to set the header
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type setHeader(String name, Expression expression) {
SetHeaderDefinition answer = new SetHeaderDefinition(name, expression);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2507,7 +2463,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param supplier the supplier used to set the header
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type setHeader(String name, final Supplier<Object> supplier) {
SetHeaderDefinition answer = new SetHeaderDefinition(name, new ExpressionAdapter() {
@Override
@@ -2517,7 +2472,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
});
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2527,11 +2482,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param expression the expression used to set the property
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type setProperty(String name, Expression expression) {
SetPropertyDefinition answer = new SetPropertyDefinition(name, expression);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2553,11 +2507,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param name the header name
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type removeHeader(String name) {
RemoveHeaderDefinition answer = new RemoveHeaderDefinition(name);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2566,11 +2519,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param pattern a pattern to match header names to be removed
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type removeHeaders(String pattern) {
RemoveHeadersDefinition answer = new RemoveHeadersDefinition(pattern);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2580,11 +2532,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param excludePatterns one or more pattern of header names that should be excluded (= preserved)
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type removeHeaders(String pattern, String... excludePatterns) {
RemoveHeadersDefinition answer = new RemoveHeadersDefinition(pattern, excludePatterns);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2593,11 +2544,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param name the property name
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type removeProperty(String name) {
RemovePropertyDefinition answer = new RemovePropertyDefinition(name);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2606,11 +2556,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param pattern a pattern to match properties names to be removed
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type removeProperties(String pattern) {
RemovePropertiesDefinition answer = new RemovePropertiesDefinition(pattern);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2620,11 +2569,10 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param excludePatterns one or more pattern of properties names that should be excluded (= preserved)
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type removeProperties(String pattern, String... excludePatterns) {
RemovePropertiesDefinition answer = new RemovePropertiesDefinition(pattern, excludePatterns);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2633,10 +2581,9 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param type the type to convert to
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type convertBodyTo(Class<?> type) {
addOutput(new ConvertBodyDefinition(type));
- return (Type) this;
+ return asType();
}
/**
@@ -2646,10 +2593,9 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param charset the charset to use by type converters (not all converters support specifc charset)
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type convertBodyTo(Class<?> type, String charset) {
addOutput(new ConvertBodyDefinition(type, charset));
- return (Type) this;
+ return asType();
}
/**
@@ -2669,10 +2615,9 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param comparator the comparator to use for sorting
* @return the builder
*/
- @SuppressWarnings("unchecked")
public <T> Type sort(Expression expression, Comparator<T> comparator) {
addOutput(new SortDefinition<>(expression, comparator));
- return (Type) this;
+ return asType();
}
/**
@@ -2708,7 +2653,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
ClaimCheckDefinition answer = new ClaimCheckDefinition();
answer.setOperation(operation);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2738,7 +2683,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
answer.setKey(key);
answer.setFilter(filter);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -2839,7 +2784,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @return the builder
* @see org.apache.camel.processor.Enricher
*/
- @SuppressWarnings("unchecked")
public Type enrich(@AsEndpointUri String resourceUri, AggregationStrategy aggregationStrategy, boolean aggregateOnException, boolean shareUnitOfWork) {
EnrichDefinition answer = new EnrichDefinition();
answer.setExpression(new ConstantExpression(resourceUri));
@@ -2847,7 +2791,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
answer.setAggregateOnException(aggregateOnException);
answer.setShareUnitOfWork(shareUnitOfWork);
addOutput(answer);
- return (Type) this;
+ return asType();
}
/**
@@ -3006,7 +2950,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @return the builder
* @see org.apache.camel.processor.PollEnricher
*/
- @SuppressWarnings("unchecked")
public Type pollEnrich(@AsEndpointUri String resourceUri, long timeout, AggregationStrategy aggregationStrategy, boolean aggregateOnException) {
PollEnrichDefinition pollEnrich = new PollEnrichDefinition();
pollEnrich.setExpression(new ConstantExpression(resourceUri));
@@ -3014,7 +2957,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
pollEnrich.setAggregationStrategy(aggregationStrategy);
pollEnrich.setAggregateOnException(aggregateOnException);
addOutput(pollEnrich);
- return (Type) this;
+ return asType();
}
/**
@@ -3037,7 +2980,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @return the builder
* @see org.apache.camel.processor.PollEnricher
*/
- @SuppressWarnings("unchecked")
public Type pollEnrich(@AsEndpointUri String resourceUri, long timeout, String aggregationStrategyRef, boolean aggregateOnException) {
PollEnrichDefinition pollEnrich = new PollEnrichDefinition();
pollEnrich.setExpression(new ConstantExpression(resourceUri));
@@ -3045,7 +2987,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
pollEnrich.setAggregationStrategyRef(aggregationStrategyRef);
pollEnrich.setAggregateOnException(aggregateOnException);
addOutput(pollEnrich);
- return (Type) this;
+ return asType();
}
/**
@@ -3089,7 +3031,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @return the builder
* @see org.apache.camel.processor.PollEnricher
*/
- @SuppressWarnings("unchecked")
public Type pollEnrich(@AsEndpointUri Expression expression, long timeout, String aggregationStrategyRef, boolean aggregateOnException) {
PollEnrichDefinition pollEnrich = new PollEnrichDefinition();
pollEnrich.setExpression(new ExpressionDefinition(expression));
@@ -3097,7 +3038,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
pollEnrich.setAggregationStrategyRef(aggregationStrategyRef);
pollEnrich.setAggregateOnException(aggregateOnException);
addOutput(pollEnrich);
- return (Type) this;
+ return asType();
}
/**
@@ -3171,10 +3112,9 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param dataFormatType the dataformat
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type unmarshal(DataFormatDefinition dataFormatType) {
addOutput(new UnmarshalDefinition(dataFormatType));
- return (Type) this;
+ return asType();
}
/**
@@ -3221,10 +3161,9 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param dataFormatType the dataformat
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type marshal(DataFormatDefinition dataFormatType) {
addOutput(new MarshalDefinition(dataFormatType));
- return (Type) this;
+ return asType();
}
/**
@@ -3248,10 +3187,9 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param dataTypeRef reference to a {@link DataFormat} to lookup in the registry
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type marshal(String dataTypeRef) {
addOutput(new MarshalDefinition(new CustomDataFormat(dataTypeRef)));
- return (Type) this;
+ return asType();
}
/**
@@ -3265,7 +3203,6 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
* @param inheritErrorHandler whether to not to inherit the error handler for this node
* @return the builder
*/
- @SuppressWarnings("unchecked")
public Type inheritErrorHandler(boolean inheritErrorHandler) {
// set on last output
int size = getOutputs().size();
@@ -3279,6 +3216,11 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
output.setInheritErrorHandler(inheritErrorHandler);
}
}
+ return asType();
+ }
+
+ @SuppressWarnings("unchecked")
+ Type asType() {
return (Type) this;
}