Author: [log in to unmask] Date: Sat Mar 14 12:23:53 2015 New Revision: 2448 Log: Add copy constructors. Modified: java/trunk/monitoring-util/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java Modified: java/trunk/monitoring-util/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java ============================================================================= --- java/trunk/monitoring-util/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java (original) +++ java/trunk/monitoring-util/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java Sat Mar 14 12:23:53 2015 @@ -8,14 +8,16 @@ */ public final class SystemStatusImpl implements SystemStatus { + StatusCode code = StatusCode.UNKNOWN; + Subsystem systemName; + String message; + String description; long lastChangedMillis; - String message; + boolean active = true; + boolean clearable; + List<SystemStatusListener> listeners = new ArrayList<SystemStatusListener>(); - final Subsystem systemName; - final String description; - boolean active = true; - final boolean clearable; /** * Fully qualified constructor. @@ -29,6 +31,36 @@ this.clearable = clearable; setLastChangedTime(); SystemStatusRegistry.getSystemStatusRegistery().register(this); + } + + /** + * Copy constructor from implementation class. + * The list of listeners is NOT copied. + * @param status The status to copy. + */ + public SystemStatusImpl(SystemStatusImpl status) { + this.code = status.code; + this.systemName = status.systemName; + this.message = status.message; + this.description = status.description; + this.lastChangedMillis = status.lastChangedMillis; + this.active = status.active; + this.clearable = status.clearable; + } + + /** + * Copy constructor from interface. + * The list of listeners is NOT copied. + * @param status The status to copy. + */ + public SystemStatusImpl(SystemStatus status) { + this.code = status.getStatusCode(); + this.systemName = status.getSubsystem(); + this.message = status.getMessage(); + this.description = status.getDescription(); + this.lastChangedMillis = status.getLastChangedMillis(); + this.active = status.isActive(); + this.clearable = status.isClearable(); } @Override @@ -97,5 +129,5 @@ @Override public boolean isClearable() { return clearable; - } + } }