Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ClassMappingMetadata |
|
| 1.0;1 |
1 | /** | |
2 | * Copyright 2005-2013 Dozer Project | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package org.dozer.metadata; | |
17 | ||
18 | import java.util.List; | |
19 | ||
20 | import org.dozer.classmap.MappingDirection; | |
21 | ||
22 | /** | |
23 | * This interface provides read-only access to all important aspects of the mapping metadata that specifies | |
24 | * how two classes are mapped to one another. The interface also holds methods to query the individual field | |
25 | * mappings that are part of the class mapping definition. This covers custom field mappings as well as | |
26 | * implicit field mappings automatically introduced by the dozer framework. | |
27 | * | |
28 | * @author Florian Kunz | |
29 | */ | |
30 | public interface ClassMappingMetadata { | |
31 | ||
32 | /** | |
33 | * | |
34 | * Obtains the name of the source class in the mapping definition. | |
35 | * | |
36 | * @return The name of the source class. | |
37 | */ | |
38 | String getSourceClassName(); | |
39 | ||
40 | /** | |
41 | * | |
42 | * Obtains the name of the destination class in the mapping definition. | |
43 | * | |
44 | * @return The name of the destination class. | |
45 | */ | |
46 | String getDestinationClassName(); | |
47 | ||
48 | /** | |
49 | * | |
50 | * Obtains the Class object that represents the source class in the mapping definition. | |
51 | * | |
52 | * @return The Class object of the source class. | |
53 | */ | |
54 | Class<?> getSourceClass(); | |
55 | ||
56 | /** | |
57 | * | |
58 | * Obtains the Class object that represents the destination class in the mapping definition. | |
59 | * | |
60 | * @return The Class object of the destination class. | |
61 | */ | |
62 | Class<?> getDestinationClass(); | |
63 | ||
64 | /** | |
65 | * @return true if the mapping will be stopped upon errors. | |
66 | */ | |
67 | boolean isStopOnErrors(); | |
68 | ||
69 | /** | |
70 | * @return true if strings are trimmed during mapping. | |
71 | */ | |
72 | boolean isTrimStrings(); | |
73 | ||
74 | /** | |
75 | * @return The wildcard policy. True means that fields with the same name are automatically mapped. | |
76 | */ | |
77 | boolean isWildcard(); | |
78 | ||
79 | /** | |
80 | * @return true if null values are mapped from the source class. | |
81 | */ | |
82 | boolean isSourceMapNull(); | |
83 | ||
84 | /** | |
85 | * @return true if null values are mapped from the destination class. | |
86 | */ | |
87 | boolean isDestinationMapNull(); | |
88 | ||
89 | /** | |
90 | * @return true if empty are mapped from the source class. | |
91 | */ | |
92 | boolean isSourceMapEmptyString(); | |
93 | ||
94 | /** | |
95 | * @return true if empty are mapped from the destination class. | |
96 | */ | |
97 | boolean isDestinationMapEmptyString(); | |
98 | ||
99 | /** | |
100 | * | |
101 | * Obtains the date format that is used during date conversions. | |
102 | * | |
103 | * @return The date format as a string. | |
104 | */ | |
105 | String getDateFormat(); | |
106 | ||
107 | /** | |
108 | * Used to check if a mapping is bi- or unidirectional. | |
109 | * | |
110 | * @return The {@link org.dozer.classmap.MappingDirection} object that specifies the | |
111 | * direction of the map. | |
112 | */ | |
113 | MappingDirection getMappingDirection(); | |
114 | ||
115 | /** | |
116 | * Returns the map id of this mapping definition used for contextual mapping selection. | |
117 | * | |
118 | * @return The identifier as a string. | |
119 | */ | |
120 | String getMapId(); | |
121 | ||
122 | /** | |
123 | * Gets a list of all field mapping definitions that are used for the mapping of the classes. | |
124 | * | |
125 | * @return The list of {@link FieldMappingMetadata} objects. | |
126 | * | |
127 | */ | |
128 | List<FieldMappingMetadata> getFieldMappings(); | |
129 | ||
130 | /** | |
131 | * | |
132 | * Gets a single field mapping definition by looking up the name of the source field. | |
133 | * | |
134 | * @param sourceFieldName The name of the source field. | |
135 | * | |
136 | * @return A {@link FieldMappingMetadata} object. | |
137 | * @throws MetadataLookupException | |
138 | * If no field map could be found. | |
139 | */ | |
140 | FieldMappingMetadata getFieldMappingBySource(String sourceFieldName); | |
141 | ||
142 | /** | |
143 | * | |
144 | * Gets a single field mapping definition by looking up the name of the destination field. | |
145 | * | |
146 | * @param destinationFieldName The name of the destination field. | |
147 | * | |
148 | * @return A {@link FieldMappingMetadata} object. | |
149 | * @throws MetadataLookupException If no field map could be found. | |
150 | */ | |
151 | FieldMappingMetadata getFieldMappingByDestination(String destinationFieldName); | |
152 | } |