Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BasicConverterFactory |
|
| 3.0;3 |
1 | /* | |
2 | * Copyright 2003-2004 The Apache Software Foundation | |
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.apache.commons.convert1; | |
17 | ||
18 | /** | |
19 | * Creates converter factors. Possibly rename to EmptyConstructorFactory. | |
20 | * | |
21 | * @author Henri Yandell | |
22 | * @since 0.1 | |
23 | */ | |
24 | public class BasicConverterFactory implements ConverterFactory { | |
25 | ||
26 | private Class clazz; | |
27 | ||
28 | 0 | public BasicConverterFactory(Class clazz) { |
29 | 0 | this.clazz = clazz; |
30 | 0 | } |
31 | ||
32 | public Object create(Class fromClass, Class toClass) { | |
33 | try { | |
34 | 0 | return clazz.newInstance(); |
35 | 0 | } catch (IllegalAccessException iae) { |
36 | 0 | return null; |
37 | 0 | } catch (InstantiationException ie) { |
38 | 0 | return null; |
39 | } | |
40 | } | |
41 | } |