コード例 #1
0
 @Override
 public AnnotationAppender onParameterizedType(TypeDescription.Generic parameterizedType) {
   StringBuilder typePath = new StringBuilder(this.typePath);
   for (int index = 0; index < parameterizedType.asErasure().getSegmentCount(); index++) {
     typePath = typePath.append(INNER_CLASS_PATH);
   }
   AnnotationAppender annotationAppender = apply(parameterizedType, typePath.toString());
   TypeDescription.Generic ownerType = parameterizedType.getOwnerType();
   if (ownerType != null) {
     annotationAppender =
         ownerType.accept(
             new ForTypeAnnotations(
                 annotationAppender, annotationValueFilter, typeReference, this.typePath));
   }
   int index = 0;
   for (TypeDescription.Generic typeArgument : parameterizedType.getTypeArguments()) {
     annotationAppender =
         typeArgument.accept(
             new ForTypeAnnotations(
                 annotationAppender,
                 annotationValueFilter,
                 typeReference,
                 typePath.toString() + index++ + INDEXED_TYPE_DELIMITER));
   }
   return annotationAppender;
 }
コード例 #2
0
 @Override
 @Before
 @SuppressWarnings("unchecked")
 public void setUp() throws Exception {
   super.setUp();
   when(firstSourceType.getStackSize()).thenReturn(StackSize.SINGLE);
   when(secondSourceType.getStackSize()).thenReturn(StackSize.SINGLE);
   when(componentType.asErasure()).thenReturn(rawComponentType);
   when(targetType.getComponentType()).thenReturn(componentType);
   when(targetType.asErasure()).thenReturn(rawTargetType);
   when(firstSourceType.asGenericType()).thenReturn(firstSourceType);
   when(firstSourceType.accept(any(TypeDescription.Generic.Visitor.class)))
       .thenReturn(firstSourceType);
   when(secondSourceType.asGenericType()).thenReturn(secondSourceType);
   when(secondSourceType.accept(any(TypeDescription.Generic.Visitor.class)))
       .thenReturn(secondSourceType);
 }
コード例 #3
0
 @Test(expected = IllegalStateException.class)
 public void testNonArrayTypeBinding() throws Exception {
   when(target.getIndex()).thenReturn(0);
   TypeDescription.Generic targetType = mock(TypeDescription.Generic.class);
   TypeDescription rawTargetType = mock(TypeDescription.class);
   when(targetType.asErasure()).thenReturn(rawTargetType);
   when(targetType.isArray()).thenReturn(false);
   when(target.getType()).thenReturn(targetType);
   AllArguments.Binder.INSTANCE.bind(
       annotationDescription, source, target, implementationTarget, assigner);
 }
コード例 #4
0
 @Override
 public AnnotationAppender onNonGenericType(TypeDescription.Generic typeDescription) {
   StringBuilder typePath = new StringBuilder(this.typePath);
   for (int index = 0; index < typeDescription.asErasure().getSegmentCount(); index++) {
     typePath = typePath.append(INNER_CLASS_PATH);
   }
   AnnotationAppender annotationAppender = apply(typeDescription, typePath.toString());
   if (typeDescription.isArray()) {
     annotationAppender =
         typeDescription
             .getComponentType()
             .accept(
                 new ForTypeAnnotations(
                     annotationAppender,
                     annotationValueFilter,
                     typeReference,
                     this.typePath + COMPONENT_TYPE_PATH)); // Impossible to be inner class
   }
   return annotationAppender;
 }