// Path: src/main/java/javapns/devices/Device.java
// public interface Device {
//   /**
//    * An id representing a particular device.
//    * <p>
//    * Note that this is a local reference to the device,
//    * which is not related to the actual device UUID or
//    * other device-specific identification. Most of the
//    * time, this deviceId should be the same as the token.
//    *
//    * @return the device id
//    */
//   String getDeviceId();
// 
//   /**
//    * An id representing a particular device.
//    * <p>
//    * Note that this is a local reference to the device,
//    * which is not related to the actual device UUID or
//    * other device-specific identification. Most of the
//    * time, this deviceId should be the same as the token.
//    *
//    * @param id the device id
//    */
//   void setDeviceId(String id);
// 
//   /**
//    * A device token.
//    *
//    * @return the device token
//    */
//   String getToken();
// 
//   /**
//    * Set the device token
//    *
//    * @param token
//    */
//   void setToken(String token);
// 
//   /**
//    * @return the last register
//    */
//   Timestamp getLastRegister();
// 
//   /**
//    * @param lastRegister the last register
//    */
//   void setLastRegister(Timestamp lastRegister);
// }
// 
// Path: src/main/java/javapns/devices/exceptions/InvalidDeviceTokenFormatException.java
// public class InvalidDeviceTokenFormatException extends Exception {
// 
//   private static final long serialVersionUID = -8571997399252125457L;
// 
//   public InvalidDeviceTokenFormatException(final String message) {
//     super(message);
//   }
// 
//   public InvalidDeviceTokenFormatException(final String token, final String problem) {
//     super(String.format("Device token cannot be parsed, most likely because it contains invalid hexadecimal characters: %s in %s", problem, token));
//   }
// 
// }
// 
// Path: src/main/java/javapns/devices/implementations/basic/BasicDevice.java
// public class BasicDevice implements Device {
// 
//   /*
//    * An id representing a particular device.
//    *
//    * Note that this is a local reference to the device,
//    * which is not related to the actual device UUID or
//    * other device-specific identification. Most of the
//    * time, this deviceId should be the same as the token.
//    */
//   private String deviceId;
// 
//   /* The device token given by Apple Server, hexadecimal form, 64bits length */
//   private String token;
// 
//   /* The last time a device registered */
//   private Timestamp lastRegister;
// 
//   public BasicDevice() {
//     // empty
//   }
// 
//   /**
//    * Default constructor.
//    *
//    * @param token The device token
//    */
//   public BasicDevice(final String token) throws InvalidDeviceTokenFormatException {
//     this(token, true);
//   }
// 
//   private BasicDevice(final String token, final boolean validate) throws InvalidDeviceTokenFormatException {
//     super();
//     this.deviceId = token;
//     this.token = token;
//     try {
//       this.lastRegister = new Timestamp(System.currentTimeMillis());
//     } catch (final Exception e) {
//       // empty
//     }
// 
//     if (validate) {
//       validateTokenFormat(token);
//     }
//   }
// 
//   /**
//    * Constructor
//    *
//    * @param id    The device id
//    * @param token The device token
//    */
//   BasicDevice(final String id, final String token, final Timestamp register) throws InvalidDeviceTokenFormatException {
//     super();
//     this.deviceId = id;
//     this.token = token;
//     this.lastRegister = register;
// 
//     validateTokenFormat(token);
// 
//   }
// 
//   public static void validateTokenFormat(final String token) throws InvalidDeviceTokenFormatException {
//     if (token == null) {
//       throw new InvalidDeviceTokenFormatException("Device Token is null, and not the required 64 bytes...");
//     }
// 
//     if (token.getBytes().length != 64) {
//       throw new InvalidDeviceTokenFormatException("Device Token has a length of [" + token.getBytes().length + "] and not the required 64 bytes!");
//     }
//   }
// 
//   public void validateTokenFormat() throws InvalidDeviceTokenFormatException {
//     validateTokenFormat(token);
//   }
// 
//   /**
//    * Getter
//    *
//    * @return the device id
//    */
//   public String getDeviceId() {
//     return deviceId;
//   }
// 
//   /**
//    * Setter
//    *
//    * @param id the device id
//    */
//   public void setDeviceId(final String id) {
//     this.deviceId = id;
//   }
// 
//   /**
//    * Getter
//    *
//    * @return the device token
//    */
//   public String getToken() {
//     return token;
//   }
// 
//   /**
//    * Setter the device token
//    *
//    * @param token
//    */
//   public void setToken(final String token) {
//     this.token = token;
//   }
// 
//   /**
//    * Getter
//    *
//    * @return the last register
//    */
//   public Timestamp getLastRegister() {
//     return lastRegister;
//   }
// 
//   public void setLastRegister(final Timestamp lastRegister) {
//     this.lastRegister = lastRegister;
//   }
// }


import javapns.devices.Device;
import javapns.devices.exceptions.InvalidDeviceTokenFormatException;
import javapns.devices.implementations.basic.BasicDevice;
package javapns.notification;


/**
 * A one-to-one link between a payload and device.
 * Provides support for a typical payload-per-device scenario.
 *
 * @author Sylvain Pedneault
 */
public class PayloadPerDevice {
  private final Payload payload;
  private final Device device;

// Path: src/main/java/javapns/devices/Device.java
// public interface Device {
//   /**
//    * An id representing a particular device.
//    * <p>
//    * Note that this is a local reference to the device,
//    * which is not related to the actual device UUID or
//    * other device-specific identification. Most of the
//    * time, this deviceId should be the same as the token.
//    *
//    * @return the device id
//    */
//   String getDeviceId();
// 
//   /**
//    * An id representing a particular device.
//    * <p>
//    * Note that this is a local reference to the device,
//    * which is not related to the actual device UUID or
//    * other device-specific identification. Most of the
//    * time, this deviceId should be the same as the token.
//    *
//    * @param id the device id
//    */
//   void setDeviceId(String id);
// 
//   /**
//    * A device token.
//    *
//    * @return the device token
//    */
//   String getToken();
// 
//   /**
//    * Set the device token
//    *
//    * @param token
//    */
//   void setToken(String token);
// 
//   /**
//    * @return the last register
//    */
//   Timestamp getLastRegister();
// 
//   /**
//    * @param lastRegister the last register
//    */
//   void setLastRegister(Timestamp lastRegister);
// }
// 
// Path: src/main/java/javapns/devices/exceptions/InvalidDeviceTokenFormatException.java
// public class InvalidDeviceTokenFormatException extends Exception {
// 
//   private static final long serialVersionUID = -8571997399252125457L;
// 
//   public InvalidDeviceTokenFormatException(final String message) {
//     super(message);
//   }
// 
//   public InvalidDeviceTokenFormatException(final String token, final String problem) {
//     super(String.format("Device token cannot be parsed, most likely because it contains invalid hexadecimal characters: %s in %s", problem, token));
//   }
// 
// }
// 
// Path: src/main/java/javapns/devices/implementations/basic/BasicDevice.java
// public class BasicDevice implements Device {
// 
//   /*
//    * An id representing a particular device.
//    *
//    * Note that this is a local reference to the device,
//    * which is not related to the actual device UUID or
//    * other device-specific identification. Most of the
//    * time, this deviceId should be the same as the token.
//    */
//   private String deviceId;
// 
//   /* The device token given by Apple Server, hexadecimal form, 64bits length */
//   private String token;
// 
//   /* The last time a device registered */
//   private Timestamp lastRegister;
// 
//   public BasicDevice() {
//     // empty
//   }
// 
//   /**
//    * Default constructor.
//    *
//    * @param token The device token
//    */
//   public BasicDevice(final String token) throws InvalidDeviceTokenFormatException {
//     this(token, true);
//   }
// 
//   private BasicDevice(final String token, final boolean validate) throws InvalidDeviceTokenFormatException {
//     super();
//     this.deviceId = token;
//     this.token = token;
//     try {
//       this.lastRegister = new Timestamp(System.currentTimeMillis());
//     } catch (final Exception e) {
//       // empty
//     }
// 
//     if (validate) {
//       validateTokenFormat(token);
//     }
//   }
// 
//   /**
//    * Constructor
//    *
//    * @param id    The device id
//    * @param token The device token
//    */
//   BasicDevice(final String id, final String token, final Timestamp register) throws InvalidDeviceTokenFormatException {
//     super();
//     this.deviceId = id;
//     this.token = token;
//     this.lastRegister = register;
// 
//     validateTokenFormat(token);
// 
//   }
// 
//   public static void validateTokenFormat(final String token) throws InvalidDeviceTokenFormatException {
//     if (token == null) {
//       throw new InvalidDeviceTokenFormatException("Device Token is null, and not the required 64 bytes...");
//     }
// 
//     if (token.getBytes().length != 64) {
//       throw new InvalidDeviceTokenFormatException("Device Token has a length of [" + token.getBytes().length + "] and not the required 64 bytes!");
//     }
//   }
// 
//   public void validateTokenFormat() throws InvalidDeviceTokenFormatException {
//     validateTokenFormat(token);
//   }
// 
//   /**
//    * Getter
//    *
//    * @return the device id
//    */
//   public String getDeviceId() {
//     return deviceId;
//   }
// 
//   /**
//    * Setter
//    *
//    * @param id the device id
//    */
//   public void setDeviceId(final String id) {
//     this.deviceId = id;
//   }
// 
//   /**
//    * Getter
//    *
//    * @return the device token
//    */
//   public String getToken() {
//     return token;
//   }
// 
//   /**
//    * Setter the device token
//    *
//    * @param token
//    */
//   public void setToken(final String token) {
//     this.token = token;
//   }
// 
//   /**
//    * Getter
//    *
//    * @return the last register
//    */
//   public Timestamp getLastRegister() {
//     return lastRegister;
//   }
// 
//   public void setLastRegister(final Timestamp lastRegister) {
//     this.lastRegister = lastRegister;
//   }
// }


// Path: src/main/java/javapns/notification/PayloadPerDevice.java
import javapns.devices.Device;
import javapns.devices.exceptions.InvalidDeviceTokenFormatException;
import javapns.devices.implementations.basic.BasicDevice;

package javapns.notification;


/**
 * A one-to-one link between a payload and device.
 * Provides support for a typical payload-per-device scenario.
 *
 * @author Sylvain Pedneault
 */
public class PayloadPerDevice {
  private final Payload payload;
  private final Device device;

  public PayloadPerDevice(final Payload payload, final String token) throws InvalidDeviceTokenFormatException {