Debian Codegraph @

core/java/android/nfc/AvailableNfcAntenna.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2015 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.nfc;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23
24 /**
25 * Represents a single available Nfc antenna
26 * on an Android device.
27 */
28 public final class AvailableNfcAntenna implements Parcelable {
29 /**
30 * Location of the antenna on the Y axis in millimeters.
31 * 0 is the bottom-left when the user is facing the screen
32 * and the device orientation is Portrait.
33 */
34 private final int mLocationX;
35 /**
36 * Location of the antenna on the Y axis in millimeters.
37 * 0 is the bottom-left when the user is facing the screen
38 * and the device orientation is Portrait.
39 */
40 private final int mLocationY;
41
42 public AvailableNfcAntenna(int locationX, int locationY) {
43 this.mLocationX = locationX;
44 this.mLocationY = locationY;
45 }
46
47 /**
48 * Location of the antenna on the X axis in millimeters.
49 * 0 is the bottom-left when the user is facing the screen
50 * and the device orientation is Portrait.
51 */
52 public int getLocationX() {
53 return mLocationX;
54 }
55
56 /**
57 * Location of the antenna on the Y axis in millimeters.
58 * 0 is the bottom-left when the user is facing the screen
59 * and the device orientation is Portrait.
60 */
61 public int getLocationY() {
62 return mLocationY;
63 }
64
65 private AvailableNfcAntenna(Parcel in) {
66 this.mLocationX = in.readInt();
67 this.mLocationY = in.readInt();
68 }
69
70 public static final @android.annotation.NonNull Parcelable.Creator<AvailableNfcAntenna>
71 CREATOR = new Parcelable.Creator<AvailableNfcAntenna>() {
72 @Override
73 public AvailableNfcAntenna createFromParcel(Parcel in) {
74 return new AvailableNfcAntenna(in);
75 }
76
77 @Override
78 public AvailableNfcAntenna[] newArray(int size) {
79 return new AvailableNfcAntenna[size];
80 }
81 };
82
83 @Override
84 public int describeContents() {
85 return 0;
86 }
87
88 @Override
89 public void writeToParcel(@NonNull Parcel dest, int flags) {
90 dest.writeInt(mLocationX);
91 dest.writeInt(mLocationY);
92 }
93
94 @Override
95 public int hashCode() {
96 final int prime = 31;
97 int result = 1;
98 result = prime * result + mLocationX;
99 result = prime * result + mLocationY;
100 return result;
101 }
102
103 /**
104 * Returns true if the specified AvailableNfcAntenna contains
105 * identical specifications.
106 */
107 @Override
108 public boolean equals(@Nullable Object obj) {
109 if (this == obj) return true;
110 if (obj == null) return false;
111 if (getClass() != obj.getClass()) return false;
112 AvailableNfcAntenna other = (AvailableNfcAntenna) obj;
113 if (this.mLocationX != other.mLocationX) return false;
114 return this.mLocationY == other.mLocationY;
115 }
116
117 @Override
118 public String toString() {
119 return "AvailableNfcAntenna " + "x: " + mLocationX + " y: " + mLocationY;
120 }
121 }