View Javadoc
1   /*
2    * Copyright (c) 2006 JMockit developers
3    * This file is subject to the terms of the MIT license (see LICENSE.txt).
4    */
5   package mockit.internal.injection.constructor;
6   
7   import static mockit.internal.util.Utilities.getClassType;
8   
9   import edu.umd.cs.findbugs.annotations.NonNull;
10  import edu.umd.cs.findbugs.annotations.Nullable;
11  
12  import java.lang.annotation.Annotation;
13  import java.lang.reflect.Type;
14  
15  import mockit.internal.injection.InjectionProvider;
16  
17  final class ConstructorParameter extends InjectionProvider {
18      @NonNull
19      private final Class<?> classOfDeclaredType;
20      @NonNull
21      private final Annotation[] annotations;
22      @Nullable
23      private final Object value;
24  
25      ConstructorParameter(@NonNull Type declaredType, @NonNull Annotation[] annotations, @NonNull String name,
26              @Nullable Object value) {
27          super(declaredType, name);
28          classOfDeclaredType = getClassType(declaredType);
29          this.annotations = annotations;
30          this.value = value;
31      }
32  
33      @NonNull
34      @Override
35      public Class<?> getClassOfDeclaredType() {
36          return classOfDeclaredType;
37      }
38  
39      @NonNull
40      @Override
41      public Annotation[] getAnnotations() {
42          return annotations;
43      }
44  
45      @Nullable
46      @Override
47      public Object getValue(@Nullable Object owner) {
48          return value;
49      }
50  
51      @Override
52      public String toString() {
53          return "parameter " + super.toString();
54      }
55  }