All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.windowsazure.messaging.AppleTemplateRegistration Maven / Gradle / Ivy

//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------

package com.windowsazure.messaging;

/**
 * Class representing a registration for template notifications for devices using APNs.
 */
public class AppleTemplateRegistration extends AppleRegistration {
    private static final String APNS_TEMPLATE_REGISTRATION1 = "";
    private static final String APNS_TEMPLATE_REGISTRATION2 = "";
    private static final String APNS_TEMPLATE_REGISTRATION3 = "";
    private static final String APNS_TEMPLATE_REGISTRATION5 = "";


    private String bodyTemplate;
    private String expiry;

    public AppleTemplateRegistration() {
        super();
    }

    public AppleTemplateRegistration(String registrationId, String deviceToken,
                                     String bodyTemplate) {
        super(registrationId, deviceToken);
        this.bodyTemplate = bodyTemplate;
    }

    public AppleTemplateRegistration(String deviceToken, String bodyTemplate) {
        super(deviceToken);
        this.bodyTemplate = bodyTemplate;
    }

    public String getBodyTemplate() {
        return bodyTemplate;
    }

    public void setBodyTemplate(String bodyTemplate) {
        this.bodyTemplate = bodyTemplate;
    }

    public String getExpiry() {
        return expiry;
    }

    public void setExpiry(String expiry) {
        this.expiry = expiry;
    }


    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result
            + ((bodyTemplate == null) ? 0 : bodyTemplate.hashCode());
        result = prime * result + ((expiry == null) ? 0 : expiry.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (!super.equals(obj))
            return false;
        if (getClass() != obj.getClass())
            return false;
        AppleTemplateRegistration other = (AppleTemplateRegistration) obj;
        if (bodyTemplate == null) {
            if (other.bodyTemplate != null)
                return false;
        } else if (!bodyTemplate.equals(other.bodyTemplate))
            return false;
        if (expiry == null) {
            if (other.expiry != null)
                return false;
        } else if (!expiry.equals(other.expiry))
            return false;
        return true;
    }

    @Override
    public String getXml() {
        return APNS_TEMPLATE_REGISTRATION1 +
            getTagsXml() +
            APNS_TEMPLATE_REGISTRATION2 +
            deviceToken +
            APNS_TEMPLATE_REGISTRATION3 +
            bodyTemplate +
            APNS_TEMPLATE_REGISTRATION4 +
            getExpiryXml() +
            APNS_TEMPLATE_REGISTRATION5;
    }

    private String getExpiryXml() {
        if (expiry == null) return "";
        return "" + expiry + "";
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy