Class Contract
java.lang.Object
org.apache.camel.spi.Contract
Declares the expected input and/or output
DataType of an Endpoint or Processor.
When a route step declares a contract, Camel compares the message's actual DataType against the declared
input and output types and, if they differ, applies a matching Transformer to convert the payload; it can
also run a Validator when isValidateInput() or isValidateOutput() is set. This is the
mechanism behind declarative input/output typing on routes.
See Transformer in the Camel user manual.- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean@Nullable DataTypeGets the declared input data type.@Nullable DataTypeGets the declared output data type.inthashCode()booleanisEmpty()booleanWhether the input should be validated against the input data type.booleanWhether the output should be validated against the output data type.voidsetInputType(Class<?> clazz) Set the input data type with Java class.voidsetInputType(String inputType) Set the input data type.voidsetOutputType(Class<?> clazz) Set the output data type with Java class.voidsetOutputType(String outputType) Set the output data type.voidsetValidateInput(boolean validate) Whether to validate the inputvoidsetValidateOutput(boolean validate) Whether to validate the outputtoString()
-
Constructor Details
-
Contract
public Contract()
-
-
Method Details
-
getInputType
Gets the declared input data type.- Returns:
- the input type, or null if none is declared
-
setInputType
Set the input data type.- Parameters:
inputType- input data type
-
setInputType
Set the input data type with Java class.- Parameters:
clazz- Java class which represents input data type
-
getOutputType
Gets the declared output data type.- Returns:
- the output type, or null if none is declared
-
setOutputType
Set the output data type.- Parameters:
outputType- output data type
-
setOutputType
Set the output data type with Java class.- Parameters:
clazz- Java class which represents output data type
-
isValidateInput
public boolean isValidateInput()Whether the input should be validated against the input data type.- Returns:
- true if input validation is enabled
-
setValidateInput
public void setValidateInput(boolean validate) Whether to validate the input -
isValidateOutput
public boolean isValidateOutput()Whether the output should be validated against the output data type.- Returns:
- true if output validation is enabled
-
setValidateOutput
public void setValidateOutput(boolean validate) Whether to validate the output -
toString
-
isEmpty
public boolean isEmpty() -
equals
-
hashCode
-