//------------------------------------------------------------------------- public override T getInfo <T>(SurfaceInfoType <T> type) { //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") T value = (T) info.get(type); T value = (T)info.get(type); if (value == null) { throw new System.ArgumentException(Messages.format("Surface info not found for type '{}'", type)); } return(value); }
//------------------------------------------------------------------------- /// <summary> /// Adds a single piece of additional information. /// <para> /// This is stored in the additional information map using {@code Map.put} semantics, /// removing the key if the instance is null. /// /// </para> /// </summary> /// @param <T> the type of the info </param> /// <param name="type"> the type to store under </param> /// <param name="value"> the value to store, may be null </param> /// <returns> this, for chaining </returns> public DefaultSurfaceMetadataBuilder addInfo <T>(SurfaceInfoType <T> type, T value) { ArgChecker.notNull(type, "type"); if (value != default(T)) { this.info[type] = value; } else { this.info.Remove(type); } return(this); }
public virtual void test_builder2() { DefaultSurfaceMetadata test = DefaultSurfaceMetadata.builder().surfaceName(SURFACE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.DISCOUNT_FACTOR).zValueType(ValueType.ZERO_RATE).dayCount(ACT_365F).addInfo(SurfaceInfoType.DAY_COUNT, null).addInfo(DESCRIPTION, "Hello").parameterMetadata(ImmutableList.of(ParameterMetadata.empty())).build(); assertThat(test.SurfaceName).isEqualTo(SURFACE_NAME); assertThat(test.XValueType).isEqualTo(ValueType.YEAR_FRACTION); assertThat(test.YValueType).isEqualTo(ValueType.DISCOUNT_FACTOR); assertThat(test.ZValueType).isEqualTo(ValueType.ZERO_RATE); assertThrowsIllegalArg(() => test.getInfo(SurfaceInfoType.DAY_COUNT)); assertThat(test.findInfo(SurfaceInfoType.DAY_COUNT)).Empty; assertThat(test.getInfo(DESCRIPTION)).isEqualTo("Hello"); assertThat(test.findInfo(DESCRIPTION)).isEqualTo(("Hello")); assertThat(test.findInfo(SurfaceInfoType.of("Rubbish"))).isEqualTo(null); assertThat(test.ParameterMetadata.Present).True; assertThat(test.ParameterMetadata.get()).containsExactly(ParameterMetadata.empty()); }
//------------------------------------------------------------------------- public DefaultSurfaceMetadata withInfo <T>(SurfaceInfoType <T> type, T value) { return(toBuilder().addInfo(type, value).build()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public <T> java.util.Optional<T> findInfo(SurfaceInfoType<T> type) public Optional <T> findInfo <T>(SurfaceInfoType <T> type) { return(Optional.ofNullable((T)info.get(type))); }
public virtual void coverage() { SurfaceInfoType <string> test = SurfaceInfoType.of("Foo"); assertEquals(test.ToString(), "Foo"); }
public virtual void test_MONEYNESS_TYPE() { SurfaceInfoType <MoneynessType> test = SurfaceInfoType.MONEYNESS_TYPE; assertEquals(test.ToString(), "MoneynessType"); }
public virtual void test_DAY_COUNT() { SurfaceInfoType <DayCount> test = SurfaceInfoType.DAY_COUNT; assertEquals(test.ToString(), "DayCount"); }