Java Code Examples for java.lang.reflect.Constructor#getGenericExceptionTypes()
The following examples show how to use
java.lang.reflect.Constructor#getGenericExceptionTypes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeLiteral.java From businessworks with Apache License 2.0 | 6 votes |
/** * Returns the resolved generic exception types thrown by {@code constructor}. * * @param methodOrConstructor a method or constructor defined by this or any supertype. * @since 2.0 */ public List<TypeLiteral<?>> getExceptionTypes(Member methodOrConstructor) { Type[] genericExceptionTypes; if (methodOrConstructor instanceof Method) { Method method = (Method) methodOrConstructor; checkArgument(method.getDeclaringClass().isAssignableFrom(rawType), "%s is not defined by a supertype of %s", method, type); genericExceptionTypes = method.getGenericExceptionTypes(); } else if (methodOrConstructor instanceof Constructor) { Constructor<?> constructor = (Constructor<?>) methodOrConstructor; checkArgument(constructor.getDeclaringClass().isAssignableFrom(rawType), "%s does not construct a supertype of %s", constructor, type); genericExceptionTypes = constructor.getGenericExceptionTypes(); } else { throw new IllegalArgumentException("Not a method or a constructor: " + methodOrConstructor); } return resolveAll(genericExceptionTypes); }
Example 2
Source File: ClassDescription.java From ldp4j with Apache License 2.0 | 6 votes |
@Override protected void processType(Constructor<?> type) { super.addTitle("Constructor"); super.addBlockField("member", wrapElementAs(type,Member.class)); super.addBlockField("generic declaration", wrapElementAs(type,GenericDeclaration.class)); super.addBlockField("annotated element", wrapElementAs(type,AnnotatedElement.class)); super.addField("accessible", type.isAccessible()); super.addMultiField("parameter types",type.getParameterTypes()); super.addMultiField("generic parameter types",type.getGenericParameterTypes()); Annotation[][] parameterAnnotations = type.getParameterAnnotations(); List<String> annots=new ArrayList<String>(); for(Annotation[] pa:parameterAnnotations) { annots.add(Arrays.toString(pa)); } super.addMultiField("parameter annotations",annots); super.addField("var args",type.isVarArgs()); super.addMultiField("exception types",type.getExceptionTypes()); super.addMultiField("generic exception types",type.getGenericExceptionTypes()); }
Example 3
Source File: TypeLiteral.java From crate with Apache License 2.0 | 6 votes |
/** * Returns the resolved generic exception types thrown by {@code constructor}. * * @param methodOrConstructor a method or constructor defined by this or any supertype. * @since 2.0 */ public List<TypeLiteral<?>> getExceptionTypes(Member methodOrConstructor) { Type[] genericExceptionTypes; if (methodOrConstructor instanceof Method) { Method method = (Method) methodOrConstructor; if (!method.getDeclaringClass().isAssignableFrom(rawType)) { throw new IllegalArgumentException(method + " is not defined by a supertype of " + type); } genericExceptionTypes = method.getGenericExceptionTypes(); } else if (methodOrConstructor instanceof Constructor) { Constructor<?> constructor = (Constructor<?>) methodOrConstructor; if (!constructor.getDeclaringClass().isAssignableFrom(rawType)) { throw new IllegalArgumentException(constructor + " does not construct a supertype of " + type); } genericExceptionTypes = constructor.getGenericExceptionTypes(); } else { throw new IllegalArgumentException("Not a method or a constructor: " + methodOrConstructor); } return resolveAll(genericExceptionTypes); }