com.opengamma.sdk.margin.LchMarginScenario 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.time.LocalDate;
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;
/**
* Details about a scenario that was chosen for the margin calculation.
*/
@BeanDefinition(builderScope = "private", metaScope = "private", factoryName = "of")
public final class LchMarginScenario implements ImmutableBean {
/**
* The scenario identifier.
*/
@PropertyDefinition(validate = "notNull")
private final String id;
/**
* The date of the scenario.
*/
@PropertyDefinition
private final LocalDate date;
/**
* The scaled profit-and-loss at the portfolio level, expressed in the reporting currency.
*/
@PropertyDefinition(validate = "notNull")
private final double scaledPortfolioPnl;
/**
* The unscaled profit-and-loss at the portfolio level, expressed in the reporting currency.
*/
@PropertyDefinition(validate = "notNull")
private final double unscaledPortfolioPnl;
//------------------------- AUTOGENERATED START -------------------------
/**
* The meta-bean for {@code LchMarginScenario}.
* @return the meta-bean, not null
*/
public static MetaBean meta() {
return LchMarginScenario.Meta.INSTANCE;
}
static {
MetaBean.register(LchMarginScenario.Meta.INSTANCE);
}
/**
* Obtains an instance.
* @param id the value of the property, not null
* @param date the value of the property
* @param scaledPortfolioPnl the value of the property, not null
* @param unscaledPortfolioPnl the value of the property, not null
* @return the instance
*/
public static LchMarginScenario of(
String id,
LocalDate date,
double scaledPortfolioPnl,
double unscaledPortfolioPnl) {
return new LchMarginScenario(
id,
date,
scaledPortfolioPnl,
unscaledPortfolioPnl);
}
private LchMarginScenario(
String id,
LocalDate date,
double scaledPortfolioPnl,
double unscaledPortfolioPnl) {
JodaBeanUtils.notNull(id, "id");
JodaBeanUtils.notNull(scaledPortfolioPnl, "scaledPortfolioPnl");
JodaBeanUtils.notNull(unscaledPortfolioPnl, "unscaledPortfolioPnl");
this.id = id;
this.date = date;
this.scaledPortfolioPnl = scaledPortfolioPnl;
this.unscaledPortfolioPnl = unscaledPortfolioPnl;
}
@Override
public MetaBean metaBean() {
return LchMarginScenario.Meta.INSTANCE;
}
//-----------------------------------------------------------------------
/**
* Gets the scenario identifier.
* @return the value of the property, not null
*/
public String getId() {
return id;
}
//-----------------------------------------------------------------------
/**
* Gets the date of the scenario.
* @return the value of the property
*/
public LocalDate getDate() {
return date;
}
//-----------------------------------------------------------------------
/**
* Gets the scaled profit-and-loss at the portfolio level, expressed in the reporting currency.
* @return the value of the property, not null
*/
public double getScaledPortfolioPnl() {
return scaledPortfolioPnl;
}
//-----------------------------------------------------------------------
/**
* Gets the unscaled profit-and-loss at the portfolio level, expressed in the reporting currency.
* @return the value of the property, not null
*/
public double getUnscaledPortfolioPnl() {
return unscaledPortfolioPnl;
}
//-----------------------------------------------------------------------
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj != null && obj.getClass() == this.getClass()) {
LchMarginScenario other = (LchMarginScenario) obj;
return JodaBeanUtils.equal(id, other.id) &&
JodaBeanUtils.equal(date, other.date) &&
JodaBeanUtils.equal(scaledPortfolioPnl, other.scaledPortfolioPnl) &&
JodaBeanUtils.equal(unscaledPortfolioPnl, other.unscaledPortfolioPnl);
}
return false;
}
@Override
public int hashCode() {
int hash = getClass().hashCode();
hash = hash * 31 + JodaBeanUtils.hashCode(id);
hash = hash * 31 + JodaBeanUtils.hashCode(date);
hash = hash * 31 + JodaBeanUtils.hashCode(scaledPortfolioPnl);
hash = hash * 31 + JodaBeanUtils.hashCode(unscaledPortfolioPnl);
return hash;
}
@Override
public String toString() {
StringBuilder buf = new StringBuilder(160);
buf.append("LchMarginScenario{");
buf.append("id").append('=').append(id).append(',').append(' ');
buf.append("date").append('=').append(date).append(',').append(' ');
buf.append("scaledPortfolioPnl").append('=').append(scaledPortfolioPnl).append(',').append(' ');
buf.append("unscaledPortfolioPnl").append('=').append(JodaBeanUtils.toString(unscaledPortfolioPnl));
buf.append('}');
return buf.toString();
}
//-----------------------------------------------------------------------
/**
* The meta-bean for {@code LchMarginScenario}.
*/
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 id} property.
*/
private final MetaProperty id = DirectMetaProperty.ofImmutable(
this, "id", LchMarginScenario.class, String.class);
/**
* The meta-property for the {@code date} property.
*/
private final MetaProperty date = DirectMetaProperty.ofImmutable(
this, "date", LchMarginScenario.class, LocalDate.class);
/**
* The meta-property for the {@code scaledPortfolioPnl} property.
*/
private final MetaProperty scaledPortfolioPnl = DirectMetaProperty.ofImmutable(
this, "scaledPortfolioPnl", LchMarginScenario.class, Double.TYPE);
/**
* The meta-property for the {@code unscaledPortfolioPnl} property.
*/
private final MetaProperty unscaledPortfolioPnl = DirectMetaProperty.ofImmutable(
this, "unscaledPortfolioPnl", LchMarginScenario.class, Double.TYPE);
/**
* The meta-properties.
*/
private final Map> metaPropertyMap$ = new DirectMetaPropertyMap(
this, null,
"id",
"date",
"scaledPortfolioPnl",
"unscaledPortfolioPnl");
/**
* Restricted constructor.
*/
private Meta() {
}
@Override
protected MetaProperty> metaPropertyGet(String propertyName) {
switch (propertyName.hashCode()) {
case 3355: // id
return id;
case 3076014: // date
return date;
case 670338368: // scaledPortfolioPnl
return scaledPortfolioPnl;
case 1679919001: // unscaledPortfolioPnl
return unscaledPortfolioPnl;
}
return super.metaPropertyGet(propertyName);
}
@Override
public BeanBuilder extends LchMarginScenario> builder() {
return new LchMarginScenario.Builder();
}
@Override
public Class extends LchMarginScenario> beanType() {
return LchMarginScenario.class;
}
@Override
public Map> metaPropertyMap() {
return metaPropertyMap$;
}
//-----------------------------------------------------------------------
@Override
protected Object propertyGet(Bean bean, String propertyName, boolean quiet) {
switch (propertyName.hashCode()) {
case 3355: // id
return ((LchMarginScenario) bean).getId();
case 3076014: // date
return ((LchMarginScenario) bean).getDate();
case 670338368: // scaledPortfolioPnl
return ((LchMarginScenario) bean).getScaledPortfolioPnl();
case 1679919001: // unscaledPortfolioPnl
return ((LchMarginScenario) bean).getUnscaledPortfolioPnl();
}
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 LchMarginScenario}.
*/
private static final class Builder extends DirectPrivateBeanBuilder {
private String id;
private LocalDate date;
private double scaledPortfolioPnl;
private double unscaledPortfolioPnl;
/**
* Restricted constructor.
*/
private Builder() {
}
//-----------------------------------------------------------------------
@Override
public Object get(String propertyName) {
switch (propertyName.hashCode()) {
case 3355: // id
return id;
case 3076014: // date
return date;
case 670338368: // scaledPortfolioPnl
return scaledPortfolioPnl;
case 1679919001: // unscaledPortfolioPnl
return unscaledPortfolioPnl;
default:
throw new NoSuchElementException("Unknown property: " + propertyName);
}
}
@Override
public Builder set(String propertyName, Object newValue) {
switch (propertyName.hashCode()) {
case 3355: // id
this.id = (String) newValue;
break;
case 3076014: // date
this.date = (LocalDate) newValue;
break;
case 670338368: // scaledPortfolioPnl
this.scaledPortfolioPnl = (Double) newValue;
break;
case 1679919001: // unscaledPortfolioPnl
this.unscaledPortfolioPnl = (Double) newValue;
break;
default:
throw new NoSuchElementException("Unknown property: " + propertyName);
}
return this;
}
@Override
public LchMarginScenario build() {
return new LchMarginScenario(
id,
date,
scaledPortfolioPnl,
unscaledPortfolioPnl);
}
//-----------------------------------------------------------------------
@Override
public String toString() {
StringBuilder buf = new StringBuilder(160);
buf.append("LchMarginScenario.Builder{");
buf.append("id").append('=').append(JodaBeanUtils.toString(id)).append(',').append(' ');
buf.append("date").append('=').append(JodaBeanUtils.toString(date)).append(',').append(' ');
buf.append("scaledPortfolioPnl").append('=').append(JodaBeanUtils.toString(scaledPortfolioPnl)).append(',').append(' ');
buf.append("unscaledPortfolioPnl").append('=').append(JodaBeanUtils.toString(unscaledPortfolioPnl));
buf.append('}');
return buf.toString();
}
}
//-------------------------- AUTOGENERATED END --------------------------
}