aa
com.cliffc.aa.util.AbstractEntry< TypeK, TypeV > Class Template Referenceabstract

A simple implementation of java.util.Map.Entry. More...

Inheritance diagram for com.cliffc.aa.util.AbstractEntry< TypeK, TypeV >:
[legend]
Collaboration diagram for com.cliffc.aa.util.AbstractEntry< TypeK, TypeV >:
[legend]

Public Member Functions

 AbstractEntry (final Map.Entry< TypeK, TypeV > e)
 
 AbstractEntry (final TypeK key, final TypeV val)
 
boolean equals (final Object o)
 Equal if the underlying key & value are equal. More...
 
TypeK getKey ()
 Return key. More...
 
TypeV getValue ()
 Return val. More...
 
int hashCode ()
 Compute "key.hashCode() ^ val.hashCode()" More...
 
String toString ()
 Return "key=val" string. More...
 

Protected Attributes

final TypeK _key
 Strongly typed key. More...
 
TypeV _val
 Strongly typed value. More...
 

Static Private Member Functions

static boolean eq (final Object o1, final Object o2)
 

Detailed Description

A simple implementation of java.util.Map.Entry.

Does not implement java.util.Map.Entry#setValue, that is done by users of the class.

Since
1.5
Author
Cliff Click
Parameters
<TypeK>the type of keys maintained by this map
<TypeV>the type of mapped values

Definition at line 15 of file AbstractEntry.java.

Constructor & Destructor Documentation

◆ AbstractEntry() [1/2]

com.cliffc.aa.util.AbstractEntry< TypeK, TypeV >.AbstractEntry ( final TypeK  key,
final TypeV  val 
)

Definition at line 21 of file AbstractEntry.java.

21 { _key = key; _val = val; }

◆ AbstractEntry() [2/2]

com.cliffc.aa.util.AbstractEntry< TypeK, TypeV >.AbstractEntry ( final Map.Entry< TypeK, TypeV >  e)

Definition at line 22 of file AbstractEntry.java.

22 { _key = e.getKey(); _val = e.getValue(); }

Member Function Documentation

◆ eq()

static boolean com.cliffc.aa.util.AbstractEntry< TypeK, TypeV >.eq ( final Object  o1,
final Object  o2 
)
staticprivate

Definition at line 44 of file AbstractEntry.java.

44  {
45  return (o1 == null ? o2 == null : o1.equals(o2));
46  }

Referenced by com.cliffc.aa.util.AbstractEntry< Long, TypeV >.equals().

Here is the caller graph for this function:

◆ equals()

boolean com.cliffc.aa.util.AbstractEntry< TypeK, TypeV >.equals ( final Object  o)

Equal if the underlying key & value are equal.

Definition at line 31 of file AbstractEntry.java.

31  {
32  if (!(o instanceof Map.Entry)) return false;
33  final Map.Entry e = (Map.Entry)o;
34  return eq(_key, e.getKey()) && eq(_val, e.getValue());
35  }

◆ getKey()

TypeK com.cliffc.aa.util.AbstractEntry< TypeK, TypeV >.getKey ( )

Return key.

Definition at line 26 of file AbstractEntry.java.

26 { return _key; }

◆ getValue()

TypeV com.cliffc.aa.util.AbstractEntry< TypeK, TypeV >.getValue ( )

Return val.

Definition at line 28 of file AbstractEntry.java.

28 { return _val; }

◆ hashCode()

int com.cliffc.aa.util.AbstractEntry< TypeK, TypeV >.hashCode ( )

Compute "key.hashCode() ^ val.hashCode()"

Definition at line 38 of file AbstractEntry.java.

38  {
39  return
40  ((_key == null) ? 0 : _key.hashCode()) ^
41  ((_val == null) ? 0 : _val.hashCode());
42  }

◆ toString()

String com.cliffc.aa.util.AbstractEntry< TypeK, TypeV >.toString ( )

Return "key=val" string.

Definition at line 24 of file AbstractEntry.java.

24 { return _key + "=" + _val; }

Member Data Documentation

◆ _key

◆ _val


The documentation for this class was generated from the following file:
com.cliffc.aa.util.AbstractEntry.eq
static boolean eq(final Object o1, final Object o2)
Definition: AbstractEntry.java:44
com.cliffc.aa.util.AbstractEntry._val
TypeV _val
Strongly typed value.
Definition: AbstractEntry.java:19
com.cliffc.aa.util.AbstractEntry._key
final TypeK _key
Strongly typed key.
Definition: AbstractEntry.java:17