Clover coverage report - Convert - proto0
Coverage timestamp: Mo Nov 22 2004 13:19:16 CET
file stats: LOC: 64   Methods: 4
NCLOC: 34   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
PrimitiveType.java 100% 100% 100% 100%
coverage
 1    /*
 2    * Copyright 2004 Ronald Blaschke.
 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.rblasch.convert.type;
 17   
 18    import org.rblasch.convert.assertion.Assertion;
 19   
 20    import java.util.HashMap;
 21    import java.util.Map;
 22   
 23    /**
 24    * Created by IntelliJ IDEA.
 25    * User: rb
 26    * Date: Oct 27, 2004
 27    * Time: 10:26:35 PM
 28    * To change this template use File | Settings | File Templates.
 29    */
 30    public class PrimitiveType extends AbstractType {
 31    final static Map valueOfMap = new HashMap();
 32    static {
 33  8 valueOfMap.put("byte", new PrimitiveType(Byte.TYPE));
 34  8 valueOfMap.put("short", new PrimitiveType(Short.TYPE));
 35  8 valueOfMap.put("int", new PrimitiveType(Integer.TYPE));
 36  8 valueOfMap.put("long", new PrimitiveType(Long.TYPE));
 37  8 valueOfMap.put("float", new PrimitiveType(Float.TYPE));
 38  8 valueOfMap.put("double", new PrimitiveType(Double.TYPE));
 39    }
 40   
 41  25 static PrimitiveType valueOf(final String s) throws UnknownTypeException {
 42  25 final PrimitiveType type = (PrimitiveType) valueOfMap.get(s);
 43  25 if (type != null) {
 44  19 return type;
 45    } else {
 46  6 throw new UnknownTypeException(s + " is not a known primitive type");
 47    }
 48    }
 49   
 50    private final Class t;
 51   
 52  60 PrimitiveType(final Class t) {
 53  60 Assertion.ensure(t.isPrimitive(), "t must be primitive");
 54  60 this.t = t;
 55    }
 56   
 57  1 public Class getTheClass() {
 58  1 return t;
 59    }
 60   
 61  205533 public String getName() {
 62  205533 return t.getName();
 63    }
 64    }