com.opengamma.sdk.margin.MarginBreakdown Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk-margin Show documentation
Show all versions of sdk-margin Show documentation
OpenGamma SDK - Provides access to the Margin service
/*
* Copyright (C) 2018 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.sdk.margin;
import java.util.Map;
import java.util.NoSuchElementException;
import org.joda.beans.Bean;
import org.joda.beans.BeanBuilder;
import org.joda.beans.ImmutableBean;
import org.joda.beans.JodaBeanUtils;
import org.joda.beans.MetaBean;
import org.joda.beans.MetaProperty;
import org.joda.beans.gen.BeanDefinition;
import org.joda.beans.gen.PropertyDefinition;
import org.joda.beans.impl.direct.DirectMetaBean;
import org.joda.beans.impl.direct.DirectMetaProperty;
import org.joda.beans.impl.direct.DirectMetaPropertyMap;
import org.joda.beans.impl.direct.DirectPrivateBeanBuilder;
/**
* The standardized breakdown of the margin amount.
*
* For the purposes of the API, the total margin is broken down into three components:
*
* - base margin - the base margin component
*
- add ons- the total of all add-ons margin components
*
- net liquidating value (NLV) - the total premium value of the options held that has been paid/received
*
*/
@BeanDefinition(builderScope = "private", metaScope = "private", factoryName = "of")
public final class MarginBreakdown implements ImmutableBean {
/**
* The total margin, expressed in the reporting currency.
* This is the sum of the base margin, add-ons and option premium.
*/
@PropertyDefinition(validate = "notNull")
private final double totalMargin;
/**
* The base margin, expressed in the reporting currency.
* This is the total of all components of the total margin that are treated as base margin.
*/
@PropertyDefinition(validate = "notNull")
private final double baseMargin;
/**
* The add-ons, expressed in the reporting currency.
* This is the total of all components of the total margin that are treated as add-ons.
*/
@PropertyDefinition(validate = "notNull")
private final double addOns;
/**
* The net liquidating value (NLV), expressed in the reporting currency.
* This is the total premium value of the options held that has been paid/received.
*/
@PropertyDefinition
private final double netLiquidatingValue;
//------------------------- AUTOGENERATED START -------------------------
/**
* The meta-bean for {@code MarginBreakdown}.
* @return the meta-bean, not null
*/
public static MetaBean meta() {
return MarginBreakdown.Meta.INSTANCE;
}
static {
MetaBean.register(MarginBreakdown.Meta.INSTANCE);
}
/**
* Obtains an instance.
* @param totalMargin the value of the property, not null
* @param baseMargin the value of the property, not null
* @param addOns the value of the property, not null
* @param netLiquidatingValue the value of the property
* @return the instance
*/
public static MarginBreakdown of(
double totalMargin,
double baseMargin,
double addOns,
double netLiquidatingValue) {
return new MarginBreakdown(
totalMargin,
baseMargin,
addOns,
netLiquidatingValue);
}
private MarginBreakdown(
double totalMargin,
double baseMargin,
double addOns,
double netLiquidatingValue) {
JodaBeanUtils.notNull(totalMargin, "totalMargin");
JodaBeanUtils.notNull(baseMargin, "baseMargin");
JodaBeanUtils.notNull(addOns, "addOns");
this.totalMargin = totalMargin;
this.baseMargin = baseMargin;
this.addOns = addOns;
this.netLiquidatingValue = netLiquidatingValue;
}
@Override
public MetaBean metaBean() {
return MarginBreakdown.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the total margin, expressed in the reporting currency.
* This is the sum of the base margin, add-ons and option premium.
* @return the value of the property, not null
*/
public double getTotalMargin() {
return totalMargin;
}
//-----------------------------------------------------------------------
/**
* Gets the base margin, expressed in the reporting currency.
* This is the total of all components of the total margin that are treated as base margin.
* @return the value of the property, not null
*/
public double getBaseMargin() {
return baseMargin;
}
//-----------------------------------------------------------------------
/**
* Gets the add-ons, expressed in the reporting currency.
* This is the total of all components of the total margin that are treated as add-ons.
* @return the value of the property, not null
*/
public double getAddOns() {
return addOns;
}
//-----------------------------------------------------------------------
/**
* Gets the net liquidating value (NLV), expressed in the reporting currency.
* This is the total premium value of the options held that has been paid/received.
* @return the value of the property
*/
public double getNetLiquidatingValue() {
return netLiquidatingValue;
}
//-----------------------------------------------------------------------
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
MarginBreakdown other = (MarginBreakdown) obj;
return JodaBeanUtils.equal(totalMargin, other.totalMargin) &&
JodaBeanUtils.equal(baseMargin, other.baseMargin) &&
JodaBeanUtils.equal(addOns, other.addOns) &&
JodaBeanUtils.equal(netLiquidatingValue, other.netLiquidatingValue);
}
return false;
}
@Override
public int hashCode() {
int hash = getClass().hashCode();
hash = hash * 31 + JodaBeanUtils.hashCode(totalMargin);
hash = hash * 31 + JodaBeanUtils.hashCode(baseMargin);
hash = hash * 31 + JodaBeanUtils.hashCode(addOns);
hash = hash * 31 + JodaBeanUtils.hashCode(netLiquidatingValue);
return hash;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(160);
buf.append("MarginBreakdown{");
buf.append("totalMargin").append('=').append(totalMargin).append(',').append(' ');
buf.append("baseMargin").append('=').append(baseMargin).append(',').append(' ');
buf.append("addOns").append('=').append(addOns).append(',').append(' ');
buf.append("netLiquidatingValue").append('=').append(JodaBeanUtils.toString(netLiquidatingValue));
buf.append('}');
return buf.toString();
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code MarginBreakdown}.
*/
private static final class Meta extends DirectMetaBean {
/**
* The singleton instance of the meta-bean.
*/
static final Meta INSTANCE = new Meta();
/**
* The meta-property for the {@code totalMargin} property.
*/
private final MetaProperty totalMargin = DirectMetaProperty.ofImmutable(
this, "totalMargin", MarginBreakdown.class, Double.TYPE);
/**
* The meta-property for the {@code baseMargin} property.
*/
private final MetaProperty baseMargin = DirectMetaProperty.ofImmutable(
this, "baseMargin", MarginBreakdown.class, Double.TYPE);
/**
* The meta-property for the {@code addOns} property.
*/
private final MetaProperty addOns = DirectMetaProperty.ofImmutable(
this, "addOns", MarginBreakdown.class, Double.TYPE);
/**
* The meta-property for the {@code netLiquidatingValue} property.
*/
private final MetaProperty netLiquidatingValue = DirectMetaProperty.ofImmutable(
this, "netLiquidatingValue", MarginBreakdown.class, Double.TYPE);
/**
* The meta-properties.
*/
private final Map> metaPropertyMap$ = new DirectMetaPropertyMap(
this, null,
"totalMargin",
"baseMargin",
"addOns",
"netLiquidatingValue");
/**
* Restricted constructor.
*/
private Meta() {
}
@Override
protected MetaProperty> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case -924857838: // totalMargin
return totalMargin;
case -1007069217: // baseMargin
return baseMargin;
case -1422529005: // addOns
return addOns;
case 466596315: // netLiquidatingValue
return netLiquidatingValue;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder extends MarginBreakdown> builder() {
return new MarginBreakdown.Builder();
}
@Override
public Class extends MarginBreakdown> beanType() {
return MarginBreakdown.class;
}
@Override
public Map> metaPropertyMap() {
return metaPropertyMap$;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case -924857838: // totalMargin
return ((MarginBreakdown) bean).getTotalMargin();
case -1007069217: // baseMargin
return ((MarginBreakdown) bean).getBaseMargin();
case -1422529005: // addOns
return ((MarginBreakdown) bean).getAddOns();
case 466596315: // netLiquidatingValue
return ((MarginBreakdown) bean).getNetLiquidatingValue();
}
return super.propertyGet(bean, propertyName, quiet);
}
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
metaProperty(propertyName);
if (quiet) {
return;
}
throw new UnsupportedOperationException("Property cannot be written: " + propertyName);
}
}
//-----------------------------------------------------------------------
/**
* The bean-builder for {@code MarginBreakdown}.
*/
private static final class Builder extends DirectPrivateBeanBuilder {
private double totalMargin;
private double baseMargin;
private double addOns;
private double netLiquidatingValue;
/**
* Restricted constructor.
*/
private Builder() {
}
//-----------------------------------------------------------------------
@Override
public Object get(String propertyName) {
switch (propertyName.hashCode()) {
case -924857838: // totalMargin
return totalMargin;
case -1007069217: // baseMargin
return baseMargin;
case -1422529005: // addOns
return addOns;
case 466596315: // netLiquidatingValue
return netLiquidatingValue;
default:
throw new NoSuchElementException("Unknown property: " + propertyName);
}
}
@Override
public Builder set(String propertyName, Object newValue) {
switch (propertyName.hashCode()) {
case -924857838: // totalMargin
this.totalMargin = (Double) newValue;
break;
case -1007069217: // baseMargin
this.baseMargin = (Double) newValue;
break;
case -1422529005: // addOns
this.addOns = (Double) newValue;
break;
case 466596315: // netLiquidatingValue
this.netLiquidatingValue = (Double) newValue;
break;
default:
throw new NoSuchElementException("Unknown property: " + propertyName);
}
return this;
}
@Override
public MarginBreakdown build() {
return new MarginBreakdown(
totalMargin,
baseMargin,
addOns,
netLiquidatingValue);
}
//-----------------------------------------------------------------------
@Override
public String toString() {
StringBuilder buf = new StringBuilder(160);
buf.append("MarginBreakdown.Builder{");
buf.append("totalMargin").append('=').append(JodaBeanUtils.toString(totalMargin)).append(',').append(' ');
buf.append("baseMargin").append('=').append(JodaBeanUtils.toString(baseMargin)).append(',').append(' ');
buf.append("addOns").append('=').append(JodaBeanUtils.toString(addOns)).append(',').append(' ');
buf.append("netLiquidatingValue").append('=').append(JodaBeanUtils.toString(netLiquidatingValue));
buf.append('}');
return buf.toString();
}
}
//-------------------------- AUTOGENERATED END --------------------------
}