1 /* 2 * Copyright (C) 2019 The Android Open Source Project 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 17 package android.processor.compat.changeid; 18 19 /** 20 * Simple data class that represents a change, built from the code annotations. 21 */ 22 final class Change { 23 final Long id; 24 final String name; 25 final boolean disabled; 26 final boolean loggingOnly; 27 final Integer enabledAfter; 28 final String description; 29 /** 30 * Package name that the change is defined in. 31 */ 32 final String javaPackage; 33 /** 34 * Name of the class within it's package that the change is defined in. 35 */ 36 final String className; 37 /** 38 * Fully qualified class name (including the package) that the change is defined in. 39 */ 40 final String qualifiedClass; 41 /** 42 * Source position, in the form path/to/File.java:line 43 */ 44 final String sourcePosition; 45 Change(Long id, String name, boolean disabled, boolean loggingOnly, Integer enabledAfter, String description, String javaPackage, String className, String qualifiedClass, String sourcePosition)46 Change(Long id, String name, boolean disabled, boolean loggingOnly, Integer enabledAfter, 47 String description, String javaPackage, String className, String qualifiedClass, 48 String sourcePosition) { 49 this.id = id; 50 this.name = name; 51 this.disabled = disabled; 52 this.loggingOnly = loggingOnly; 53 this.enabledAfter = enabledAfter; 54 this.description = description; 55 this.javaPackage = javaPackage; 56 this.className = className; 57 this.qualifiedClass = qualifiedClass; 58 this.sourcePosition = sourcePosition; 59 } 60 61 public static class Builder { 62 Long id; 63 String name; 64 boolean disabled; 65 boolean loggingOnly; 66 Integer enabledAfter; 67 String description; 68 String javaPackage; 69 String javaClass; 70 String qualifiedClass; 71 String sourcePosition; 72 Builder()73 Builder() { 74 } 75 id(long id)76 public Builder id(long id) { 77 this.id = id; 78 return this; 79 } 80 name(String name)81 public Builder name(String name) { 82 this.name = name; 83 return this; 84 } 85 disabled()86 public Builder disabled() { 87 this.disabled = true; 88 return this; 89 } 90 loggingOnly()91 public Builder loggingOnly() { 92 this.loggingOnly = true; 93 return this; 94 } 95 enabledAfter(int sdkVersion)96 public Builder enabledAfter(int sdkVersion) { 97 this.enabledAfter = sdkVersion; 98 return this; 99 } 100 description(String description)101 public Builder description(String description) { 102 this.description = description; 103 return this; 104 } 105 javaPackage(String javaPackage)106 public Builder javaPackage(String javaPackage) { 107 this.javaPackage = javaPackage; 108 return this; 109 } 110 javaClass(String javaClass)111 public Builder javaClass(String javaClass) { 112 this.javaClass = javaClass; 113 return this; 114 } 115 qualifiedClass(String className)116 public Builder qualifiedClass(String className) { 117 this.qualifiedClass = className; 118 return this; 119 } 120 sourcePosition(String sourcePosition)121 public Builder sourcePosition(String sourcePosition) { 122 this.sourcePosition = sourcePosition; 123 return this; 124 } 125 build()126 public Change build() { 127 return new Change(id, name, disabled, loggingOnly, enabledAfter, description, 128 javaPackage, javaClass, qualifiedClass, sourcePosition); 129 } 130 } 131 } 132