/** * Converts to an {@link OvernightIndex}. * * <p>If this is an Overnight index, then this returns the matching {@link OvernightIndex}. If * not, an exception is thrown. * * @return the index * @throws IllegalStateException if the type is not an Overnight index type * @see #getType() */ public OvernightIndex toOvernightIndex() { if (!type.isOvernight()) { throw new IllegalStateException("Incorrect index type, expected Overnight: " + name); } return OvernightIndex.of(indexName); }
/** * Converts to an {@link PriceIndex}. * * <p>If this is a price index, then this returns the matching {@link PriceIndex}. If not, an * exception is thrown. * * @return the index * @throws IllegalStateException if the type is not a price index type * @see #getType() */ public PriceIndex toPriceIndex() { if (!type.isPrice()) { throw new IllegalStateException("Incorrect index type, expected Price: " + name); } return PriceIndex.of(indexName); }
/** * Checks and returns an Ibor index. * * <p>If this is an Ibor index, then this returns the matching {@link IborIndex}. If not, an * exception is thrown. * * @param tenor the tenor of the index * @return the index * @throws IllegalStateException if the type is not an Ibor index type * @see #getType() */ public IborIndex toIborIndex(Tenor tenor) { if (!type.isIbor()) { throw new IllegalStateException("Incorrect index type, expected Ibor: " + name); } return IborIndex.of(indexName + tenor.normalized().toString()); }