/**
* Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.bbg.referencedata;
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.DirectBean;
import org.joda.beans.impl.direct.DirectBeanBuilder;
import org.joda.beans.impl.direct.DirectMetaBean;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;
import com.opengamma.util.PublicSPI;
/**
* Information about an error that occurred.
* <p>
* This class is mutable and not thread-safe.
*/
@PublicSPI
@BeanDefinition
public class ReferenceDataError extends DirectBean {
/**
* The data field that the error refers to, null if refers to the identifier.
*/
@PropertyDefinition // CSIGNORE
private String _field;
/**
* The error code.
*/
@PropertyDefinition // CSIGNORE
private int _code;
/**
* The error category.
*/
@PropertyDefinition // CSIGNORE
private String _category;
/**
* The error sub-category.
*/
@PropertyDefinition // CSIGNORE
private String _subcategory;
/**
* The error message.
*/
@PropertyDefinition // CSIGNORE
private String _message;
/**
* Creates an instance.
*/
protected ReferenceDataError() {
}
/**
* Creates an instance.
*
* @param field the field, null if linked to the identifier rather than a field
* @param code the error code
* @param category the error category, may be null
* @param subcategory the error sub-category, may be null
* @param message the error message, may be null
*/
public ReferenceDataError(String field, int code, String category, String subcategory, String message) {
super();
_field = field;
_code = code;
_category = category;
_subcategory = subcategory;
_message = message;
}
//-------------------------------------------------------------------------
/**
* Checks if the error is field-based or not.
*
* @return true if field-based, false if identifier-based
*/
public boolean isFieldBased() {
return getField() != null;
}
/**
* Checks if the error is due to not being entitled.
*
* @return true if error due to not being entitled
*/
public boolean isEntitlementError() {
return "NOT_ENTITLED".equals(getCategory());
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code ReferenceDataError}.
* @return the meta-bean, not null
*/
public static ReferenceDataError.Meta meta() {
return ReferenceDataError.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(ReferenceDataError.Meta.INSTANCE);
}
@Override
public ReferenceDataError.Meta metaBean() {
return ReferenceDataError.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the data field that the error refers to, null if refers to the identifier.
* @return the value of the property
*/
public String getField() {
return _field;
}
/**
* Sets the data field that the error refers to, null if refers to the identifier.
* @param field the new value of the property
*/
public void setField(String field) {
this._field = field;
}
/**
* Gets the the {@code field} property.
* @return the property, not null
*/
public final Property<String> field() {
return metaBean().field().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the error code.
* @return the value of the property
*/
public int getCode() {
return _code;
}
/**
* Sets the error code.
* @param code the new value of the property
*/
public void setCode(int code) {
this._code = code;
}
/**
* Gets the the {@code code} property.
* @return the property, not null
*/
public final Property<Integer> code() {
return metaBean().code().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the error category.
* @return the value of the property
*/
public String getCategory() {
return _category;
}
/**
* Sets the error category.
* @param category the new value of the property
*/
public void setCategory(String category) {
this._category = category;
}
/**
* Gets the the {@code category} property.
* @return the property, not null
*/
public final Property<String> category() {
return metaBean().category().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the error sub-category.
* @return the value of the property
*/
public String getSubcategory() {
return _subcategory;
}
/**
* Sets the error sub-category.
* @param subcategory the new value of the property
*/
public void setSubcategory(String subcategory) {
this._subcategory = subcategory;
}
/**
* Gets the the {@code subcategory} property.
* @return the property, not null
*/
public final Property<String> subcategory() {
return metaBean().subcategory().createProperty(this);
}
//-----------------------------------------------------------------------
/**
* Gets the error message.
* @return the value of the property
*/
public String getMessage() {
return _message;
}
/**
* Sets the error message.
* @param message the new value of the property
*/
public void setMessage(String message) {
this._message = message;
}
/**
* Gets the the {@code message} property.
* @return the property, not null
*/
public final Property<String> message() {
return metaBean().message().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public ReferenceDataError clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
ReferenceDataError other = (ReferenceDataError) obj;
return JodaBeanUtils.equal(getField(), other.getField()) &&
(getCode() == other.getCode()) &&
JodaBeanUtils.equal(getCategory(), other.getCategory()) &&
JodaBeanUtils.equal(getSubcategory(), other.getSubcategory()) &&
JodaBeanUtils.equal(getMessage(), other.getMessage());
}
return false;
}
@Override
public int hashCode() {
int hash = getClass().hashCode();
hash = hash * 31 + JodaBeanUtils.hashCode(getField());
hash = hash * 31 + JodaBeanUtils.hashCode(getCode());
hash = hash * 31 + JodaBeanUtils.hashCode(getCategory());
hash = hash * 31 + JodaBeanUtils.hashCode(getSubcategory());
hash = hash * 31 + JodaBeanUtils.hashCode(getMessage());
return hash;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(192);
buf.append("ReferenceDataError{");
int len = buf.length();
toString(buf);
if (buf.length() > len) {
buf.setLength(buf.length() - 2);
}
buf.append('}');
return buf.toString();
}
protected void toString(StringBuilder buf) {
buf.append("field").append('=').append(JodaBeanUtils.toString(getField())).append(',').append(' ');
buf.append("code").append('=').append(JodaBeanUtils.toString(getCode())).append(',').append(' ');
buf.append("category").append('=').append(JodaBeanUtils.toString(getCategory())).append(',').append(' ');
buf.append("subcategory").append('=').append(JodaBeanUtils.toString(getSubcategory())).append(',').append(' ');
buf.append("message").append('=').append(JodaBeanUtils.toString(getMessage())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code ReferenceDataError}.
*/
public static class Meta extends DirectMetaBean {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code field} property.
*/
private final MetaProperty<String> _field = DirectMetaProperty.ofReadWrite(
this, "field", ReferenceDataError.class, String.class);
/**
* The meta-property for the {@code code} property.
*/
private final MetaProperty<Integer> _code = DirectMetaProperty.ofReadWrite(
this, "code", ReferenceDataError.class, Integer.TYPE);
/**
* The meta-property for the {@code category} property.
*/
private final MetaProperty<String> _category = DirectMetaProperty.ofReadWrite(
this, "category", ReferenceDataError.class, String.class);
/**
* The meta-property for the {@code subcategory} property.
*/
private final MetaProperty<String> _subcategory = DirectMetaProperty.ofReadWrite(
this, "subcategory", ReferenceDataError.class, String.class);
/**
* The meta-property for the {@code message} property.
*/
private final MetaProperty<String> _message = DirectMetaProperty.ofReadWrite(
this, "message", ReferenceDataError.class, String.class);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, null,
"field",
"code",
"category",
"subcategory",
"message");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 97427706: // field
return _field;
case 3059181: // code
return _code;
case 50511102: // category
return _category;
case 1300380478: // subcategory
return _subcategory;
case 954925063: // message
return _message;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends ReferenceDataError> builder() {
return new DirectBeanBuilder<ReferenceDataError>(new ReferenceDataError());
}
@Override
public Class<? extends ReferenceDataError> beanType() {
return ReferenceDataError.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code field} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> field() {
return _field;
}
/**
* The meta-property for the {@code code} property.
* @return the meta-property, not null
*/
public final MetaProperty<Integer> code() {
return _code;
}
/**
* The meta-property for the {@code category} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> category() {
return _category;
}
/**
* The meta-property for the {@code subcategory} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> subcategory() {
return _subcategory;
}
/**
* The meta-property for the {@code message} property.
* @return the meta-property, not null
*/
public final MetaProperty<String> message() {
return _message;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case 97427706: // field
return ((ReferenceDataError) bean).getField();
case 3059181: // code
return ((ReferenceDataError) bean).getCode();
case 50511102: // category
return ((ReferenceDataError) bean).getCategory();
case 1300380478: // subcategory
return ((ReferenceDataError) bean).getSubcategory();
case 954925063: // message
return ((ReferenceDataError) bean).getMessage();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case 97427706: // field
((ReferenceDataError) bean).setField((String) newValue);
return;
case 3059181: // code
((ReferenceDataError) bean).setCode((Integer) newValue);
return;
case 50511102: // category
((ReferenceDataError) bean).setCategory((String) newValue);
return;
case 1300380478: // subcategory
((ReferenceDataError) bean).setSubcategory((String) newValue);
return;
case 954925063: // message
((ReferenceDataError) bean).setMessage((String) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}