I am trying to create a generic database function to populate default values into a table on creation if need be. I have a class which will create pairs, thanks to this post but don't quite understand how it works! :(
I believe I would create something like this for the pairs:
public class DBColumnValuePair<T, V>
{
private final T column;
private final V value;
public DBColumnValuePair(T column, V value)
{
this.column = column;
this.value = value;
}
public T getColumn()
{
return column;
}
public V getValue()
{
return value;
}
@Override
public int hashCode()
{
return this.column.hashCode() ^ this.value.hashCode();
}
@Override
public boolean equals(Object o)
{
if (o == null)
{
return false;
}
if (!(o instanceof DBColumnValuePair))
{
return false;
}
DBColumnValuePair dbCVPObject = (DBColumnValuePair) o;
return this.column.equals(dbCVPObject.getColumn())
&& this.value.equals(dbCVPObject.getValue());
}
}
Then populate an array with these pairs? Then send this to the method I want to handle the default values.
So my question is how do i populate the pairs in the first place? and would an array of pairs be the way to send them to the handler method?
Hope you can help :)