blob: 2f098e2821014346c6dd38eb06dcb9a099670bea [file] [log] [blame]
Felipe Leme1cdf5fb2017-11-22 15:44:46 -08001/*
2 * Copyright (C) 2017 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
17package android.service.autofill;
18
19import static android.view.autofill.Helper.sDebug;
20
21import android.annotation.NonNull;
22import android.os.Parcel;
23import android.os.Parcelable;
24
25import com.android.internal.util.Preconditions;
26
27/**
28 * Validator used to implement a {@code NOT} logical operation.
29 *
30 * @hide
31 */
32final class NegationValidator extends InternalValidator {
33 @NonNull private final InternalValidator mValidator;
34
35 NegationValidator(@NonNull InternalValidator validator) {
36 mValidator = Preconditions.checkNotNull(validator);
37 }
38
39 @Override
40 public boolean isValid(@NonNull ValueFinder finder) {
41 return !mValidator.isValid(finder);
42 }
43
44 /////////////////////////////////////
45 // Object "contract" methods. //
46 /////////////////////////////////////
47 @Override
48 public String toString() {
49 if (!sDebug) return super.toString();
50
51 return "NegationValidator: [validator=" + mValidator + "]";
52 }
53
54 /////////////////////////////////////
55 // Parcelable "contract" methods. //
56 /////////////////////////////////////
57 @Override
58 public int describeContents() {
59 return 0;
60 }
61
62 @Override
63 public void writeToParcel(Parcel dest, int flags) {
64 dest.writeParcelable(mValidator, flags);
65 }
66
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070067 public static final @android.annotation.NonNull Parcelable.Creator<NegationValidator> CREATOR =
Felipe Leme1cdf5fb2017-11-22 15:44:46 -080068 new Parcelable.Creator<NegationValidator>() {
69 @Override
70 public NegationValidator createFromParcel(Parcel parcel) {
71 return new NegationValidator(parcel.readParcelable(null));
72 }
73
74 @Override
75 public NegationValidator[] newArray(int size) {
76 return new NegationValidator[size];
77 }
78 };
79}