| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.service.autofill; |
| 18 |
|
| 19 |
import static android.view.autofill.Helper.sDebug; |
| 20 |
|
| 21 |
import android.annotation.NonNull; |
| 22 |
import android.os.Parcel; |
| 23 |
import android.os.Parcelable; |
| 24 |
import android.util.Log; |
| 25 |
|
| 26 |
import com.android.internal.util.Preconditions; |
| 27 |
|
| 28 |
import java.util.Arrays; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
final class RequiredValidators extends InternalValidator { |
| 39 |
|
| 40 |
private static final String TAG = "RequiredValidators"; |
| 41 |
|
| 42 |
@NonNull private final InternalValidator[] mValidators; |
| 43 |
|
| 44 |
RequiredValidators(@NonNull InternalValidator[] validators) { |
| 45 |
mValidators = Preconditions.checkArrayElementsNotNull(validators, "validators"); |
| 46 |
} |
| 47 |
|
| 48 |
@Override |
| 49 |
public boolean isValid(@NonNull ValueFinder finder) { |
| 50 |
for (InternalValidator validator : mValidators) { |
| 51 |
final boolean valid = validator.isValid(finder); |
| 52 |
if (sDebug) Log.d(TAG, "isValid(" + validator + "): " + valid); |
| 53 |
if (!valid) return false; |
| 54 |
} |
| 55 |
return true; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
@Override |
| 62 |
public String toString() { |
| 63 |
if (!sDebug) return super.toString(); |
| 64 |
|
| 65 |
return new StringBuilder("RequiredValidators: [validators=") |
| 66 |
.append(Arrays.toString(mValidators)) |
| 67 |
.append("]") |
| 68 |
.toString(); |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
@Override |
| 75 |
public int describeContents() { |
| 76 |
return 0; |
| 77 |
} |
| 78 |
|
| 79 |
@Override |
| 80 |
public void writeToParcel(Parcel dest, int flags) { |
| 81 |
dest.writeParcelableArray(mValidators, flags); |
| 82 |
} |
| 83 |
|
| 84 |
public static final @android.annotation.NonNull Parcelable.Creator<RequiredValidators> CREATOR = |
| 85 |
new Parcelable.Creator<RequiredValidators>() { |
| 86 |
@Override |
| 87 |
public RequiredValidators createFromParcel(Parcel parcel) { |
| 88 |
return new RequiredValidators(parcel |
| 89 |
.readParcelableArray(null, InternalValidator.class)); |
| 90 |
} |
| 91 |
|
| 92 |
@Override |
| 93 |
public RequiredValidators[] newArray(int size) { |
| 94 |
return new RequiredValidators[size]; |
| 95 |
} |
| 96 |
}; |
| 97 |
} |