blob: 3099a914f20180d98f5ce5ac05ace11600e3b2ea [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.ui.examples.contributions.model;
/**
* A simple model object that is mutable.
*
* @since 3.3
*/
public class Person {
private int id;
private String surname;
private String givenname;
Person(int id, String sn, String gn) {
surname = sn;
givenname = gn;
this.id = id;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public int getId() {
return id;
}
public String getGivenname() {
return givenname;
}
public void setGivenname(String givenname) {
this.givenname = givenname;
}
public String toString() {
return surname + ", " + givenname + " (" + id + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
protected Person copy() {
return new Person(id, surname, givenname);
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return id;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object o) {
if (o instanceof Person) {
Person p = (Person) o;
return p.givenname == givenname && p.id == id
&& p.surname == surname;
}
return false;
}
}