package org.ajax4jsf.bean.validation;

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

import org.hibernate.validator.Max;
import org.hibernate.validator.Min;
import org.hibernate.validator.NotNull;

/**
 * renamed and copied from demo
 */
public class OrderOfDay {
    public OrderOfDay() {
        activities.add(new Activity("Sport", 0));
        activities.add(new Activity("Entertainment", 0));
        activities.add(new Activity("Sleeping", 0));
        activities.add(new Activity("Games", 0));
    }

    private List<Activity> activities = new ArrayList<Activity>();

    public List<Activity> getActivities() {
        return activities;
    }

    public void setActivities(List<Activity> activities) {
        this.activities = activities;
    }

    @NotNull
    @Min(value = 1, message = "Please fill at least one entry")
    @Max(value = 24, message = "Only 24h in a day!")
    public Integer getTotalTime() {
        Integer retVal = 0;
        for (Activity activity : activities) {
            retVal += activity.getTime();
        }
        return retVal;
    }
    
    @NotNull
    @Max(value = 10, message = "Are you sure you have power for this??!!")
    public Integer getSportTime() {
        return activities.get(0).getTime();
    }

}
