public static FileNameMapper getFileNameMapper()

in src/main/java/org/apache/maven/shared/model/fileset/mappers/MapperUtil.java [68:104]


    public static FileNameMapper getFileNameMapper(Mapper mapper) throws MapperException {
        if (mapper == null) {
            return null;
        }

        initializeBuiltIns();

        String type = mapper.getType();
        String classname = mapper.getClassname();

        if (type == null && classname == null) {
            throw new MapperException("nested mapper or " + "one of the attributes type or classname is required");
        }

        if (type != null && classname != null) {
            throw new MapperException("must not specify both type and classname attribute");
        }
        if (type != null) {
            classname = implementations.getProperty(type);
        }

        try {
            FileNameMapper m = (FileNameMapper) Thread.currentThread()
                    .getContextClassLoader()
                    .loadClass(classname)
                    .newInstance();

            m.setFrom(mapper.getFrom());
            m.setTo(mapper.getTo());

            return m;
        } catch (ClassNotFoundException e) {
            throw new MapperException("Cannot find mapper implementation: " + classname, e);
        } catch (InstantiationException | IllegalAccessException e) {
            throw new MapperException("Cannot load mapper implementation: " + classname, e);
        }
    }