com.opengamma.sdk.margin.MarginDetailDeserializer 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.Optional;
import org.joda.beans.MetaBean;
import org.joda.beans.ser.DefaultDeserializer;
import org.joda.beans.ser.SerDeserializer;
import org.joda.beans.ser.SerDeserializerProvider;
/**
* Deserializes the result, handling the CCP specific nature of the response.
*/
final class MarginDetailDeserializer extends DefaultDeserializer implements SerDeserializerProvider {
/**
* The type of the detail.
*/
private final MetaBean detailMetaBean;
// converts a CCP to a deserializer instance
static Optional of(Ccp ccp) {
if (ccp == Ccp.LCH) {
return Optional.of(new MarginDetailDeserializer(LchMarginDetail.meta()));
} else {
return Optional.empty();
}
}
// constructor
MarginDetailDeserializer(MetaBean detailMetaBean) {
this.detailMetaBean = detailMetaBean;
}
//-------------------------------------------------------------------------
@Override
public SerDeserializer findDeserializer(Class> beanType) {
return beanType == MarginDetail.class ? this : null;
}
@Override
public MetaBean findMetaBean(Class> beanType) {
return detailMetaBean;
}
}