/**
* Copyright (C) 2015 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.strata.product.cms;
import org.joda.convert.FromString;
import org.joda.convert.ToString;
import com.google.common.base.CaseFormat;
import com.opengamma.strata.collect.ArgChecker;
/**
* A CMS payment period type.
* <p>
* A CMS payment period is a CMS coupon, CMS caplet or CMS floorlet.
* All of these payments are defined in a unified manner by {@link CmsPeriod}.
*/
public enum CmsPeriodType {
/**
* CMS coupon.
*/
COUPON,
/**
* CMS caplet.
*/
CAPLET,
/**
* CMS floorlet.
*/
FLOORLET;
//-------------------------------------------------------------------------
/**
* Obtains the type from a unique name.
*
* @param uniqueName the unique name
* @return the type
* @throws IllegalArgumentException if the name is not known
*/
@FromString
public static CmsPeriodType of(String uniqueName) {
ArgChecker.notNull(uniqueName, "uniqueName");
return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, uniqueName));
}
/**
* Returns the formatted unique name of the type.
*
* @return the formatted string representing the type
*/
@ToString
@Override
public String toString() {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, name());
}
}