All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.opengamma.sdk.margin.MarginDetailDeserializer Maven / Gradle / Ivy

There is a newer version: 3.6.4
Show newest version
/*
 * 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;
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy