// Copyright 2008 by Basil Vandegriend.  All rights reserved.

package com.basilv.resumecalculator;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import org.joda.time.Interval;

import com.basilv.core.Assert;

/**
 * Represents a single entry within a resume representing some experience gained over a span of time.
 * Typically represents a position, job, or project.
 */
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name = "entry")
public class ResumeEntry
{
	@XmlAttribute(required=true)
	private String id; // is immutable.
	
	@XmlAttribute(name="summary")
	private String summary;

	@XmlAttribute(name="interval")
	@XmlJavaTypeAdapter(XmlResumeEntryIntervalAdapter.class)
	private Interval dateInterval;
	private List<String> keywords = new ArrayList<String>();
	
	public ResumeEntry(String id) {
		Assert.notNullOrEmpty("id", "id");
		this.id = id;
	}
	
	public String getSummary() {
		return summary;
	}
	public void setSummary(String description) {
		this.summary = description;
	}
	
	public Interval getDateInterval() {
		return dateInterval;
	}
	public void setDateInterval(Interval dateInterval) {
		this.dateInterval = dateInterval;
	}
	
	public String getId() {
		return id;
	}
	
	public List<String> getKeywords() {
		return keywords;
	}
	
	public void addKeyword(String keyword) {
		Assert.notNullOrEmpty("keyword", keyword);
		keywords.add(keyword);
	}

	// Needed for conversion from XML
	@SuppressWarnings("unused")
	private ResumeEntry() {
	}
	
	// Needed for conversion from XML
	@SuppressWarnings("unused")
	private void setId(String id) {
		this.id = id;
	}

}
