• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 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  *   https://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.android.enterprise.connectedapps.processor.containers;
17 
18 import com.google.android.enterprise.connectedapps.annotations.CrossProfile;
19 import com.google.auto.value.AutoValue;
20 import com.google.common.collect.ImmutableCollection;
21 import java.util.Optional;
22 import javax.lang.model.element.TypeElement;
23 
24 /** Wrapper around information contained in an annotation of type {@link CrossProfile}. */
25 @AutoValue
26 public abstract class CrossProfileAnnotationInfo {
27 
28   public static final String DEFAULT_CONNECTOR_NAME =
29       "com.google.android.enterprise.connectedapps.annotations.CrossProfile";
30 
connectorClass()31   public abstract TypeElement connectorClass();
32 
profileClassName()33   public abstract String profileClassName();
34 
timeoutMillis()35   public abstract Optional<Long> timeoutMillis();
36 
parcelableWrapperClasses()37   public abstract ImmutableCollection<TypeElement> parcelableWrapperClasses();
38 
futureWrapperClasses()39   public abstract ImmutableCollection<TypeElement> futureWrapperClasses();
40 
isStatic()41   public abstract boolean isStatic();
42 
connectorIsDefault()43   public boolean connectorIsDefault() {
44     return connectorClass().asType().toString().equals(DEFAULT_CONNECTOR_NAME);
45   }
46 
isProfileClassNameDefault()47   public boolean isProfileClassNameDefault() {
48     return profileClassName().isEmpty();
49   }
50 
builder()51   public static Builder builder() {
52     return new AutoValue_CrossProfileAnnotationInfo.Builder();
53   }
54 
55   @AutoValue.Builder
56   public abstract static class Builder {
57 
setConnectorClass(TypeElement value)58     public abstract Builder setConnectorClass(TypeElement value);
59 
setProfileClassName(String value)60     public abstract Builder setProfileClassName(String value);
61 
setTimeoutMillis(Long value)62     public abstract Builder setTimeoutMillis(Long value);
63 
setParcelableWrapperClasses(ImmutableCollection<TypeElement> value)64     public abstract Builder setParcelableWrapperClasses(ImmutableCollection<TypeElement> value);
65 
setFutureWrapperClasses(ImmutableCollection<TypeElement> value)66     public abstract Builder setFutureWrapperClasses(ImmutableCollection<TypeElement> value);
67 
setIsStatic(boolean value)68     public abstract Builder setIsStatic(boolean value);
69 
build()70     public abstract CrossProfileAnnotationInfo build();
71   }
72 }
73