Evaluating Software Design Patterns
— the "Gang of Four" patterns implemented in Java 6

dk.rode.thesis.meta.reflect.proxy
Class ProxyFactory.Key

java.lang.Object
  extended by dk.rode.thesis.meta.reflect.proxy.ProxyFactory.Key
Enclosing class:
ProxyFactory

private static final class ProxyFactory.Key
extends Object

A key adapts a proxy to ensure consistent hashCode() and equals(Object) behaviour when proxies are stored internally by proxy factories, because proxies may override hashCode and equals(Object) in unpredictable ways.

Author:
Gunni Rode / rode.dk

Field Summary
private  ProxyFactory.Proxy proxy
          The actual proxy object.
 
Constructor Summary
private ProxyFactory.Key(ProxyFactory.Proxy proxy)
          Constructor.
 
Method Summary
 boolean equals(Object object)
          True if object is a key representing the same exact proxy instance as the proxy represented by this key.
 int hashCode()
          Returns the hash code of this key.
 String toString()
          Returns the string representation of this key.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

proxy

private final ProxyFactory.Proxy proxy
The actual proxy object.

Never null.

Constructor Detail

ProxyFactory.Key

private ProxyFactory.Key(ProxyFactory.Proxy proxy)
Constructor.

Parameters:
proxy - The proxy to store; never null.
Method Detail

equals

public boolean equals(Object object)
True if object is a key representing the same exact proxy instance as the proxy represented by this key.

Overrides:
equals in class Object
Parameters:
object - The object to test; can be null.
Returns:
True if equal, false if not.

hashCode

public int hashCode()
Returns the hash code of this key.

Overrides:
hashCode in class Object
Returns:
The hash code.

toString

public String toString()
Returns the string representation of this key.

Overrides:
toString in class Object
Returns:
The string representation; never null.

Gunni Rode / rode.dk

Feel free to use and/or modify the Java 6 source code developed for this thesis AT YOUR OWN RISK, but note that the source code comes WITHOUT ANY — and I do mean WITHOUT ANY — form of warranty WHAT SO EVER!

The original thesis and source code are available at rode.dk/thesis.