org.fernice.reflare.internal.Helper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fernice-reflare-access Show documentation
Show all versions of fernice-reflare-access Show documentation
Dirty helper for accessing internal Java API
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.fernice.reflare.internal;
class Helper {
@SuppressWarnings("unchecked")
static T accessor(Class type) {
try {
Class impl = (Class) Class.forName(type.getPackage().getName() + ".impl." + type.getSimpleName() + "Impl");
return impl.newInstance();
} catch (ClassNotFoundException e) {
throw new IllegalStateException("no reflare access implementation is present in classpath", e);
} catch (IllegalAccessException | InstantiationException e) {
throw new IllegalStateException("reflare access implementation is corrupted", e);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy