@@ -236,9 +236,8 @@ public boolean apply(ClassMap classMap, Configuration configuration) {
236236 Mapping mapping = readMethod .getAnnotation (Mapping .class );
237237 String propertyName = property .getName ();
238238 if (mapping != null ) {
239- validate (mapping , readMethod );
240- String pairName = mapping .value ();
241- GeneratorUtils .addGenericMapping (classMap , configuration , propertyName , pairName );
239+ String pairName = mapping .value ().trim ();
240+ GeneratorUtils .addGenericMapping (classMap , configuration , propertyName , pairName .isEmpty () ? propertyName : pairName );
242241 }
243242 }
244243 }
@@ -251,9 +250,8 @@ public boolean apply(ClassMap classMap, Configuration configuration) {
251250 Mapping mapping = readMethod .getAnnotation (Mapping .class );
252251 String propertyName = property .getName ();
253252 if (mapping != null ) {
254- validate (mapping , readMethod );
255- String pairName = mapping .value ();
256- GeneratorUtils .addGenericMapping (classMap , configuration , pairName , propertyName );
253+ String pairName = mapping .value ().trim ();
254+ GeneratorUtils .addGenericMapping (classMap , configuration , pairName .isEmpty () ? propertyName : pairName , propertyName );
257255 }
258256 }
259257 }
@@ -275,9 +273,8 @@ public boolean apply(ClassMap classMap, Configuration configuration) {
275273 Mapping mapping = field .getAnnotation (Mapping .class );
276274 String fieldName = field .getName ();
277275 if (mapping != null ) {
278- validate (mapping , field );
279- String pairName = mapping .value ();
280- addFieldMapping (classMap , configuration , fieldName , pairName );
276+ String pairName = mapping .value ().trim ();
277+ addFieldMapping (classMap , configuration , fieldName , pairName .isEmpty () ? fieldName : pairName );
281278 }
282279 }
283280 srcType = srcType .getSuperclass ();
@@ -289,9 +286,8 @@ public boolean apply(ClassMap classMap, Configuration configuration) {
289286 Mapping mapping = field .getAnnotation (Mapping .class );
290287 String fieldName = field .getName ();
291288 if (mapping != null ) {
292- validate (mapping , field );
293- String pairName = mapping .value ();
294- addFieldMapping (classMap , configuration , pairName , fieldName );
289+ String pairName = mapping .value ().trim ();
290+ addFieldMapping (classMap , configuration , pairName .isEmpty () ? fieldName : pairName , fieldName );
295291 }
296292 }
297293 destType = destType .getSuperclass ();
@@ -317,12 +313,4 @@ private static void addFieldMapping(ClassMap classMap, Configuration configurati
317313 MappingUtils .applyGlobalCopyByReference (configuration , fieldMap , classMap );
318314 classMap .addFieldMapping (fieldMap );
319315 }
320-
321- private static void validate (Mapping annotation , Member member ) {
322- if (annotation .value ().trim ().equals ("" )) {
323- throw new MappingException ("Mapping annotation value missing at " + member .getDeclaringClass ().getName () + "."
324- + member .getName ());
325- }
326- }
327-
328316}
0 commit comments