/**
* Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.master.security;
import java.util.Map;
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 org.threeten.bp.Instant;
import com.opengamma.id.ObjectIdentifiable;
import com.opengamma.master.AbstractHistoryRequest;
import com.opengamma.util.PublicSPI;
/**
* Request for the history of a security.
* <p>
* A full security master implements historical storage of data.
* History can be stored in two dimensions and this request provides searching.
* <p>
* The first historic dimension is the classic series of versions.
* Each new version is stored in such a manor that previous versions can be accessed.
* <p>
* The second historic dimension is corrections.
* A correction occurs when it is realized that the original data stored was incorrect.
* A simple security master might simply replace the original version with the corrected value.
* A full implementation will store the correction in such a manner that it is still possible
* to obtain the value before the correction was made.
* <p>
* For example, a security added on Monday and updated on Thursday has two versions.
* If it is realized on Friday that the version stored on Monday was incorrect, then a
* correction may be applied. There are now two versions, the first of which has one correction.
* This may continue, with multiple corrections allowed for each version.
* <p>
* Versions and corrections are represented by instants in the search.
*/
@PublicSPI
@BeanDefinition
public class SecurityHistoryRequest extends AbstractHistoryRequest {
/**
* The depth of security data to return.
* False will only return the basic information held in the {@code ManageableSecurity} class.
* True will load the full security subclass for each returned security.
* By default this is true returning all the data.
*/
@PropertyDefinition
private boolean _fullDetail = true;
/**
* Creates an instance.
* The object identifier must be added before searching.
*/
public SecurityHistoryRequest() {
super();
}
/**
* Creates an instance with object identifier.
* This will retrieve all versions and corrections unless the relevant fields are set.
*
* @param objectId the object identifier, not null
*/
public SecurityHistoryRequest(final ObjectIdentifiable objectId) {
super(objectId);
}
/**
* Creates an instance with object identifier and optional version and correction.
*
* @param objectId the object identifier, not null
* @param versionInstant the version instant to retrieve, null for all versions
* @param correctedToInstant the instant that the data should be corrected to, null for all corrections
*/
public SecurityHistoryRequest(final ObjectIdentifiable objectId, Instant versionInstant, Instant correctedToInstant) {
super(objectId, versionInstant, correctedToInstant);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code SecurityHistoryRequest}.
* @return the meta-bean, not null
*/
public static SecurityHistoryRequest.Meta meta() {
return SecurityHistoryRequest.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(SecurityHistoryRequest.Meta.INSTANCE);
}
@Override
public SecurityHistoryRequest.Meta metaBean() {
return SecurityHistoryRequest.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the depth of security data to return.
* False will only return the basic information held in the {@code ManageableSecurity} class.
* True will load the full security subclass for each returned security.
* By default this is true returning all the data.
* @return the value of the property
*/
public boolean isFullDetail() {
return _fullDetail;
}
/**
* Sets the depth of security data to return.
* False will only return the basic information held in the {@code ManageableSecurity} class.
* True will load the full security subclass for each returned security.
* By default this is true returning all the data.
* @param fullDetail the new value of the property
*/
public void setFullDetail(boolean fullDetail) {
this._fullDetail = fullDetail;
}
/**
* Gets the the {@code fullDetail} property.
* False will only return the basic information held in the {@code ManageableSecurity} class.
* True will load the full security subclass for each returned security.
* By default this is true returning all the data.
* @return the property, not null
*/
public final Property<Boolean> fullDetail() {
return metaBean().fullDetail().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public SecurityHistoryRequest clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
SecurityHistoryRequest other = (SecurityHistoryRequest) obj;
return (isFullDetail() == other.isFullDetail()) &&
super.equals(obj);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = hash * 31 + JodaBeanUtils.hashCode(isFullDetail());
return hash ^ super.hashCode();
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(64);
buf.append("SecurityHistoryRequest{");
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("fullDetail").append('=').append(JodaBeanUtils.toString(isFullDetail())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code SecurityHistoryRequest}.
*/
public static class Meta extends AbstractHistoryRequest.Meta {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code fullDetail} property.
*/
private final MetaProperty<Boolean> _fullDetail = DirectMetaProperty.ofReadWrite(
this, "fullDetail", SecurityHistoryRequest.class, Boolean.TYPE);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, (DirectMetaPropertyMap) super.metaPropertyMap(),
"fullDetail");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -1233600576: // fullDetail
return _fullDetail;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends SecurityHistoryRequest> builder() {
return new DirectBeanBuilder<SecurityHistoryRequest>(new SecurityHistoryRequest());
}
@Override
public Class<? extends SecurityHistoryRequest> beanType() {
return SecurityHistoryRequest.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code fullDetail} property.
* @return the meta-property, not null
*/
public final MetaProperty<Boolean> fullDetail() {
return _fullDetail;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -1233600576: // fullDetail
return ((SecurityHistoryRequest) bean).isFullDetail();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case -1233600576: // fullDetail
((SecurityHistoryRequest) bean).setFullDetail((Boolean) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}