/*
 * Copyright (c) 2011, Patrik Dufresne. All rights reserved.
 * Patrik Dufresne PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.planimod.core;


import javax.persistence.Column;
import javax.persistence.Entity;

import com.patrikdufresne.managers.ManagedObject;

/**
 * This class represent one setting for the application.
 * 
 * @author patapouf
 */
@Entity
public class ApplicationSetting extends ManagedObject {
	/**
	 * Key to access the first day of week value.
	 */
	public static final String FIRST_DAY_OF_WEEK = "firstDayOfWeek"; //$NON-NLS-1$
	/**
	 * Key to access the customer name. Commonly used to sets the plan name.
	 */
	public static final String CUSTOMER_NAME = "customerName"; //$NON-NLS-1$
	
	/**
	 * Name property
	 */
	public static final String NAME = "name"; //$NON-NLS-1$
	/**
	 * Value property
	 */
	public static final String VALUE = "value"; //$NON-NLS-1$

	private String name;
	private String value;
	public ApplicationSetting() {
		// No default value to set.
	}

	/**
	 * Unique name of the setting.
	 * 
	 * @return the name of the setting.
	 */
	@Column(nullable = false, length = 50)
	public String getName() {
		return this.name;
	}

	/**
	 * Get value of the setting.
	 * 
	 * @return the value.
	 */
	@Column(nullable = false, length = 50)
	public String getValue() {
		return this.value;
	}

	/**
	 * Sets the name of the setting.
	 * 
	 * @param name
	 *            the new name
	 */
	public void setName(String name) {
		this.changeSupport
				.firePropertyChange(NAME, this.name, this.name = name);
	}

	/**
	 * Sets the value of thr setting
	 * 
	 * @param value
	 *            the value.
	 */
	public void setValue(String value) {
		this.changeSupport.firePropertyChange(VALUE, this.value,
				this.value = value);
	}

	@Override
	public String toString() {
		return "ApplicationSetting [name=" + this.name //$NON-NLS-1$
				+ ", value=" + this.value + "]"; //$NON-NLS-1$ //$NON-NLS-2$ 
	}
}
