1 /* 2 * Copyright 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 androidx.appsearch.safeparcel.stub; 18 19 import android.os.Parcel; 20 import android.os.Parcelable; 21 22 import androidx.annotation.RestrictTo; 23 import androidx.appsearch.safeparcel.SafeParcelable; 24 25 import org.jspecify.annotations.NonNull; 26 27 /** 28 * An abstract class providing a default {@link #writeToParcel(SafeParcelable, Parcel, int)} to 29 * throw {@link UnsupportedOperationException}. 30 * 31 * <p>All the stub Creator classes in the package can extend this as the parent class, so they 32 * don't need to implement {@code writeToParcel} individually. 33 */ 34 // @exportToFramework:skipFile() 35 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) 36 abstract class AbstractCreator<T> implements Parcelable.Creator<T> { 37 @Override createFromParcel(Parcel var1)38 public T createFromParcel(Parcel var1) { 39 // This is here only for code sync purpose. 40 throw new UnsupportedOperationException("createFromParcel is not implemented and should " 41 + "not be used."); 42 } 43 44 @Override newArray(int var1)45 public T[] newArray(int var1) { 46 // This is here only for code sync purpose. 47 throw new UnsupportedOperationException("newArray is not implemented and should " 48 + "not be used."); 49 } 50 writeToParcel( @onNull SafeParcelable safeParcelable, @NonNull Parcel parcel, int flags)51 public static void writeToParcel( 52 @NonNull SafeParcelable safeParcelable, 53 @NonNull Parcel parcel, 54 int flags) { 55 // This is here only for code sync purpose. 56 throw new UnsupportedOperationException( 57 "writeToParcel is not implemented and should not be used."); 58 } 59 } 60