Debian Codegraph @

core/java/android/net/StringNetworkSpecifier.java

raw symbols SCIP
1 /*
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
17 package android.net;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 import android.text.TextUtils;
24
25 import com.android.internal.util.Preconditions;
26
27 import java.util.Objects;
28
29 /** @hide */
30 public final class StringNetworkSpecifier extends NetworkSpecifier implements Parcelable {
31 /**
32 * Arbitrary string used to pass (additional) information to the network factory.
33 */
34 @NonNull
35 public final String specifier;
36
37 public StringNetworkSpecifier(@NonNull String specifier) {
38 Preconditions.checkStringNotEmpty(specifier);
39 this.specifier = specifier;
40 }
41
42 /** @hide */
43 @Override
44 public boolean canBeSatisfiedBy(NetworkSpecifier other) {
45 return equals(other);
46 }
47
48 @Override
49 public boolean equals(@Nullable Object o) {
50 if (!(o instanceof StringNetworkSpecifier)) return false;
51 return TextUtils.equals(specifier, ((StringNetworkSpecifier) o).specifier);
52 }
53
54 @Override
55 public int hashCode() {
56 return Objects.hashCode(specifier);
57 }
58
59 @Override
60 public String toString() {
61 return specifier;
62 }
63
64 @Override
65 public int describeContents() {
66 return 0;
67 }
68
69 @Override
70 public void writeToParcel(@NonNull Parcel dest, int flags) {
71 dest.writeString(specifier);
72 }
73
74 public static final @NonNull Parcelable.Creator<StringNetworkSpecifier> CREATOR =
75 new Parcelable.Creator<StringNetworkSpecifier>() {
76 public StringNetworkSpecifier createFromParcel(Parcel in) {
77 return new StringNetworkSpecifier(in.readString());
78 }
79 public StringNetworkSpecifier[] newArray(int size) {
80 return new StringNetworkSpecifier[size];
81 }
82 };
83 }