/*
 * 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.information;

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

/**
 * Model for persistent InformationMailTemplates
 *
 * @author s_wolff
 */
public class InformationMailTemplate extends Model {

    /**
     * Singleton instance of InformationMailTemplate
     */
    private static InformationMailTemplate INSTANCE;
    private static final long serialVersionUID = 1L;
    
    /**
     * Mail subject
     */
    private String subject = "This is a dummy subject";
    
    /**
     * Mail content
     */
    private String content = "This is a dummy content";

    public InformationMailTemplate() {
    }

    private InformationMailTemplate(String subject, String content) {
        this.subject = subject;
        this.content = content;
    }

    /**
     * Get mail content
     * @return Content of InformationMailTemplate
     */
    public String getContent() {
        return content;
    }

    /**
     * Get mail subject
     * @return Subject of InformationMailTemplate
     */
    public String getSubject() {
        return subject;
    }

    /**
     * Set mail content
     * @param content New content for InformationMailTemplate
     */
    public void setContent(String content) {
        this.content = content;
    }

    /**
     * Set mail subject
     * @param subject New subject for InformationMailTemplate
     */
    public void setSubject(String subject) {
        this.subject = subject;
    }

    /**
     * Get singleton instance of InformationMailTemplate
     * @return Sinleton InformationMailTemplate
     */
    public static InformationMailTemplate getTemplate() {
        if (INSTANCE == null) {
            try {
                INSTANCE = InformationMailTemplateManager.getInstance().get();
            } catch (ModelNotExistingException e) {
                INSTANCE = new InformationMailTemplate();
            } finally {
                if (INSTANCE == null) {
                    INSTANCE = new InformationMailTemplate();
                }
            }
        }
        return INSTANCE;
    }
}
