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

Last change on this file since 10208 was 10208, checked in by Don-vip, 8 years ago

see #11924 - Java 9 - JDK-6850612 deprecates Class.newInstance() ==> replace it by Class.getConstructor().newInstance()

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