/*
*
* Goko
* Copyright (C) 2013 PsyKo
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.goko.test.recorder.ui.test;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.CellEditor;
public abstract class Tuple<T>{
String name;
List<T> data;
CellEditor editor;
public Tuple(String name, T v1, T v2, T v3, T v4) {
this.name = name;
data = new ArrayList<T>(4);
data.add(null);
data.add(null);
data.add(null);
data.add(null);
put(0,v1);
put(1,v2);
put(2,v3);
put(3,v4);
}
public T get(int index){
return data.get(index);
}
public void put(int index, T value){
data.set(index, value);
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/** (inheritDoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((data == null) ? 0 : data.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
/** (inheritDoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Tuple other = (Tuple) obj;
if (data == null) {
if (other.data != null) {
return false;
}
} else if (!data.equals(other.data)) {
return false;
}
if (name == null) {
if (other.name != null) {
return false;
}
} else if (!name.equals(other.name)) {
return false;
}
return true;
}
/**
* @return the editor
*/
public CellEditor getEditor() {
return editor;
}
/**
* @param editor the editor to set
*/
public void setEditor(CellEditor editor) {
this.editor = editor;
}
public abstract void putObject(int columnIndex, Object userInputValue);
}