source: josm/trunk/src/org/openstreetmap/josm/data/projection/proj/ClassProjFactory.java@ 13632

Last change on this file since 13632 was 11374, checked in by Don-vip, 7 years ago

sonar - squid:S00112 - Generic exceptions should never be thrown: define JosmRuntimeException

  • Property svn:eol-style set to native
File size: 836 bytes
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.projection.proj;
3
4import org.openstreetmap.josm.tools.JosmRuntimeException;
5
6/**
7 * Proj Factory that creates instances from a given class.
8 */
9public class ClassProjFactory implements ProjFactory {
10
11 private final Class<? extends Proj> projClass;
12
13 /**
14 * Constructs a new {@code ClassProjFactory}.
15 * @param projClass projection class
16 */
17 public ClassProjFactory(Class<? extends Proj> projClass) {
18 this.projClass = projClass;
19 }
20
21 @Override
22 public Proj createInstance() {
23 Proj proj = null;
24 try {
25 proj = projClass.getConstructor().newInstance();
26 } catch (ReflectiveOperationException e) {
27 throw new JosmRuntimeException(e);
28 }
29 return proj;
30 }
31}
Note: See TracBrowser for help on using the repository browser.