下面列出了怎么用java.lang.reflect.MalformedParameterizedTypeException的API类实例代码及写法,或者点击链接到github查看源代码。
private Class<? extends Throwable> getGenericType(Class<? extends ExceptionMapper> mapper) {
try {
Type[] types = mapper.getGenericInterfaces();
if (null == types || 0 == types.length) {
types = new Type[]{mapper.getGenericSuperclass()};
}
for (Type type : types) {
Class<?> rawType = ClassUtils.getRawType(type);
if (type instanceof ParameterizedType && ExceptionMapper.class.isAssignableFrom(rawType)) {
//noinspection unchecked
return (Class<? extends Throwable>) ((ParameterizedType) type).getActualTypeArguments()[0];
}
}
if (isProxy(mapper)) {
return getGenericType((Class<? extends ExceptionMapper>) mapper.getSuperclass());
}
//Won't get in here
throw new IllegalStateException("unable to discover exception class for " + mapper.getName());
} catch (MalformedParameterizedTypeException e) {
throw new IllegalStateException(mapper.getName(), e);
}
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length) {
throw new MalformedParameterizedTypeException(String.format("Mismatch of count of " +
"formal and actual type " +
"arguments in constructor " +
"of %s: %d formal argument(s) "+
"%d actual argument(s)",
rawType.getName(),
formals.length,
actualTypeArguments.length));
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable/*<?>*/[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length) {
throw new MalformedParameterizedTypeException();
}
/*
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
*/
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable/*<?>*/[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length) {
throw new MalformedParameterizedTypeException();
}
/*
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
*/
}
private void validateConstructorArguments()
{
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length) {
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable/*<?>*/[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable/*<?>*/[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length) {
throw new MalformedParameterizedTypeException();
}
/*
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
*/
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable/*<?>*/[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length) {
throw new MalformedParameterizedTypeException();
}
/*
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
*/
}
private void validateConstructorArguments() {
TypeVariable/*<?>*/[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable/*<?>*/[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length) {
throw new MalformedParameterizedTypeException();
}
/*
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
*/
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable/*<?>*/[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length) {
throw new MalformedParameterizedTypeException();
}
/*
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
*/
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable/*<?>*/[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length) {
throw new MalformedParameterizedTypeException();
}
/*
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
*/
}
private void validateConstructorArguments() {
TypeVariable/*<?>*/[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length) {
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable/*<?>*/[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length) {
throw new MalformedParameterizedTypeException();
}
/*
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
*/
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
TypeVariable<?>[] formals = rawType.getTypeParameters();
// check correct arity of actual type args
if (formals.length != actualTypeArguments.length){
throw new MalformedParameterizedTypeException();
}
for (int i = 0; i < actualTypeArguments.length; i++) {
// check actuals against formals' bounds
}
}
private void validateConstructorArguments() {
@SuppressWarnings("rawtypes")
TypeVariable[] arrayOfTypeVariable = this.rawType.getTypeParameters();
if (arrayOfTypeVariable.length != this.actualTypeArguments.length) {
throw new MalformedParameterizedTypeException();
}
// for(int i=0; i < this.actualTypeArguments.length; i++);
}
/**
* java.lang.reflect.MalformedParameterizedTypeException#MalformedParameterizedTypeException()
*/
public void test_Constructor() throws Exception {
Constructor<MalformedParameterizedTypeException> ctor = MalformedParameterizedTypeException.class
.getDeclaredConstructor();
assertNotNull("Parameterless constructor does not exist.", ctor);
assertTrue("Constructor is not protected", Modifier.isPublic(ctor
.getModifiers()));
assertNotNull(ctor.newInstance());
}
/**
* java.lang.reflect.MalformedParameterizedTypeException#
* MalformedParameterizedTypeException()
*/
public void testMalformedParameterizedTypeException() {
MalformedParameterizedTypeException e = new MalformedParameterizedTypeException();
assertNotNull(e);
assertNull(e.getMessage());
}