-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
InputTypeDefinition.java
105 lines (92 loc) · 3.28 KB
/
InputTypeDefinition.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.camel.spi.Metadata;
/**
* Set the expected data type of the input message. If the actual message type is different at runtime,
* camel look for a required {@link Transformer} and apply if exists. If validate attribute is true
* then camel applies {@link Validator} as well.
* Type name consists of two parts, 'scheme' and 'name' connected with ':'. For Java type 'name'
* is a fully qualified class name. For example {@code java:java.lang.String}, {@code json:ABCOrder}.
* It's also possible to specify only scheme part, so that it works like a wildcard. If only 'xml'
* is specified, all the XML message matches. It's handy to add only one transformer/validator
* for all the transformation from/to XML.
*
* @see {@link OutputTypeDefinition} {@link Transformer} {@link Validator}
*/
@Metadata(label = "configuration")
@XmlRootElement(name = "inputType")
@XmlAccessorType(XmlAccessType.FIELD)
public class InputTypeDefinition extends OptionalIdentifiedDefinition<InputTypeDefinition> {
@XmlAttribute @Metadata(required = true)
private String urn;
@XmlAttribute @Metadata(defaultValue = "false")
private Boolean validate = false;
public InputTypeDefinition() {
}
/**
* Get input type URN.
* @return input type URN
*/
public String getUrn() {
return urn;
}
/**
* Set input type URN.
* @param urn input type URN
*/
public void setUrn(String urn) {
this.urn = urn;
}
/**
* Set input type via Java Class.
* @param clazz Java Class
*/
public void setJavaClass(Class<?> clazz) {
this.urn = "java:" + clazz.getName();
}
/**
* Get if validation is required for this input type.
* @return true if validate
*/
public boolean isValidate() {
return this.validate;
}
/**
* Set if validation is required for this input type.
* @param validate true if validate
*/
public void setValidate(boolean validate) {
this.validate = validate;
}
@Override
public String toString() {
return "inputType[" + urn + "]";
}
@Override
public String getShortName() {
return "inputType";
}
@Override
public String getLabel() {
return "inputType[" + urn + "]";
}
}