|
| 1 | +/* |
| 2 | + The MIT License |
| 3 | +
|
| 4 | + Copyright (c) 2010-2021 Paul R. Holser, Jr. |
| 5 | +
|
| 6 | + Permission is hereby granted, free of charge, to any person obtaining |
| 7 | + a copy of this software and associated documentation files (the |
| 8 | + "Software"), to deal in the Software without restriction, including |
| 9 | + without limitation the rights to use, copy, modify, merge, publish, |
| 10 | + distribute, sublicense, and/or sell copies of the Software, and to |
| 11 | + permit persons to whom the Software is furnished to do so, subject to |
| 12 | + the following conditions: |
| 13 | +
|
| 14 | + The above copyright notice and this permission notice shall be |
| 15 | + included in all copies or substantial portions of the Software. |
| 16 | +
|
| 17 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 20 | + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 21 | + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 22 | + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 23 | + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 | +*/ |
| 25 | + |
| 26 | +package org.utbot.quickcheck.internal; |
| 27 | + |
| 28 | +import java.lang.annotation.Annotation; |
| 29 | +import java.lang.reflect.AnnotatedArrayType; |
| 30 | +import java.lang.reflect.AnnotatedType; |
| 31 | +import java.lang.reflect.Type; |
| 32 | + |
| 33 | +final class FakeAnnotatedTypeFactoryWithType { |
| 34 | + private FakeAnnotatedTypeFactoryWithType() { |
| 35 | + throw new UnsupportedOperationException(); |
| 36 | + } |
| 37 | + |
| 38 | + static AnnotatedType makeFrom(Type type) { |
| 39 | + return type.getClass().isArray() ? makeArrayType(type) : makePlainType(type); |
| 40 | + } |
| 41 | + |
| 42 | + private static AnnotatedArrayType makeArrayType(Type type) { |
| 43 | + return new FakeAnnotatedArrayType(type); |
| 44 | + } |
| 45 | + |
| 46 | + private static AnnotatedType makePlainType(Type type) { |
| 47 | + return new FakeAnnotatedType(type); |
| 48 | + } |
| 49 | + |
| 50 | + private static final class FakeAnnotatedArrayType |
| 51 | + implements AnnotatedArrayType { |
| 52 | + |
| 53 | + private final Type type; |
| 54 | + |
| 55 | + FakeAnnotatedArrayType(Type type) { |
| 56 | + this.type = type; |
| 57 | + } |
| 58 | + |
| 59 | + @Override public AnnotatedType getAnnotatedGenericComponentType() { |
| 60 | + return makeFrom(type.getClass().getComponentType()); |
| 61 | + } |
| 62 | + |
| 63 | + // Not introduced until JDK 9 -- not marking as... |
| 64 | + // @Override |
| 65 | + public AnnotatedType getAnnotatedOwnerType() { |
| 66 | + return null; |
| 67 | + } |
| 68 | + |
| 69 | + @Override public Type getType() { |
| 70 | + return type; |
| 71 | + } |
| 72 | + |
| 73 | + @Override public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { |
| 74 | + |
| 75 | + return null; |
| 76 | + } |
| 77 | + |
| 78 | + @Override public Annotation[] getAnnotations() { |
| 79 | + return new Annotation[0]; |
| 80 | + } |
| 81 | + |
| 82 | + @Override public Annotation[] getDeclaredAnnotations() { |
| 83 | + return new Annotation[0]; |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + private static final class FakeAnnotatedType implements AnnotatedType { |
| 88 | + private final Type type; |
| 89 | + |
| 90 | + FakeAnnotatedType(Type type) { |
| 91 | + this.type = type; |
| 92 | + } |
| 93 | + |
| 94 | + @Override public Type getType() { |
| 95 | + return type; |
| 96 | + } |
| 97 | + |
| 98 | + @Override public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { |
| 99 | + |
| 100 | + return null; |
| 101 | + } |
| 102 | + |
| 103 | + @Override public Annotation[] getAnnotations() { |
| 104 | + return new Annotation[0]; |
| 105 | + } |
| 106 | + |
| 107 | + @Override public Annotation[] getDeclaredAnnotations() { |
| 108 | + return new Annotation[0]; |
| 109 | + } |
| 110 | + } |
| 111 | +} |
0 commit comments