FileDocCategorySizeDatePackage
ValueObject.javaAPI DocExample710Thu Nov 08 00:23:48 GMT 2001com.ora.rmibook.chapter7

ValueObject.java

package com.ora.rmibook.chapter7;


import java.io.*;


public abstract class ValueObject implements Serializable {
    private String _stringifiedRepresentation;
    private boolean _alreadyHashed;
    private int _hashCode;

    public ValueObject(String stringifiedRepresentation) {
        _stringifiedRepresentation = stringifiedRepresentation;
        _alreadyHashed = false;
    }

    public String toString() {
        return _stringifiedRepresentation;
    }

    public int hashCode() {
        if (false == _alreadyHashed) {
            _hashCode = _stringifiedRepresentation.hashCode();
            _alreadyHashed = true;
        }
        return _hashCode;
    }
}