// 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
// public class PayloadPerDevice {
//   private final Payload payload;
//   private final Device device;
// 
//   public PayloadPerDevice(final Payload payload, final String token) throws InvalidDeviceTokenFormatException {
//     super();
//     this.payload = payload;
//     this.device = new BasicDevice(token);
//   }
// 
//   public PayloadPerDevice(final Payload payload, final Device device) {
//     super();
//     this.payload = payload;
//     this.device = device;
//   }
// 
//   public Payload getPayload() {
//     return payload;
//   }
// 
//   public Device getDevice() {
//     return device;
//   }
// 
// }


import javapns.devices.implementations.basic.BasicDevice;
import javapns.notification.PayloadPerDevice;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
package javapns.devices;



public class Devices {

  private Devices() {}

  public static List<Device> asDevices(final Object rawList) {
    final List<Device> list = new ArrayList<>();
    if (rawList == null) {
      return list;
    }

    if (rawList instanceof List) {
      final List devices = (List) rawList;
      if (devices.isEmpty()) {
        return list;
      }

      final Object firstDevice = devices.get(0);
      if (firstDevice instanceof Device) {
        //noinspection unchecked
        return devices;
      } else if (firstDevice instanceof String) {
        for (final Object token : devices) {
// 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
// public class PayloadPerDevice {
//   private final Payload payload;
//   private final Device device;
// 
//   public PayloadPerDevice(final Payload payload, final String token) throws InvalidDeviceTokenFormatException {
//     super();
//     this.payload = payload;
//     this.device = new BasicDevice(token);
//   }
// 
//   public PayloadPerDevice(final Payload payload, final Device device) {
//     super();
//     this.payload = payload;
//     this.device = device;
//   }
// 
//   public Payload getPayload() {
//     return payload;
//   }
// 
//   public Device getDevice() {
//     return device;
//   }
// 
// }


// Path: src/main/java/javapns/devices/Devices.java
import javapns.devices.implementations.basic.BasicDevice;
import javapns.notification.PayloadPerDevice;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

package javapns.devices;



public class Devices {

  private Devices() {}

  public static List<Device> asDevices(final Object rawList) {
    final List<Device> list = new ArrayList<>();
    if (rawList == null) {
      return list;
    }

    if (rawList instanceof List) {
      final List devices = (List) rawList;
      if (devices.isEmpty()) {
        return list;
      }

      final Object firstDevice = devices.get(0);
      if (firstDevice instanceof Device) {
        //noinspection unchecked
        return devices;
      } else if (firstDevice instanceof String) {
        for (final Object token : devices) {
          final BasicDevice device = new BasicDevice();