Aurimas Liutikas | bcfbe3a | 2023-10-30 15:25:21 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2023 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.ondevicepersonalization; |
| 18 | |
| 19 | import android.annotation.Nullable; |
| 20 | |
| 21 | import com.android.ondevicepersonalization.internal.util.DataClass; |
| 22 | |
| 23 | /** @hide */ |
| 24 | @DataClass(genBuilder = true, genEqualsHashCode = true) |
| 25 | public class EventUrlOptions { |
| 26 | /** Return a 1x1 blank GIF image. */ |
| 27 | public static final int RESPONSE_TYPE_1X1_IMAGE = 1; |
| 28 | |
| 29 | /** Redirect to the provided destination URL. */ |
| 30 | public static final int RESPONSE_TYPE_REDIRECT = 2; |
| 31 | |
| 32 | /** Return a 204 No Content HTTP response. */ |
| 33 | public static final int RESPONSE_TYPE_NO_CONTENT = 3; |
| 34 | |
| 35 | /** The expected type of response for this URL. */ |
| 36 | @ResponseType |
| 37 | private final int mResponseType; |
| 38 | |
| 39 | /** The destination URL to redirect to, if the response type is RESPONSE_TYPE_REDIRECT. */ |
| 40 | @Nullable private final String mDestinationUrl; |
| 41 | |
| 42 | |
| 43 | |
| 44 | // Code below generated by codegen v1.0.23. |
| 45 | // |
| 46 | // DO NOT MODIFY! |
| 47 | // CHECKSTYLE:OFF Generated code |
| 48 | // |
| 49 | // To regenerate run: |
| 50 | // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/EventUrlOptions.java |
| 51 | // |
| 52 | // To exclude the generated code from IntelliJ auto-formatting enable (one-time): |
| 53 | // Settings > Editor > Code Style > Formatter Control |
| 54 | //@formatter:off |
| 55 | |
| 56 | |
| 57 | @android.annotation.IntDef(prefix = "RESPONSE_TYPE_", value = { |
| 58 | RESPONSE_TYPE_1X1_IMAGE, |
| 59 | RESPONSE_TYPE_REDIRECT, |
| 60 | RESPONSE_TYPE_NO_CONTENT |
| 61 | }) |
| 62 | @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) |
| 63 | @DataClass.Generated.Member |
| 64 | public @interface ResponseType {} |
| 65 | |
| 66 | @DataClass.Generated.Member |
| 67 | public static String responseTypeToString(@ResponseType int value) { |
| 68 | switch (value) { |
| 69 | case RESPONSE_TYPE_1X1_IMAGE: |
| 70 | return "RESPONSE_TYPE_1X1_IMAGE"; |
| 71 | case RESPONSE_TYPE_REDIRECT: |
| 72 | return "RESPONSE_TYPE_REDIRECT"; |
| 73 | case RESPONSE_TYPE_NO_CONTENT: |
| 74 | return "RESPONSE_TYPE_NO_CONTENT"; |
| 75 | default: return Integer.toHexString(value); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | @DataClass.Generated.Member |
| 80 | /* package-private */ EventUrlOptions( |
| 81 | @ResponseType int responseType, |
| 82 | @Nullable String destinationUrl) { |
| 83 | this.mResponseType = responseType; |
| 84 | |
| 85 | if (!(mResponseType == RESPONSE_TYPE_1X1_IMAGE) |
| 86 | && !(mResponseType == RESPONSE_TYPE_REDIRECT) |
| 87 | && !(mResponseType == RESPONSE_TYPE_NO_CONTENT)) { |
| 88 | throw new java.lang.IllegalArgumentException( |
| 89 | "responseType was " + mResponseType + " but must be one of: " |
| 90 | + "RESPONSE_TYPE_1X1_IMAGE(" + RESPONSE_TYPE_1X1_IMAGE + "), " |
| 91 | + "RESPONSE_TYPE_REDIRECT(" + RESPONSE_TYPE_REDIRECT + "), " |
| 92 | + "RESPONSE_TYPE_NO_CONTENT(" + RESPONSE_TYPE_NO_CONTENT + ")"); |
| 93 | } |
| 94 | |
| 95 | this.mDestinationUrl = destinationUrl; |
| 96 | |
| 97 | // onConstructed(); // You can define this method to get a callback |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * The expected type of response for this URL. |
| 102 | */ |
| 103 | @DataClass.Generated.Member |
| 104 | public @ResponseType int getResponseType() { |
| 105 | return mResponseType; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * The destination URL to redirect to, if the response type is RESPONSE_TYPE_REDIRECT. |
| 110 | */ |
| 111 | @DataClass.Generated.Member |
| 112 | public @Nullable String getDestinationUrl() { |
| 113 | return mDestinationUrl; |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | @DataClass.Generated.Member |
| 118 | public boolean equals(@Nullable Object o) { |
| 119 | // You can override field equality logic by defining either of the methods like: |
| 120 | // boolean fieldNameEquals(EventUrlOptions other) { ... } |
| 121 | // boolean fieldNameEquals(FieldType otherValue) { ... } |
| 122 | |
| 123 | if (this == o) return true; |
| 124 | if (o == null || getClass() != o.getClass()) return false; |
| 125 | @SuppressWarnings("unchecked") |
| 126 | EventUrlOptions that = (EventUrlOptions) o; |
| 127 | //noinspection PointlessBooleanExpression |
| 128 | return true |
| 129 | && mResponseType == that.mResponseType |
| 130 | && java.util.Objects.equals(mDestinationUrl, that.mDestinationUrl); |
| 131 | } |
| 132 | |
| 133 | @Override |
| 134 | @DataClass.Generated.Member |
| 135 | public int hashCode() { |
| 136 | // You can override field hashCode logic by defining methods like: |
| 137 | // int fieldNameHashCode() { ... } |
| 138 | |
| 139 | int _hash = 1; |
| 140 | _hash = 31 * _hash + mResponseType; |
| 141 | _hash = 31 * _hash + java.util.Objects.hashCode(mDestinationUrl); |
| 142 | return _hash; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * A builder for {@link EventUrlOptions} |
| 147 | */ |
| 148 | @SuppressWarnings("WeakerAccess") |
| 149 | @DataClass.Generated.Member |
| 150 | public static class Builder { |
| 151 | |
| 152 | private @ResponseType int mResponseType; |
| 153 | private @Nullable String mDestinationUrl; |
| 154 | |
| 155 | private long mBuilderFieldsSet = 0L; |
| 156 | |
| 157 | /** |
| 158 | * Creates a new Builder. |
| 159 | */ |
| 160 | public Builder() {} |
| 161 | |
| 162 | /** |
| 163 | * The expected type of response for this URL. |
| 164 | */ |
| 165 | @DataClass.Generated.Member |
| 166 | public @android.annotation.NonNull Builder setResponseType(@ResponseType int value) { |
| 167 | checkNotUsed(); |
| 168 | mBuilderFieldsSet |= 0x1; |
| 169 | mResponseType = value; |
| 170 | return this; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * The destination URL to redirect to, if the response type is RESPONSE_TYPE_REDIRECT. |
| 175 | */ |
| 176 | @DataClass.Generated.Member |
| 177 | public @android.annotation.NonNull Builder setDestinationUrl(@android.annotation.NonNull String value) { |
| 178 | checkNotUsed(); |
| 179 | mBuilderFieldsSet |= 0x2; |
| 180 | mDestinationUrl = value; |
| 181 | return this; |
| 182 | } |
| 183 | |
| 184 | /** Builds the instance. This builder should not be touched after calling this! */ |
| 185 | public @android.annotation.NonNull EventUrlOptions build() { |
| 186 | checkNotUsed(); |
| 187 | mBuilderFieldsSet |= 0x4; // Mark builder used |
| 188 | |
| 189 | EventUrlOptions o = new EventUrlOptions( |
| 190 | mResponseType, |
| 191 | mDestinationUrl); |
| 192 | return o; |
| 193 | } |
| 194 | |
| 195 | private void checkNotUsed() { |
| 196 | if ((mBuilderFieldsSet & 0x4) != 0) { |
| 197 | throw new IllegalStateException( |
| 198 | "This Builder should not be reused. Use a new Builder instance instead"); |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | @DataClass.Generated( |
| 204 | time = 1674079433654L, |
| 205 | codegenVersion = "1.0.23", |
| 206 | sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/EventUrlOptions.java", |
| 207 | inputSignatures = "public static final int RESPONSE_TYPE_1X1_IMAGE\npublic static final int RESPONSE_TYPE_REDIRECT\npublic static final int RESPONSE_TYPE_NO_CONTENT\nprivate final @android.ondevicepersonalization.EventUrlOptions.ResponseType int mResponseType\nprivate final @android.annotation.Nullable java.lang.String mDestinationUrl\nclass EventUrlOptions extends java.lang.Object implements []\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)") |
| 208 | @Deprecated |
| 209 | private void __metadata() {} |
| 210 | |
| 211 | |
| 212 | //@formatter:on |
| 213 | // End of generated code |
| 214 | |
| 215 | } |