1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package tests; 17 18 import static java.lang.annotation.ElementType.PARAMETER; 19 import static java.lang.annotation.ElementType.TYPE_USE; 20 import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 22 import com.google.auto.factory.AutoFactory; 23 import com.google.auto.factory.Provided; 24 import java.lang.annotation.Retention; 25 import java.lang.annotation.Target; 26 27 @AutoFactory 28 final class ParameterAnnotations { 29 @Retention(RUNTIME) 30 @Target(PARAMETER) 31 @interface NullableParameter {} 32 33 // We have special treatment of @Nullable; make sure it doesn't get copied twice. 34 @Retention(RUNTIME) 35 @Target(PARAMETER) 36 @interface Nullable {} 37 38 @Retention(RUNTIME) 39 @Target(TYPE_USE) 40 @interface NullableType {} 41 42 @Retention(RUNTIME) 43 @Target({PARAMETER, TYPE_USE}) 44 @interface NullableParameterAndType {} 45 ParameterAnnotations( @rovided @ullableParameter @ullableType String foo, @NullableParameter Integer bar, @Nullable Long baz, @NullableType Thread buh, @NullableParameterAndType String quux)46 ParameterAnnotations( 47 @Provided @NullableParameter @NullableType String foo, 48 @NullableParameter Integer bar, 49 @Nullable Long baz, 50 @NullableType Thread buh, 51 @NullableParameterAndType String quux) {} 52 } 53