Coverage Report - org.dozer.loader.api.TypeMappingBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
TypeMappingBuilder
100%
19/19
100%
2/2
1.143
 
 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.loader.api;
 17  
 
 18  
 import org.dozer.loader.DozerBuilder;
 19  
 
 20  
 /**
 21  
  * @author Dmitry Buzdin
 22  
  */
 23  
 public final class TypeMappingBuilder {
 24  
 
 25  
   private DozerBuilder.MappingBuilder beanMappingBuilder;
 26  
 
 27  29
   public TypeMappingBuilder(DozerBuilder.MappingBuilder beanMappingBuilder) {
 28  29
     this.beanMappingBuilder = beanMappingBuilder;
 29  29
   }
 30  
 
 31  
   public TypeMappingBuilder fields(String a, String b, FieldsMappingOption... options) {
 32  17
     return fields(new FieldDefinition(a), new FieldDefinition(b), options);
 33  
   }
 34  
 
 35  
   public TypeMappingBuilder fields(FieldDefinition a, String b, FieldsMappingOption... options) {
 36  1
     return fields(a, new FieldDefinition(b), options);
 37  
   }
 38  
 
 39  
   public TypeMappingBuilder fields(String a, FieldDefinition b, FieldsMappingOption... options) {
 40  1
     return fields(new FieldDefinition(a), b, options);
 41  
   }  
 42  
 
 43  
   public TypeMappingBuilder fields(FieldDefinition a, FieldDefinition b, FieldsMappingOption... options) {
 44  23
     DozerBuilder.FieldMappingBuilder builder = beanMappingBuilder.field();
 45  
     
 46  23
     String aText = a.resolve();
 47  23
     String bText = b.resolve();
 48  
 
 49  23
     a.build(builder.a(aText));
 50  23
     b.build(builder.b(bText));
 51  
 
 52  45
     for (FieldsMappingOption option : options) {
 53  22
       option.apply(builder);
 54  
     }
 55  
 
 56  23
     return this;
 57  
   }
 58  
 
 59  
   public TypeMappingBuilder exclude(String field) {
 60  1
     return exclude(new FieldDefinition(field));
 61  
   }
 62  
 
 63  
   public TypeMappingBuilder exclude(FieldDefinition field) {
 64  1
     DozerBuilder.FieldExclusionBuilder builder = beanMappingBuilder.fieldExclude();
 65  1
     builder.a(field.resolve(), null);
 66  1
     builder.b(field.resolve(), null);
 67  1
     return this;
 68  
   }
 69  
 
 70  
 }