org.babyfish.jimmer.sql.di.StrategyProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jimmer-sql Show documentation
Show all versions of jimmer-sql Show documentation
A revolutionary ORM framework for both java and kotlin
package org.babyfish.jimmer.sql.di;
import org.babyfish.jimmer.sql.JSqlClient;
import java.lang.reflect.Constructor;
public interface StrategyProvider {
@SuppressWarnings("unchecked")
default T get(
Class type,
JSqlClient sqlClient
) throws Exception {
Constructor> constructor = null;
try {
constructor = type.getConstructor();
} catch (NoSuchMethodException ex) {
// Do nothing
}
if (constructor != null) {
return (T) constructor.newInstance();
}
throw new IllegalArgumentException(
"Illegal type \"" +
type.getName() +
"\", it is not manged by IOC framework but does not support default constructor"
);
}
default T get(String ref, JSqlClient sqlClient) throws Exception {
throw new UnsupportedOperationException(
"The `ref` " +
"\" is not supported by \"" +
getClass().getName() +
"\" which is not used to support IOC framework"
);
}
}