| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| ca.spaz.cron.user.UserMetrics | 
 | 
 | 
| 1 |  /* | |
| 2 |   ******************************************************************************* | |
| 3 |   * Copyright (c) 2005 Chris Rose and AIMedia | |
| 4 |   * All rights reserved. UserMetrics and the accompanying materials | |
| 5 |   * are made available under the terms of the Common Public License v1.0 | |
| 6 |   * which accompanies this distribution, and is available at | |
| 7 |   * http://www.eclipse.org/legal/cpl-v10.html | |
| 8 |   *  | |
| 9 |   * Contributors: | |
| 10 |   *     Chris Rose | |
| 11 |   *******************************************************************************/ | |
| 12 |  package ca.spaz.cron.user; | |
| 13 | ||
| 14 |  import java.util.*; | |
| 15 | ||
| 16 | public class UserMetrics implements Comparable { | |
| 17 | ||
| 18 |     private Date date; | |
| 19 |     private List metricList; | |
| 20 | ||
| 21 |     /** | |
| 22 |      * Create a new <code>UserMetrics</code> object with the current time | |
| 23 |      * as its date; | |
| 24 |      */ | |
| 25 |     public UserMetrics() { | |
| 26 | 0 |        this(new Date()); | 
| 27 | 0 |     } | 
| 28 | ||
| 29 |     /** | |
| 30 |      * Create a new <code>UserMetrics</code> object with the specified time | |
| 31 |      * as its date; | |
| 32 |      * @param date The time of this set of metrics. | |
| 33 |      */ | |
| 34 | 0 |     public UserMetrics(Date date) { | 
| 35 | 0 |        if (null == date) { | 
| 36 | 0 |           throw new IllegalArgumentException("Must provide a Date"); | 
| 37 | } | |
| 38 | 0 |        this.date = date; | 
| 39 | 0 |     } | 
| 40 | ||
| 41 |     /** | |
| 42 |      * Get the date of this set of metrics. | |
| 43 |      * @return a <code>Date</code> object for the metrics. | |
| 44 |      */ | |
| 45 |     public Date getMetricDate() { | |
| 46 | 0 |        return new Date(date.getTime()); | 
| 47 | } | |
| 48 | ||
| 49 |     /** | |
| 50 |      * Get a list of the metrics in this object.  The list will not be modifiable. | |
| 51 |      * @return a <code>List</code> of metrics for this object. | |
| 52 |      */ | |
| 53 |     public List getMetrics() { | |
| 54 | 0 |        return Collections.unmodifiableList(getMetricList()); | 
| 55 | } | |
| 56 | ||
| 57 |     /** | |
| 58 |      * Add a new metric to the list. | |
| 59 |      * @param metric the <code>Metric</code> to add. | |
| 60 |      */ | |
| 61 | public void addMetric(Metric metric) { | |
| 62 | 0 |        getMetricList().add(metric); | 
| 63 | 0 |     } | 
| 64 | ||
| 65 |     /** | |
| 66 |      * Remove a metric from the list. | |
| 67 |      * @param metric the <code>Metric</code> to remove. | |
| 68 |      */ | |
| 69 | public void removeMetric(Metric metric) { | |
| 70 | 0 |        getMetricList().remove(metric); | 
| 71 | 0 |     } | 
| 72 | ||
| 73 |     private List getMetricList() { | |
| 74 | 0 |        if (null == metricList) { | 
| 75 | 0 |           metricList = new ArrayList(); | 
| 76 | } | |
| 77 | 0 |        return metricList; | 
| 78 | } | |
| 79 | ||
| 80 |     /* (non-Javadoc) | |
| 81 |      * @see java.lang.Comparable#compareTo(java.lang.Object) | |
| 82 |      */ | |
| 83 | public int compareTo(Object arg0) { | |
| 84 | 0 |        return date.compareTo((Date) arg0); | 
| 85 | } | |
| 86 | ||
| 87 |     /* (non-Javadoc) | |
| 88 |      * @see java.lang.Object#equals(java.lang.Object) | |
| 89 |      */ | |
| 90 | public boolean equals(Object o) { | |
| 91 | 0 |        return date.equals(o); | 
| 92 | } | |
| 93 | ||
| 94 |     /* (non-Javadoc) | |
| 95 |      * @see java.lang.Object#hashCode() | |
| 96 |      */ | |
| 97 | public int hashCode() { | |
| 98 | 0 |        return date.hashCode(); | 
| 99 | } | |
| 100 | ||
| 101 | } | 
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |