Coverage Report - org.dozer.classmap.CopyByReference
 
Classes in this File Line Coverage Branch Coverage Complexity
CopyByReference
64%
9/14
N/A
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.classmap;
 17  
 
 18  
 import org.apache.commons.lang3.StringUtils;
 19  
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 20  
 import org.apache.commons.lang3.builder.ToStringStyle;
 21  
 
 22  
 import java.util.regex.Matcher;
 23  
 import java.util.regex.Pattern;
 24  
 
 25  
 /**
 26  
  * Only intended for internal use.
 27  
  *
 28  
  * @author garsombke.franz
 29  
  * @author sullins.ben
 30  
  * @author tierney.matt
 31  
  */
 32  
 public class CopyByReference {
 33  
 
 34  
     private static final String WILDCARD = "*";
 35  
     
 36  
     private String mask;
 37  
     private Pattern pattern;
 38  
 
 39  144
     public CopyByReference(String mask) {
 40  144
         this.mask = mask;
 41  144
         pattern = compilePattern(mask);
 42  144
     }
 43  
 
 44  
     public String getMask() {
 45  0
         return mask;
 46  
     }
 47  
 
 48  
     public void setMask(String mask) {
 49  0
         this.mask = mask;
 50  0
         pattern = compilePattern(mask);
 51  0
     }
 52  
 
 53  
     private Pattern compilePattern(String mask) {
 54  144
         String regexp = StringUtils.replace(mask, ".", "\\.");
 55  144
         regexp = StringUtils.replace(regexp, WILDCARD, ".*?");
 56  144
         return Pattern.compile(regexp);
 57  
     }
 58  
 
 59  
     public boolean matches(String destFieldTypeName) {
 60  75185
         Matcher matcher = pattern.matcher(destFieldTypeName);
 61  75185
         return matcher.matches();
 62  
     }
 63  
 
 64  
     @Override
 65  
     public String toString() {
 66  0
         return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
 67  
     }
 68  
 
 69  
 }