/**
* Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.util.fudgemsg;
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;
/**
* A wrapper for a boolean that ensures transfer by Fudge.
* <p>
* This allows a boolean to be easily sent in a full Fudge wrapper.
*/
@BeanDefinition
public class FudgeBooleanWrapper extends DirectBean {
/**
* The boolean value.
*/
@PropertyDefinition
private boolean _value;
/**
* Creates an instance.
*
* @param value the value, not null
* @return the list, not null
*/
public static FudgeBooleanWrapper of(boolean value) {
return new FudgeBooleanWrapper(value);
}
//-------------------------------------------------------------------------
/**
* Creates an instance.
*/
private FudgeBooleanWrapper() {
}
/**
* Creates an instance.
*
* @param value the value, not null
*/
public FudgeBooleanWrapper(boolean value) {
setValue(value);
}
//------------------------- AUTOGENERATED START -------------------------
///CLOVER:OFF
/**
* The meta-bean for {@code FudgeBooleanWrapper}.
* @return the meta-bean, not null
*/
public static FudgeBooleanWrapper.Meta meta() {
return FudgeBooleanWrapper.Meta.INSTANCE;
}
static {
JodaBeanUtils.registerMetaBean(FudgeBooleanWrapper.Meta.INSTANCE);
}
@Override
public FudgeBooleanWrapper.Meta metaBean() {
return FudgeBooleanWrapper.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the boolean value.
* @return the value of the property
*/
public boolean isValue() {
return _value;
}
/**
* Sets the boolean value.
* @param value the new value of the property
*/
public void setValue(boolean value) {
this._value = value;
}
/**
* Gets the the {@code value} property.
* @return the property, not null
*/
public final Property<Boolean> value() {
return metaBean().value().createProperty(this);
}
//-----------------------------------------------------------------------
@Override
public FudgeBooleanWrapper clone() {
return JodaBeanUtils.cloneAlways(this);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
FudgeBooleanWrapper other = (FudgeBooleanWrapper) obj;
return (isValue() == other.isValue());
}
return false;
}
@Override
public int hashCode() {
int hash = getClass().hashCode();
hash = hash * 31 + JodaBeanUtils.hashCode(isValue());
return hash;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(64);
buf.append("FudgeBooleanWrapper{");
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("value").append('=').append(JodaBeanUtils.toString(isValue())).append(',').append(' ');
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code FudgeBooleanWrapper}.
*/
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 value} property.
*/
private final MetaProperty<Boolean> _value = DirectMetaProperty.ofReadWrite(
this, "value", FudgeBooleanWrapper.class, Boolean.TYPE);
/**
* The meta-properties.
*/
private final Map<String, MetaProperty<?>> _metaPropertyMap$ = new DirectMetaPropertyMap(
this, null,
"value");
/**
* Restricted constructor.
*/
protected Meta() {
}
@Override
protected MetaProperty<?> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 111972721: // value
return _value;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder<? extends FudgeBooleanWrapper> builder() {
return new DirectBeanBuilder<FudgeBooleanWrapper>(new FudgeBooleanWrapper());
}
@Override
public Class<? extends FudgeBooleanWrapper> beanType() {
return FudgeBooleanWrapper.class;
}
@Override
public Map<String, MetaProperty<?>> metaPropertyMap() {
return _metaPropertyMap$;
}
//-----------------------------------------------------------------------
/**
* The meta-property for the {@code value} property.
* @return the meta-property, not null
*/
public final MetaProperty<Boolean> value() {
return _value;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case 111972721: // value
return ((FudgeBooleanWrapper) bean).isValue();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
switch (propertyName.hashCode()) {
case 111972721: // value
((FudgeBooleanWrapper) bean).setValue((Boolean) newValue);
return;
}
super.propertySet(bean, propertyName, newValue, quiet);
}
}
///CLOVER:ON
//-------------------------- AUTOGENERATED END --------------------------
}