Coverage Report - org.dozer.metadata.DozerClassMappingMetadata
 
Classes in this File Line Coverage Branch Coverage Complexity
DozerClassMappingMetadata
53%
16/30
100%
6/6
1.278
 
 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.ArrayList;
 19  
 import java.util.List;
 20  
 
 21  
 import org.dozer.classmap.ClassMap;
 22  
 import org.dozer.classmap.MappingDirection;
 23  
 import org.dozer.fieldmap.FieldMap;
 24  
 
 25  
 /**
 26  
  * Internal use only.
 27  
  * @author Florian Kunz
 28  
  */
 29  
 public final class DozerClassMappingMetadata implements ClassMappingMetadata {
 30  
         
 31  
         private final ClassMap classMap;
 32  
         
 33  34
         public DozerClassMappingMetadata(ClassMap classMap) {
 34  34
                 this.classMap = classMap;
 35  34
         }
 36  
         
 37  
         public String getSourceClassName() {
 38  0
                 return classMap.getSrcClassName();
 39  
         }
 40  
 
 41  
         public String getDestinationClassName() {
 42  0
                 return classMap.getDestClassName();
 43  
         }
 44  
 
 45  
         public Class<?> getSourceClass() {
 46  0
                 return classMap.getSrcClassToMap();
 47  
         }
 48  
 
 49  
         public Class<?> getDestinationClass() {
 50  0
                 return classMap.getDestClassToMap();
 51  
         }
 52  
 
 53  
         public boolean isStopOnErrors() {
 54  0
                 return classMap.isStopOnErrors();
 55  
         }
 56  
 
 57  
         public boolean isTrimStrings() {
 58  0
                 return classMap.isTrimStrings();
 59  
         }
 60  
 
 61  
         public boolean isWildcard() {
 62  0
                 return classMap.isWildcard();
 63  
         }
 64  
 
 65  
         public boolean isSourceMapNull() {
 66  0
                 return classMap.isSrcMapNull();
 67  
         }
 68  
 
 69  
         public boolean isDestinationMapNull() {
 70  0
                 return classMap.isDestMapNull();
 71  
         }
 72  
 
 73  
         public boolean isSourceMapEmptyString() {
 74  0
                 return classMap.isSrcMapEmptyString();
 75  
         }
 76  
 
 77  
         public boolean isDestinationMapEmptyString() {
 78  0
                 return classMap.isDestMapEmptyString();
 79  
         }
 80  
 
 81  
         public String getDateFormat() {
 82  0
                 return classMap.getDateFormat();
 83  
         }
 84  
 
 85  
         public MappingDirection getMappingDirection() {
 86  0
                 return classMap.getType();
 87  
         }
 88  
 
 89  
         public String getMapId() {
 90  0
                 return classMap.getMapId();
 91  
         }
 92  
 
 93  
         public List<FieldMappingMetadata> getFieldMappings() {
 94  2
                 List<FieldMappingMetadata> fieldMapCats = new ArrayList<FieldMappingMetadata>();
 95  2
                 for(FieldMap fieldMap : classMap.getFieldMaps()) {
 96  6
                         fieldMapCats.add(new DozerFieldMappingMetadata(fieldMap));
 97  6
                 }
 98  
                 
 99  2
                 return fieldMapCats;
 100  
         }
 101  
 
 102  
         public FieldMappingMetadata getFieldMappingBySource(String sourceFieldName) {
 103  6
                 FieldMap fieldMap = classMap.getFieldMapUsingSrc(sourceFieldName);
 104  6
                 if (fieldMap == null) {
 105  2
                         throw new MetadataLookupException("Field mapping " + sourceFieldName + " not found for class " + classMap.getSrcClassName());
 106  
                 }
 107  
                 
 108  4
                 return new DozerFieldMappingMetadata(fieldMap);
 109  
         }
 110  
 
 111  
         public FieldMappingMetadata getFieldMappingByDestination(String destinationFieldName) {
 112  6
                 FieldMap fieldMap = classMap.getFieldMapUsingDest(destinationFieldName);
 113  6
                 if (fieldMap == null) {
 114  2
                         throw new MetadataLookupException("Field mapping " + destinationFieldName + " not found for class " + classMap.getDestClassName());
 115  
                 }
 116  
                 
 117  4
                 return new DozerFieldMappingMetadata(fieldMap);
 118  
         }
 119  
 
 120  
 }