Coverage Report - org.dozer.classmap.MappingDirection
 
Classes in this File Line Coverage Branch Coverage Complexity
MappingDirection
90%
9/10
83%
5/6
8
 
 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.classmap;
 17  
 
 18  
 import org.apache.commons.lang3.StringUtils;
 19  
 
 20  
 /**
 21  
  * @author dmitry.buzdin
 22  
  */
 23  2
 public final class MappingDirection {
 24  
 
 25  
   private static final String BI_DIRECTIONAL_VALUE = "bi-directional";
 26  
   private static final String ONE_WAY_VALUE = "one-way";
 27  
 
 28  
   /**
 29  
    * Default mapping approach when a -> b -> a' then a == a'
 30  
    */
 31  1
   public static final MappingDirection BI_DIRECTIONAL = new MappingDirection();
 32  
   /**
 33  
    * Unidirectional mapping when a -> b -> a' then a != a'
 34  
    */
 35  1
   public static final MappingDirection ONE_WAY = new MappingDirection();
 36  
 
 37  
   public static MappingDirection valueOf(String mappingDirection) {
 38  1671
     if (BI_DIRECTIONAL_VALUE.equals(mappingDirection)) {
 39  829
       return BI_DIRECTIONAL;
 40  842
     } else if (ONE_WAY_VALUE.equals(mappingDirection)) {
 41  841
       return ONE_WAY;
 42  1
     } else if (StringUtils.isEmpty(mappingDirection)) {
 43  1
       return null;
 44  
     }
 45  0
     throw new IllegalStateException("type should be bi-directional or one-way. " + mappingDirection);
 46  
   }
 47  
   
 48  
 }