/*
$Id: DateParameterValueData.java 6127 2012-09-14 07:28:35Z nicklas $
Copyright (C) 2005 Samuel Andersson, Johan Enell, Nicklas Nordborg
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
This file is part of BASE - BioArray Software Environment.
Available at http://base.thep.lu.se/
BASE 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.
BASE 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 BASE. If not, see .
*/
package net.sf.basedb.core.data;
import java.util.List;
import java.util.ArrayList;
import java.util.Date;
import net.sf.basedb.core.DateUtil;
/**
Date parameter value.
@author Samuel
@version 2.0
@see Developer documentation: Parameters
@hibernate.subclass discriminator-value="8"
@base.modified $Date: 2012-09-14 07:28:35 +0000 (Fri, 14 Sep 2012) $
*/
public class DateParameterValueData
extends ParameterValueData
{
public DateParameterValueData()
{}
public DateParameterValueData(Date... values)
{
super(values);
}
/**
@return 8 (Type.DATE)
@since 2.16
*/
@Override
public int getValueType()
{
return 8;
}
private List values;
/**
@hibernate.bag table="`DateValues`" lazy="true" cascade="all"
@hibernate.collection-key column="`id`"
@hibernate.collection-element column="`value`" type="date" not-null="true"
*/
@Override
public List getValues()
{
if (values == null )
{
values = new ArrayList();
}
return values;
}
@Override
void setValues(List values)
{
this.values = values;
}
/**
Overrides the parent method since we want to get rid of the
time part of the date.
*/
@Override
public void replaceValues(List> values)
{
List current = getValues();
current.clear();
if (values != null)
{
for (Object v : values)
{
current.add(DateUtil.truncate((Date)v));
}
}
}
/**
Overrides the parent method since we want to get rid of the
time part of the date.
*/
@Override
public void setSingleValue(Object value)
{
List current = getValues();
current.clear();
current.add(DateUtil.truncate((Date)value));
}
@Override
public String toString()
{
return values.toString();
}
}