/* * Copyright 2010 Prime Technology. * * 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.primefaces.examples.domain; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.List; public class Player implements Serializable { private String name; private int number; private String photo; private String position; private String nationality; private String height; private String weight; private Date birth; private List<Stats> stats = new ArrayList<Stats>(); public Player() {} public Player(String name) { this.name = name; } public Player(String name, int number, String photo) { this.name = name; this.number = number; this.photo = photo; } public Player(String name, int number, String photo, String position) { this.name = name; this.number = number; this.photo = photo; this.position = position; } public String getHeight() { return height; } public void setHeight(String height) { this.height = height; } public String getWeight() { return weight; } public void setWeight(String weight) { this.weight = weight; } public Date getBirth() { return birth; } public void setBirth(Date birth) { this.birth = birth; } public Player(String name, int number) { this.name = name; this.number = number; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPhoto() { return photo; } public void setPhoto(String photo) { this.photo = photo; } public String getPosition() { return position; } public void setPosition(String position) { this.position = position; } public String getNationality() { return nationality; } public void setNationality(String nationality) { this.nationality = nationality; } public int getNumber() { return number; } public void setNumber(int number) { this.number = number; } public List<Stats> getStats() { return stats; } public void setStats(List<Stats> stats) { this.stats = stats; } public int getAllGoals() { int sum = 0; for(Stats s : stats) { sum += s.getGoals(); } return sum; } public int getAllAssists() { int sum = 0; for(Stats s : stats) { sum += s.getAssists(); } return sum; } @Override public boolean equals(Object obj) { if(obj == null) return false; if(!(obj instanceof Player)) return false; return ((Player)obj).getNumber() == this.number; } @Override public int hashCode() { int hash = 1; return hash * 31 + name.hashCode(); } @Override public String toString() { return name; } }