package janet.services.shared; import janet.services.*; /** * IntUpperBound.java * @author Peter Cappello * @version 1 */ public class IntUpperBound implements Shared { private Integer shared; /** Constructor a IntUpperBound from the int argument. * @param shared The int value to be shared. */ public IntUpperBound( int shared ) { this.shared = new Integer( shared ); } /* begin implementation of Shared */ /** Returns a reference to the shared Integer Object. * @return a reference to the shared Integer Object. */ public synchronized Object get() { return shared; } /** Sets the value if this IntUpperBound to the argument Shared Object, * if the argument is newer (see isNewer). * @return true if & only if the argument Shared Object is newer. * @param shared The Shared Object whose value is proposed as newer. */ public synchronized boolean set(Shared shared) { if ( isNewer( shared ) ) { this.shared = (Integer) shared.get(); return true; } else { return false; } } /* end implementation of Shared */ /** This method operationally defines the semantics of newer. * @return true if & only if the argument Shared Object is newer. * @param shared The Shared Object whose value is proposed as newer. */ public boolean isNewer( Shared shared ) { return this.shared.intValue() > ( (Integer) shared.get() ).intValue(); } }