FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
OnJava8-Examples/equalshashcode/MapEntry.java at master · xinan-w/OnJava8-Examples · GitHub
xinan-w
/
OnJava8-Examples
Public
forked from
BruceEckel/OnJava8-Examples
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
OnJava8-Examples
/
equalshashcode
/
MapEntry.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
36 lines (35 loc) · 1.03 KB
Breadcrumbs
OnJava8-Examples
/
equalshashcode
/
MapEntry.java
Copy path
File metadata and controls
36 lines (35 loc) · 1.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// equalshashcode/MapEntry.java
// (c)2021 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
// A simple Map.Entry for sample Map implementations
import
java
.
util
.*;
public
class
MapEntry
<
K
,
V
>
implements
Map
.
Entry
<
K
,
V
> {
private
K
key
;
private
V
value
;
public
MapEntry
(
K
key
,
V
value
) {
this
.
key
=
key
;
this
.
value
=
value
;
}
@
Override
public
K
getKey
() {
return
key
; }
@
Override
public
V
getValue
() {
return
value
; }
@
Override
public
V
setValue
(
V
v
) {
V
result
=
value
;
value
=
v
;
return
result
;
}
@
Override
public
int
hashCode
() {
return
Objects
.
hash
(
key
,
value
);
}
@
SuppressWarnings
(
"unchecked"
)
@
Override
public
boolean
equals
(
Object
rval
) {
return
rval
instanceof
MapEntry
&&
Objects
.
equals
(
key
,
((
MapEntry
<
K
,
V
>)
rval
).
getKey
()) &&
Objects
.
equals
(
value
,
((
MapEntry
<
K
,
V
>)
rval
).
getValue
());
}
@
Override
public
String
toString
() {
return
key
+
"="
+
value
;
}
}
Back
|
FazBrowse Home
|
New Git URL