1 /* 2 * Copyright 2018 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.value.processor; 17 18 import com.google.common.collect.ImmutableSet; 19 import com.google.escapevelocity.Template; 20 import java.util.Map; 21 22 /** 23 * The variables to substitute into the autooneof.vm template. 24 * 25 * @author emcmanus@google.com (Éamonn McManus) 26 */ 27 @SuppressWarnings("unused") // the fields in this class are only read via reflection 28 class AutoOneOfTemplateVars extends AutoValueishTemplateVars { 29 /** 30 * The properties defined by the parent class's abstract methods. The elements of this set are in 31 * the same order as the original abstract method declarations in the AutoOneOf class. 32 */ 33 ImmutableSet<AutoOneOfProcessor.Property> props; 34 35 /** The simple name of the generated class. */ 36 String generatedClass; 37 38 /** The encoded name of the "kind" enum class. */ 39 String kindType; 40 41 /** The name of the method that gets the kind of the current {@code @AutoOneOf} instance. */ 42 String kindGetter; 43 44 /** Maps property names like {@code dog} to enum constants like {@code DOG}. */ 45 Map<String, String> propertyToKind; 46 47 /** True if this {@code @AutoOneOf} class is Serializable. */ 48 Boolean serializable; 49 50 private static final Template TEMPLATE = parsedTemplateForResource("autooneof.vm"); 51 52 @Override parsedTemplate()53 Template parsedTemplate() { 54 return TEMPLATE; 55 } 56 } 57