/*
 * Copyright 2012 s_wolff.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.aegee.runanddine.registrationvalidation;

import org.aegee.runanddine.util.data.ModelNotExistingException;
import org.aegee.runanddine.util.model.Model;

/**
 * Model for persistent RegistrationValidationMailTemplates
 * @author s_wolff
 */
public class RegistrationValidationMailTemplate extends Model {

    /**
     * Singleton instance of template
     */
    private static RegistrationValidationMailTemplate TEMPLATE = null;
    private static final long serialVersionUID = 1L;
    
    /**
     * Mail subject
     */
    private String subject = "dummy subject";
    
    /**
     * Mail content
     */
    private String content = "dummy content";

    public RegistrationValidationMailTemplate() {
    }

    public RegistrationValidationMailTemplate(int id, String subject, String content) {
        this.id = id;
        this.subject = subject;
        this.content = content;
    }

    /**
     * Get mail content
     * @return Mail content
     */
    public String getContent() {
        return content;
    }

    /**
     * Get mail subject
     * @return Mail subject
     */
    public String getSubject() {
        return subject;
    }

    /**
     * Set mail content
     * @param content Content to be set
     */
    public void setContent(String content) {
        this.content = content;
    }

    /**
     * Set mail subject
     * @param subject Subject to be set
     */
    public void setSubject(String subject) {
        this.subject = subject;
    }

    /**
     * Get singleton instance of RegistrationValidationMailTemplate
     * @return Singleton instance
     */
    public static RegistrationValidationMailTemplate getTemplate() {
        if (TEMPLATE == null) {
            try {
                TEMPLATE = RegistrationValidationMailTemplateManager.getInstance().get();
            } catch (ModelNotExistingException e) {
                TEMPLATE = new RegistrationValidationMailTemplate();
            } finally {
                if (TEMPLATE == null) {
                    TEMPLATE = new RegistrationValidationMailTemplate();
                }
            }
        }
        return TEMPLATE;
    }
}
