// Path: src/main/java/javapns/notification/exceptions/PayloadAlertAlreadyExistsException.java
// public class PayloadAlertAlreadyExistsException extends JSONException {
// 
//   private static final long serialVersionUID = -4514511954076864373L;
// 
//   /**
//    * Default constructor
//    */
//   public PayloadAlertAlreadyExistsException() {
//     super("Payload alert already exists");
//   }
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param message
//    */
//   public PayloadAlertAlreadyExistsException(final String message) {
//     super(message);
//   }
// 
// }


import javapns.notification.exceptions.PayloadAlertAlreadyExistsException;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.IllegalFormatException;
import java.util.List;
   * Get the value of a given property, but only if it is of the expected class.
   * If the value exists but is of a different class than expected, an
   * exception is thrown.
   * <p>
   * This method is useful for properly supporting properties that can have a simple
   * or complex value (such as "alert")
   *
   * @param <T>              the property value's class
   * @param propertyName     the name of the property to get
   * @param expectedClass    the property value's expected (required) class
   * @param exceptionMessage the exception message to throw if the value is not of the expected class
   * @param dictionary       the dictionary where to get the property from
   * @return the property's value
   * @throws JSONException
   */
  @SuppressWarnings("unchecked")
  private <T> T getCompatibleProperty(final String propertyName, final Class<T> expectedClass, String exceptionMessage, final JSONObject dictionary) throws JSONException {
    Object propertyValue = null;
    try {
      propertyValue = dictionary.get(propertyName);
    } catch (final Exception e) {
      // empty
    }
    if (propertyValue == null) {
      return null;
    }
    if (propertyValue.getClass().equals(expectedClass)) {
      return (T) propertyValue;
    }
    try {
// Path: src/main/java/javapns/notification/exceptions/PayloadAlertAlreadyExistsException.java
// public class PayloadAlertAlreadyExistsException extends JSONException {
// 
//   private static final long serialVersionUID = -4514511954076864373L;
// 
//   /**
//    * Default constructor
//    */
//   public PayloadAlertAlreadyExistsException() {
//     super("Payload alert already exists");
//   }
// 
//   /**
//    * Constructor with custom message
//    *
//    * @param message
//    */
//   public PayloadAlertAlreadyExistsException(final String message) {
//     super(message);
//   }
// 
// }


// Path: src/main/java/javapns/notification/PushNotificationPayload.java
import javapns.notification.exceptions.PayloadAlertAlreadyExistsException;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.IllegalFormatException;
import java.util.List;

   * Get the value of a given property, but only if it is of the expected class.
   * If the value exists but is of a different class than expected, an
   * exception is thrown.
   * <p>
   * This method is useful for properly supporting properties that can have a simple
   * or complex value (such as "alert")
   *
   * @param <T>              the property value's class
   * @param propertyName     the name of the property to get
   * @param expectedClass    the property value's expected (required) class
   * @param exceptionMessage the exception message to throw if the value is not of the expected class
   * @param dictionary       the dictionary where to get the property from
   * @return the property's value
   * @throws JSONException
   */
  @SuppressWarnings("unchecked")
  private <T> T getCompatibleProperty(final String propertyName, final Class<T> expectedClass, String exceptionMessage, final JSONObject dictionary) throws JSONException {
    Object propertyValue = null;
    try {
      propertyValue = dictionary.get(propertyName);
    } catch (final Exception e) {
      // empty
    }
    if (propertyValue == null) {
      return null;
    }
    if (propertyValue.getClass().equals(expectedClass)) {
      return (T) propertyValue;
    }
    try {
      throw new PayloadAlertAlreadyExistsException(String.format(exceptionMessage, propertyValue));