/**
* Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.web.holiday;
import java.util.Map;
import javax.ws.rs.core.UriInfo;
import org.joda.beans.Bean;
import org.joda.beans.BeanBuilder;
import org.joda.beans.BeanDefinition;
import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaProperty;
import org.joda.beans.Property;
import org.joda.beans.PropertyDefinition;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;
import com.opengamma.id.UniqueId;
import com.opengamma.master.holiday.HolidayDocument;
import com.opengamma.master.holiday.HolidayMaster;
import com.opengamma.web.WebPerRequestData;
/**
* Data class for web-based holidays.
*/
@BeanDefinition
public class WebHolidayData extends WebPerRequestData {
/**
* The holiday master.
*/
@PropertyDefinition
private HolidayMaster _holidayMaster;
/**
* The holiday id from the input URI.
*/
@PropertyDefinition
private String _uriHolidayId;
/**
* The version id from the URI.
*/
@PropertyDefinition
private String _uriVersionId;
/**
* The holiday.
*/
@PropertyDefinition
private HolidayDocument _holiday;
/**
* The versioned holiday.
*/
@PropertyDefinition
private HolidayDocument _versioned;
/**
* Creates an instance.
*/
public WebHolidayData() {
}
/**
* Creates an instance.
* @param uriInfo the URI information
*/
public WebHolidayData(final UriInfo uriInfo) {
setUriInfo(uriInfo);
}
//-------------------------------------------------------------------------
/**
* Gets the best available holiday id.
* @param overrideId the override id, null derives the result from the data
* @return the id, may be null
*/
public String getBestHolidayUriId(final UniqueId overrideId) {
if (overrideId != null) {
return overrideId.toLatest().toString();
}
return getHoliday() != null ? getHoliday().getUniqueId().toLatest().toString() : getUriHolidayId();
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code WebHolidayData}.
* @return the meta-bean, not null
*/
public static WebHolidayData.Meta meta() {
return WebHolidayData.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(WebHolidayData.Meta.INSTANCE);
}
@Override
public WebHolidayData.Meta metaBean() {
return WebHolidayData.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the holiday master.
* @return the value of the property
*/
public HolidayMaster getHolidayMaster() {
return _holidayMaster;
}
/**
* Sets the holiday master.
* @param holidayMaster the new value of the property
*/
public void setHolidayMaster(HolidayMaster holidayMaster) {
this._holidayMaster = holidayMaster;
}
/**
* Gets the the {@code holidayMaster} property.
* @return the property, not null
*/
public final Property<HolidayMaster> holidayMaster() {
return metaBean().holidayMaster().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the holiday id from the input URI.
* @return the value of the property
*/
public String getUriHolidayId() {
return _uriHolidayId;
}
/**
* Sets the holiday id from the input URI.
* @param uriHolidayId the new value of the property
*/
public void setUriHolidayId(String uriHolidayId) {
this._uriHolidayId = uriHolidayId;
}
/**
* Gets the the {@code uriHolidayId} property.
* @return the property, not null
*/
public final Property<String> uriHolidayId() {
return metaBean().uriHolidayId().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the version id from the URI.
* @return the value of the property
*/
public String getUriVersionId() {
return _uriVersionId;
}
/**
* Sets the version id from the URI.
* @param uriVersionId the new value of the property
*/
public void setUriVersionId(String uriVersionId) {
this._uriVersionId = uriVersionId;
}
/**
* Gets the the {@code uriVersionId} property.
* @return the property, not null
*/
public final Property<String> uriVersionId() {
return metaBean().uriVersionId().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the holiday.
* @return the value of the property
*/
public HolidayDocument getHoliday() {
return _holiday;
}
/**
* Sets the holiday.
* @param holiday the new value of the property
*/
public void setHoliday(HolidayDocument holiday) {
this._holiday = holiday;
}
/**
* Gets the the {@code holiday} property.
* @return the property, not null
*/
public final Property<HolidayDocument> holiday() {
return metaBean().holiday().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the versioned holiday.
* @return the value of the property
*/
public HolidayDocument getVersioned() {
return _versioned;
}
/**
* Sets the versioned holiday.
* @param versioned the new value of the property
*/
public void setVersioned(HolidayDocument versioned) {
this._versioned = versioned;
}
/**
* Gets the the {@code versioned} property.
* @return the property, not null
*/
public final Property<HolidayDocument> versioned() {
return metaBean().versioned().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public WebHolidayData clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
WebHolidayData other = (WebHolidayData) obj;
return JodaBeanUtils.equal(getHolidayMaster(), other.getHolidayMaster()) &&
JodaBeanUtils.equal(getUriHolidayId(), other.getUriHolidayId()) &&
JodaBeanUtils.equal(getUriVersionId(), other.getUriVersionId()) &&
JodaBeanUtils.equal(getHoliday(), other.getHoliday()) &&
JodaBeanUtils.equal(getVersioned(), other.getVersioned()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(getHolidayMaster());
hash = hash * 31 + JodaBeanUtils.hashCode(getUriHolidayId());
hash = hash * 31 + JodaBeanUtils.hashCode(getUriVersionId());
hash = hash * 31 + JodaBeanUtils.hashCode(getHoliday());
hash = hash * 31 + JodaBeanUtils.hashCode(getVersioned());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(192);
buf.append("WebHolidayData{");
int len = buf.length();
toString(buf);
if (buf.length() > len) {
buf.setLength(buf.length() - 2);
}
buf.append('}');
return buf.toString();
}
@Override
protected void toString(StringBuilder buf) {
super.toString(buf);
buf.append("holidayMaster").append('=').append(JodaBeanUtils.toString(getHolidayMaster())).append(',').append(' ');
buf.append("uriHolidayId").append('=').append(JodaBeanUtils.toString(getUriHolidayId())).append(',').append(' ');
buf.append("uriVersionId").append('=').append(JodaBeanUtils.toString(getUriVersionId())).append(',').append(' ');
buf.append("holiday").append('=').append(JodaBeanUtils.toString(getHoliday())).append(',').append(' ');
buf.append("versioned").append('=').append(JodaBeanUtils.toString(getVersioned())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code WebHolidayData}.
*/
public static class Meta extends WebPerRequestData.Meta {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code holidayMaster} property.
*/
private final MetaProperty<HolidayMaster> _holidayMaster = DirectMetaProperty.ofReadWrite(
this, "holidayMaster", WebHolidayData.class, HolidayMaster.class);
/**
* The meta-property for the {@code uriHolidayId} property.
*/
private final MetaProperty<String> _uriHolidayId = DirectMetaProperty.ofReadWrite(
this, "uriHolidayId", WebHolidayData.class, String.class);
/**
* The meta-property for the {@code uriVersionId} property.
*/
private final MetaProperty<String> _uriVersionId = DirectMetaProperty.ofReadWrite(
this, "uriVersionId", WebHolidayData.class, String.class);
/**
* The meta-property for the {@code holiday} property.
*/
private final MetaProperty<HolidayDocument> _holiday = DirectMetaProperty.ofReadWrite(
this, "holiday", WebHolidayData.class, HolidayDocument.class);
/**
* The meta-property for the {@code versioned} property.
*/
private final MetaProperty<HolidayDocument> _versioned = DirectMetaProperty.ofReadWrite(
this, "versioned", WebHolidayData.class, HolidayDocument.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"holidayMaster",
"uriHolidayId",
"uriVersionId",
"holiday",
"versioned");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 246258906: // holidayMaster
return _holidayMaster;
case -872009849: // uriHolidayId
return _uriHolidayId;
case 666567687: // uriVersionId
return _uriVersionId;
case 1091905624: // holiday
return _holiday;
case -1407102089: // versioned
return _versioned;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends WebHolidayData> builder() {
return new DirectBeanBuilder<WebHolidayData>(new WebHolidayData());
}
@Override
public Class<? extends WebHolidayData> beanType() {
return WebHolidayData.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code holidayMaster} property.
* @return the meta-property, not null
*/
public final MetaProperty<HolidayMaster> holidayMaster() {
return _holidayMaster;
}
/**
* The meta-property for the {@code uriHolidayId} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> uriHolidayId() {
return _uriHolidayId;
}
/**
* The meta-property for the {@code uriVersionId} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> uriVersionId() {
return _uriVersionId;
}
/**
* The meta-property for the {@code holiday} property.
* @return the meta-property, not null
*/
public final MetaProperty<HolidayDocument> holiday() {
return _holiday;
}
/**
* The meta-property for the {@code versioned} property.
* @return the meta-property, not null
*/
public final MetaProperty<HolidayDocument> versioned() {
return _versioned;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case 246258906: // holidayMaster
return ((WebHolidayData) bean).getHolidayMaster();
case -872009849: // uriHolidayId
return ((WebHolidayData) bean).getUriHolidayId();
case 666567687: // uriVersionId
return ((WebHolidayData) bean).getUriVersionId();
case 1091905624: // holiday
return ((WebHolidayData) bean).getHoliday();
case -1407102089: // versioned
return ((WebHolidayData) bean).getVersioned();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case 246258906: // holidayMaster
((WebHolidayData) bean).setHolidayMaster((HolidayMaster) newValue);
return;
case -872009849: // uriHolidayId
((WebHolidayData) bean).setUriHolidayId((String) newValue);
return;
case 666567687: // uriVersionId
((WebHolidayData) bean).setUriVersionId((String) newValue);
return;
case 1091905624: // holiday
((WebHolidayData) bean).setHoliday((HolidayDocument) newValue);
return;
case -1407102089: // versioned
((WebHolidayData) bean).setVersioned((HolidayDocument) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}