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