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 com.android.federatedcompute.services.common; 18 19 import com.android.ondevicepersonalization.internal.util.DataClass; 20 21 /** A constraint on the task when to run again. */ 22 @DataClass(genBuilder = true, genEqualsHashCode = true) 23 public class TaskRetry { 24 private final long mMinDelay; 25 private final long mMaxDelay; 26 27 // Code below generated by codegen v1.0.23. 28 // 29 // DO NOT MODIFY! 30 // CHECKSTYLE:OFF Generated code 31 // 32 // To regenerate run: 33 // $ codegen 34 // $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/federatedcompute/src/com/android/federatedcompute/services/common/TaskRetry.java 35 // 36 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 37 // Settings > Editor > Code Style > Formatter Control 38 // @formatter:off 39 40 @DataClass.Generated.Member TaskRetry(long minDelay, long maxDelay)41 /* package-private */ TaskRetry(long minDelay, long maxDelay) { 42 this.mMinDelay = minDelay; 43 this.mMaxDelay = maxDelay; 44 45 // onConstructed(); // You can define this method to get a callback 46 } 47 48 @DataClass.Generated.Member getMinDelay()49 public long getMinDelay() { 50 return mMinDelay; 51 } 52 53 @DataClass.Generated.Member getMaxDelay()54 public long getMaxDelay() { 55 return mMaxDelay; 56 } 57 58 @Override 59 @DataClass.Generated.Member equals(@ndroid.annotation.Nullable Object o)60 public boolean equals(@android.annotation.Nullable Object o) { 61 // You can override field equality logic by defining either of the methods like: 62 // boolean fieldNameEquals(TaskRetry other) { ... } 63 // boolean fieldNameEquals(FieldType otherValue) { ... } 64 65 if (this == o) return true; 66 if (o == null || getClass() != o.getClass()) return false; 67 @SuppressWarnings("unchecked") 68 TaskRetry that = (TaskRetry) o; 69 //noinspection PointlessBooleanExpression 70 return true && mMinDelay == that.mMinDelay && mMaxDelay == that.mMaxDelay; 71 } 72 73 @Override 74 @DataClass.Generated.Member hashCode()75 public int hashCode() { 76 // You can override field hashCode logic by defining methods like: 77 // int fieldNameHashCode() { ... } 78 79 int _hash = 1; 80 _hash = 31 * _hash + Long.hashCode(mMinDelay); 81 _hash = 31 * _hash + Long.hashCode(mMaxDelay); 82 return _hash; 83 } 84 85 /** A builder for {@link TaskRetry} */ 86 @SuppressWarnings("WeakerAccess") 87 @DataClass.Generated.Member 88 public static class Builder { 89 90 private long mMinDelay; 91 private long mMaxDelay; 92 93 private long mBuilderFieldsSet = 0L; 94 Builder()95 public Builder() {} 96 97 @DataClass.Generated.Member setMinDelay(long value)98 public @android.annotation.NonNull Builder setMinDelay(long value) { 99 checkNotUsed(); 100 mBuilderFieldsSet |= 0x1; 101 mMinDelay = value; 102 return this; 103 } 104 105 @DataClass.Generated.Member setMaxDelay(long value)106 public @android.annotation.NonNull Builder setMaxDelay(long value) { 107 checkNotUsed(); 108 mBuilderFieldsSet |= 0x2; 109 mMaxDelay = value; 110 return this; 111 } 112 113 /** Builds the instance. This builder should not be touched after calling this! */ build()114 public @android.annotation.NonNull TaskRetry build() { 115 checkNotUsed(); 116 mBuilderFieldsSet |= 0x4; // Mark builder used 117 118 TaskRetry o = new TaskRetry(mMinDelay, mMaxDelay); 119 return o; 120 } 121 checkNotUsed()122 private void checkNotUsed() { 123 if ((mBuilderFieldsSet & 0x4) != 0) { 124 throw new IllegalStateException( 125 "This Builder should not be reused. Use a new Builder instance instead"); 126 } 127 } 128 } 129 130 // @formatter:on 131 // End of generated code 132 133 } 134