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.processor.SupportedTypes; 19 import com.google.auto.value.AutoValue; 20 import com.google.common.collect.ImmutableSet; 21 import java.util.Collection; 22 import javax.annotation.processing.ProcessingEnvironment; 23 import javax.lang.model.element.ExecutableElement; 24 import javax.lang.model.element.TypeElement; 25 import javax.lang.model.util.Elements; 26 import javax.lang.model.util.Types; 27 28 /** 29 * Context for connected apps code validators. 30 * 31 * <p>This is used to validate enough that a {@link GeneratorContext} can be created for further 32 * validation and generation. 33 */ 34 @AutoValue 35 public abstract class ValidatorContext extends Context { 36 builderFromPreValidatorContext(PreValidatorContext preValidatorContext)37 public static Builder builderFromPreValidatorContext(PreValidatorContext preValidatorContext) { 38 return new AutoValue_ValidatorContext.Builder() 39 .setProcessingEnv(preValidatorContext.processingEnv()) 40 .setElements(preValidatorContext.elements()) 41 .setTypes(preValidatorContext.types()); 42 } 43 globalSupportedTypes()44 public abstract SupportedTypes globalSupportedTypes(); 45 newProfileConnectorInterfaces()46 public abstract ImmutableSet<ProfileConnectorInfo> newProfileConnectorInterfaces(); 47 newUserConnectorInterfaces()48 public abstract ImmutableSet<UserConnectorInfo> newUserConnectorInterfaces(); 49 newGeneratedProfileConnectors()50 public abstract ImmutableSet<TypeElement> newGeneratedProfileConnectors(); 51 newGeneratedUserConnectors()52 public abstract ImmutableSet<TypeElement> newGeneratedUserConnectors(); 53 newConfigurations()54 public abstract ImmutableSet<ValidatorCrossProfileConfigurationInfo> newConfigurations(); 55 newCrossProfileTypes()56 public abstract ImmutableSet<ValidatorCrossProfileTypeInfo> newCrossProfileTypes(); 57 newCrossProfileMethods()58 public abstract ImmutableSet<ExecutableElement> newCrossProfileMethods(); 59 newProviderClasses()60 public abstract ImmutableSet<ValidatorProviderClassInfo> newProviderClasses(); 61 newProviderMethods()62 public abstract ImmutableSet<ExecutableElement> newProviderMethods(); 63 newCrossProfileCallbackInterfaces()64 public abstract ImmutableSet<TypeElement> newCrossProfileCallbackInterfaces(); 65 newCrossProfileTests()66 public abstract ImmutableSet<ValidatorCrossProfileTestInfo> newCrossProfileTests(); 67 newCustomParcelableWrappers()68 public abstract ImmutableSet<TypeElement> newCustomParcelableWrappers(); 69 newCustomFutureWrappers()70 public abstract ImmutableSet<TypeElement> newCustomFutureWrappers(); 71 72 /** A builder for {@link ValidatorContext}. */ 73 @AutoValue.Builder 74 public abstract static class Builder { setProcessingEnv(ProcessingEnvironment processingEnv)75 public abstract Builder setProcessingEnv(ProcessingEnvironment processingEnv); 76 setElements(Elements elements)77 public abstract Builder setElements(Elements elements); 78 setTypes(Types types)79 public abstract Builder setTypes(Types types); 80 setGlobalSupportedTypes(SupportedTypes globalSupportedTypes)81 public abstract Builder setGlobalSupportedTypes(SupportedTypes globalSupportedTypes); 82 setNewProfileConnectorInterfaces( Collection<ProfileConnectorInfo> newProfileConnectorInterfaces)83 public abstract Builder setNewProfileConnectorInterfaces( 84 Collection<ProfileConnectorInfo> newProfileConnectorInterfaces); 85 setNewUserConnectorInterfaces( Collection<UserConnectorInfo> newUserConnectorInterfaces)86 public abstract Builder setNewUserConnectorInterfaces( 87 Collection<UserConnectorInfo> newUserConnectorInterfaces); 88 setNewGeneratedProfileConnectors( Collection<TypeElement> newGeneratedConnectors)89 public abstract Builder setNewGeneratedProfileConnectors( 90 Collection<TypeElement> newGeneratedConnectors); 91 setNewGeneratedUserConnectors( Collection<TypeElement> newGeneratedUserConnectors)92 public abstract Builder setNewGeneratedUserConnectors( 93 Collection<TypeElement> newGeneratedUserConnectors); 94 setNewConfigurations( Collection<ValidatorCrossProfileConfigurationInfo> newConfigurations)95 public abstract Builder setNewConfigurations( 96 Collection<ValidatorCrossProfileConfigurationInfo> newConfigurations); 97 setNewCrossProfileTypes( Collection<ValidatorCrossProfileTypeInfo> newCrossProfileTypes)98 public abstract Builder setNewCrossProfileTypes( 99 Collection<ValidatorCrossProfileTypeInfo> newCrossProfileTypes); 100 setNewCrossProfileMethods( Collection<ExecutableElement> newCrossProfileMethods)101 public abstract Builder setNewCrossProfileMethods( 102 Collection<ExecutableElement> newCrossProfileMethods); 103 setNewProviderClasses( Collection<ValidatorProviderClassInfo> newProviderClasses)104 public abstract Builder setNewProviderClasses( 105 Collection<ValidatorProviderClassInfo> newProviderClasses); 106 setNewProviderMethods(Collection<ExecutableElement> newProviderMethods)107 public abstract Builder setNewProviderMethods(Collection<ExecutableElement> newProviderMethods); 108 setNewCrossProfileCallbackInterfaces( Collection<TypeElement> newCrossProfileCallbackInterfaces)109 public abstract Builder setNewCrossProfileCallbackInterfaces( 110 Collection<TypeElement> newCrossProfileCallbackInterfaces); 111 setNewCrossProfileTests( Collection<ValidatorCrossProfileTestInfo> newCrossProfileTests)112 public abstract Builder setNewCrossProfileTests( 113 Collection<ValidatorCrossProfileTestInfo> newCrossProfileTests); 114 setNewCustomParcelableWrappers( Collection<TypeElement> newCustomParcelableWrappers)115 public abstract Builder setNewCustomParcelableWrappers( 116 Collection<TypeElement> newCustomParcelableWrappers); 117 setNewCustomFutureWrappers( Collection<TypeElement> newCustomFutureWrappers)118 public abstract Builder setNewCustomFutureWrappers( 119 Collection<TypeElement> newCustomFutureWrappers); 120 build()121 public abstract ValidatorContext build(); 122 } 123 } 124