1 /* 2 * Copyright (C) 2021 Square, Inc. 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.squareup.moshi.kotlin.codegen.api 17 18 import com.squareup.kotlinpoet.ClassName 19 20 @InternalMoshiCodegenApi 21 public object Options { 22 /** 23 * This processing option can be specified to have a `@Generated` annotation 24 * included in the generated code. It is not encouraged unless you need it for static analysis 25 * reasons and not enabled by default. 26 * 27 * Note that this can only be one of the following values: 28 * * `"javax.annotation.processing.Generated"` (JRE 9+) 29 * * `"javax.annotation.Generated"` (JRE <9) 30 */ 31 public const val OPTION_GENERATED: String = "moshi.generated" 32 33 /** 34 * This boolean processing option can disable proguard rule generation. 35 * Normally, this is not recommended unless end-users build their own JsonAdapter look-up tool. 36 * This is enabled by default. 37 */ 38 public const val OPTION_GENERATE_PROGUARD_RULES: String = "moshi.generateProguardRules" 39 40 /** 41 * This boolean processing option controls whether or not Moshi will directly instantiate 42 * JsonQualifier annotations in Kotlin 1.6+. Note that this is enabled by default in Kotlin 1.6 43 * but can be disabled to restore the legacy behavior of storing annotations on generated adapter 44 * fields and looking them up reflectively. 45 */ 46 public const val OPTION_INSTANTIATE_ANNOTATIONS: String = "moshi.instantiateAnnotations" 47 48 public val POSSIBLE_GENERATED_NAMES: Map<String, ClassName> = arrayOf( 49 ClassName("javax.annotation.processing", "Generated"), 50 ClassName("javax.annotation", "Generated") <lambda>null51 ).associateBy { it.canonicalName } 52 } 53