• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2016 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 com.google.auto.factory.processor;
17 
18 import static com.google.auto.factory.processor.Mirrors.unwrapOptionalEquivalence;
19 import static com.google.auto.factory.processor.Mirrors.wrapOptionalInEquivalence;
20 
21 import com.google.auto.common.AnnotationMirrors;
22 import com.google.auto.value.AutoValue;
23 import com.google.common.base.Equivalence;
24 import java.util.Optional;
25 import javax.lang.model.element.AnnotationMirror;
26 
27 @AutoValue
28 abstract class ProviderField {
name()29   abstract String name();
30 
key()31   abstract Key key();
32 
nullableWrapper()33   abstract Optional<Equivalence.Wrapper<AnnotationMirror>> nullableWrapper();
34 
nullable()35   Optional<AnnotationMirror> nullable() {
36     return unwrapOptionalEquivalence(nullableWrapper());
37   }
38 
create(String name, Key key, Optional<AnnotationMirror> nullable)39   static ProviderField create(String name, Key key, Optional<AnnotationMirror> nullable) {
40     return new AutoValue_ProviderField(
41         name, key, wrapOptionalInEquivalence(AnnotationMirrors.equivalence(), nullable));
42   }
43 }
44