@Override public String toString() { return Messages.format("SyntheticCurveCalibrator[{}, {}]", calibrator, measures); }
@Test(dataProvider = "formatMessageWithAttributes") public void test_formatMessageWithAttributes( String template, Object[] args, Pair<String, Map<String, String>> expectedOutput) { assertEquals(Messages.formatWithAttributes(template, args), expectedOutput); }
@Override public String toString() { return Messages.format("CurveCalibrator[{}]", measures); }
/** * Creates an instance, specifying the definition that caused the problem. * <p> * The message is formatted using {@link Messages#format(String, Object...)}. * Message formatting is null tolerant to avoid hiding this exception. * * @param definition the invalid schedule definition, null tolerant * @param msgTemplate the message template, null tolerant * @param msgArguments the message arguments, null tolerant */ public ScheduleException(PeriodicSchedule definition, String msgTemplate, Object... msgArguments) { super(Messages.format(msgTemplate, msgArguments)); this.definition = definition; }
@Override public <T> T getInfo(CurveInfoType<T> type) { // overridden for performance @SuppressWarnings("unchecked") T value = (T) info.get(type); if (value == null) { throw new IllegalArgumentException(Messages.format("Curve info not found for type '{}'", type)); } return value; }
@Override public <T> T getInfo(SurfaceInfoType<T> type) { // overridden for performance @SuppressWarnings("unchecked") T value = (T) info.get(type); if (value == null) { throw new IllegalArgumentException(Messages.format("Surface info not found for type '{}'", type)); } return value; }
private String msgValueNotFound(MarketDataId<?> id) { return Messages.format( "Market data not found for identifier '{}' of type '{}'", id, id.getClass().getSimpleName()); }
@Override public String formatForCsv(Object object) { return Messages.format("<{}>", object.getClass().getSimpleName()); }
static final String msgValueNotFound(ReferenceDataId<?> id) { return Messages.format( "Reference data not found for identifier '{}' of type '{}'", id, id.getClass().getSimpleName()); }
private String msgValueNotFound(MarketDataId<?> id) { return Messages.format( "Market data not found for identifier '{}' of type '{}'", id, id.getClass().getSimpleName()); }
@SuppressWarnings("unchecked") private <T extends ResolvedTrade> CalibrationMeasure<ResolvedTrade> getMeasure(ResolvedTrade trade) { Class<? extends ResolvedTrade> tradeType = trade.getClass(); CalibrationMeasure<? extends ResolvedTrade> measure = measuresByTrade.get(tradeType); if (measure == null) { throw new IllegalArgumentException(Messages.format( "Trade type '{}' is not supported for calibration", tradeType.getSimpleName())); } // cast makes life easier for the code using this method return (CalibrationMeasure<ResolvedTrade>) measure; }
@Override public String formatForDisplay(Object object) { Set<String> validTokens = ValuePathEvaluator.tokens(object); if (validTokens.isEmpty()) { return Messages.format("<{}> - drilling into this type is not supported", object.getClass().getSimpleName()); } else { List<String> orderedTokens = new ArrayList<>(validTokens); orderedTokens.sort(null); return Messages.format("<{}> - drill down using a field: {}", object.getClass().getSimpleName(), orderedTokens); } }
/** * Gets a single sensitivity instance by name. * * @param name the curve name to find * @return the matching sensitivity * @throws IllegalArgumentException if the name and currency do not match an entry */ public UnitParameterSensitivity getSensitivity(MarketDataName<?> name) { return findSensitivity(name) .orElseThrow(() -> new IllegalArgumentException(Messages.format( "Unable to find sensitivity: {}", name))); }
static void checkType(MarketDataId<?> id, Object value) { if (!id.getMarketDataType().isInstance(value)) { if (value == null) { throw new IllegalArgumentException(Messages.format( "Value for identifier '{}' must not be null", id)); } throw new ClassCastException(Messages.format( "Value for identifier '{}' does not implement expected type '{}': '{}'", id, id.getMarketDataType().getSimpleName(), value)); } }
@ImmutableValidator private void validate() { if (minGapInDays < 1) { throw new IllegalArgumentException(Messages.format( "Minimum gap must be at least one day, but was {}", minGapInDays)); } }
private static void validateEntry(ReferenceDataId<?> id, Object value) { if (!id.getReferenceDataType().isInstance(value)) { if (value == null) { throw new IllegalArgumentException(Messages.format( "Value for identifier '{}' must not be null", id)); } throw new ClassCastException(Messages.format( "Value for identifier '{}' does not implement expected type '{}': '{}'", id, id.getReferenceDataType().getSimpleName(), value)); } }
@Override public <T> T getAttribute(AttributeType<T> type) { return findAttribute(type).orElseThrow(() -> new IllegalArgumentException( Messages.format("Attribute not found for type '{}'", type))); }
@Override public <T> T getAttribute(AttributeType<T> type) { return findAttribute(type).orElseThrow(() -> new IllegalArgumentException( Messages.format("Attribute not found for type '{}'", type))); }
@Override public <T> T getAttribute(AttributeType<T> type) { return findAttribute(type).orElseThrow(() -> new IllegalArgumentException( Messages.format("Attribute not found for type '{}'", type))); }
/** * Gets a single sensitivity instance by name and currency. * * @param name the curve name to find * @param currency the currency to find * @return the matching sensitivity * @throws IllegalArgumentException if the name and currency do not match an entry */ public CrossGammaParameterSensitivity getSensitivity(MarketDataName<?> name, Currency currency) { return findSensitivity(name, currency) .orElseThrow(() -> new IllegalArgumentException(Messages.format( "Unable to find sensitivity: {} for {}", name, currency))); }