URLNotification.java

  1. /*
  2.  * URLNotification
  3.  */
  4. package gov.usgs.earthquake.distribution;

  5. import gov.usgs.earthquake.product.ProductId;
  6. import java.net.URL;
  7. import java.util.Date;

  8. /**
  9.  * A URLNotification represents a product that is available via a URL.
  10.  */
  11. public class URLNotification extends DefaultNotification {

  12.     /** Location where product is available. */
  13.     private final URL productURL;

  14.     /**
  15.      * Construct a URLNotification.
  16.      *
  17.      * @param id
  18.      *            which product is available.
  19.      * @param expirationDate
  20.      *            how long the product is available.
  21.      * @param trackerURL
  22.      *            where to send status updates.
  23.      * @param productURL
  24.      *            where product is available.
  25.      */
  26.     public URLNotification(ProductId id, Date expirationDate, URL trackerURL,
  27.             URL productURL) {
  28.         super(id, expirationDate, trackerURL);
  29.         this.productURL = productURL;
  30.     }

  31.     /**
  32.      * @return Location where this product can be downloaded.
  33.      */
  34.     public URL getProductURL() {
  35.         return productURL;
  36.     }

  37.     /** A comparison method to see if two notifications are equal. */
  38.     public boolean equals(Notification that) {
  39.         return (that instanceof URLNotification
  40.                 && getExpirationDate().equals(that.getExpirationDate())
  41.                 && getProductId().equals(that.getProductId())
  42.                 && (
  43.                     (getTrackerURL() == null && that.getTrackerURL() == null)
  44.                     || getTrackerURL().equals(that.getTrackerURL()))
  45.                 && (
  46.                     (getProductURL() == null
  47.                         && ((URLNotification) that).getProductURL() == null)
  48.                     || getProductURL().equals(((URLNotification) that).getProductURL())));
  49.     }

  50. }