package org.sistema.spring.autowiring.annotations.models;

import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

/**
 * Represents a football match between two teams
 * 
 * @author Eugenia Pérez Martínez
 */
public class Match {
	@Autowired
	@Qualifier("osasuna")
	private Team homeTeam;
	@Autowired
	@Qualifier("erreala")
	private Team visitorTeam;
	@Autowired
	@Qualifier("mejuto")
	private Referee referee;
	@Autowired
	private Home stadium; // There is only one Home in xml file. Spring
	// will inject that.
	private Date date;
	private int homeGoal;
	private int visitorGoal;

	/**
	 * default constructor
	 */
	public Match() {
	}

	/**
	 * gives result of the match
	 * 
	 * @return
	 */
	public String outcome() {
		return homeTeam.getName() + " " + homeGoal + " - "
				+ visitorTeam.getName() + " " + visitorGoal;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Match [homeTeam=" + homeTeam.toString() + "\n, visitorTeam="
				+ visitorTeam.toString() + "\n, referee=" + referee.toString()
				+ "\n, stadium=" + stadium.toString() + "\n, date=" + date
				+ ", homeGoal=" + homeGoal + ", visitorGoal=" + visitorGoal
				+ "]";
	}

	public Team getHomeTeam() {
		return homeTeam;
	}

	public void setHomeTeam(Team homeTeam) {
		this.homeTeam = homeTeam;
	}

	public Team getVisitorTeam() {
		return visitorTeam;
	}

	public void setVisitorTeam(Team visitorTeam) {
		this.visitorTeam = visitorTeam;
	}

	public Referee getReferee() {
		return referee;
	}

	public void setReferee(Referee referee) {
		this.referee = referee;
	}

	public Home getStadium() {
		return stadium;
	}

	public void setStadium(Home stadium) {
		this.stadium = stadium;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public int getHomeGoal() {
		return homeGoal;
	}

	public void setHomeGoal(int homeGoal) {
		this.homeGoal = homeGoal;
	}

	public int getVisitorGoal() {
		return visitorGoal;
	}

	public void setVisitorGoal(int visitorGoal) {
		this.visitorGoal = visitorGoal;
	}

}
