001    // License: GPL. For details, see LICENSE file.
002    package org.openstreetmap.josm.data.projection.proj;
003    
004    /**
005     * Proj Factory that creates instances from a given class.
006     */
007    public class ClassProjFactory implements ProjFactory {
008    
009        private Class<? extends Proj> projClass;
010    
011        public ClassProjFactory(Class<? extends Proj> projClass) {
012            this.projClass = projClass;
013        }
014    
015        @Override
016        public Proj createInstance() {
017            Proj proj = null;
018            try {
019                proj = projClass.newInstance();
020            } catch (InstantiationException e) {
021                throw new RuntimeException(e);
022            } catch (IllegalAccessException e) {
023                throw new RuntimeException(e);
024            }
025            return proj;
026        }
027    }