Coverage Report - net.sourceforge.jeuclid.elements.support.text.CodePointAndVariant
 
Classes in this File Line Coverage Branch Coverage Complexity
CodePointAndVariant
62%
22/35
55%
10/18
3,167
 
 1  
 /*
 2  
  * Copyright 2002 - 2007 JEuclid, http://jeuclid.sf.net
 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  
 
 17  
 /* $Id: CodePointAndVariant.java,v 21bfa7b63ab2 2008/09/11 14:08:48 maxberger $ */
 18  
 
 19  
 package net.sourceforge.jeuclid.elements.support.text;
 20  
 
 21  
 import java.io.Serializable;
 22  
 
 23  
 import net.sourceforge.jeuclid.elements.support.attributes.MathVariant;
 24  
 
 25  
 /**
 26  
  * @version $Revision: 21bfa7b63ab2 $
 27  
  */
 28  209
 public class CodePointAndVariant implements Serializable {
 29  
     /**
 30  
      * 
 31  
      */
 32  
     private static final long serialVersionUID = 1L;
 33  
 
 34  
     private final int codePoint;
 35  
 
 36  
     private final MathVariant variant;
 37  
 
 38  
     /**
 39  
      * Create a new CodePointAndVariant.
 40  
      * 
 41  
      * @param icodePoint
 42  
      *            the codepoint to use
 43  
      * @param ivariant
 44  
      *            the MathVariant of the character.
 45  
      */
 46  
     public CodePointAndVariant(final int icodePoint,
 47  77248
             final MathVariant ivariant) {
 48  77248
         assert ivariant != null;
 49  77248
         this.codePoint = icodePoint;
 50  77248
         this.variant = ivariant;
 51  77248
     }
 52  
 
 53  
     /**
 54  
      * @return the codePoint
 55  
      */
 56  
     public final int getCodePoint() {
 57  123381
         return this.codePoint;
 58  
     }
 59  
 
 60  
     /**
 61  
      * @return the variant
 62  
      */
 63  
     public final MathVariant getVariant() {
 64  93048
         return this.variant;
 65  
     }
 66  
 
 67  
     /** {@inheritDoc} */
 68  
     @Override
 69  
     public int hashCode() {
 70  
         final int prime = 31;
 71  85511
         int result = 1;
 72  85511
         result = prime * result + this.codePoint;
 73  85511
         result = prime * result + this.variant.hashCode();
 74  85511
         return result;
 75  
     }
 76  
 
 77  
     /** {@inheritDoc} */
 78  
     @Override
 79  
     public boolean equals(final Object obj) {
 80  96931
         if (this == obj) {
 81  35361
             return true;
 82  
         }
 83  61570
         if (obj == null) {
 84  0
             return false;
 85  
         }
 86  61570
         if (this.getClass() != obj.getClass()) {
 87  0
             return false;
 88  
         }
 89  61570
         final CodePointAndVariant other = (CodePointAndVariant) obj;
 90  61570
         if (this.codePoint != other.codePoint) {
 91  3455
             return false;
 92  
         }
 93  58115
         if (this.variant == null) {
 94  0
             if (other.variant != null) {
 95  0
                 return false;
 96  
             }
 97  58115
         } else if (!this.variant.equals(other.variant)) {
 98  0
             return false;
 99  
         }
 100  58115
         return true;
 101  
     }
 102  
 
 103  
     /** {@inheritDoc} */
 104  
     @Override
 105  
     public String toString() {
 106  0
         final StringBuilder b = new StringBuilder();
 107  0
         b.append('[');
 108  0
         b.append("0x");
 109  0
         b.append(Integer.toHexString(this.codePoint));
 110  0
         b.append(' ');
 111  0
         b.append(this.variant.toString());
 112  0
         b.append(']');
 113  0
         return b.toString();
 114  
     }
 115  
 }