Java Class.getEnclosingConstructor Examples

Java Class.getEnclosingConstructor - 2 examples found. These are the top rated real world Java examples of Class.getEnclosingConstructor extracted from open source projects. You can rate examples to help us improve the quality of examples.
 @Test
 public void testEnclosingMethod() throws Exception {
   for (Class<?> type : standardTypes) {
     Matcher<MethodDescription> matcher;
     if (type.getEnclosingMethod() != null) {
       matcher =
           CoreMatchers.<MethodDescription>is(
               new MethodDescription.ForLoadedMethod(type.getEnclosingMethod()));
     } else if (type.getEnclosingConstructor() != null) {
       matcher =
           CoreMatchers.<MethodDescription>is(
               new MethodDescription.ForLoadedConstructor(type.getEnclosingConstructor()));
     } else {
       matcher = nullValue(MethodDescription.class);
     }
     assertThat(describe(type).getEnclosingMethod(), matcher);
   }
 }
  static int examine(Class enclosedClass, String constructorSig) {
    Constructor c = enclosedClass.getEnclosingConstructor();
    if (c == null && constructorSig == null) return 0;

    if (c != null && c.getAnnotation(ConstructorDescriptor.class).value().equals(constructorSig))
      return 0; // everything is okay
    else {
      System.err.println(
          "\nUnexpected constructor value; expected:\t" + constructorSig + "\ngot:\t" + c);
      return 1;
    }
  }