예제 #1
0
        // split out for hotspot inlining
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") private <T> T tryDefaultValue(com.opengamma.strata.basics.ReferenceDataId<T> id)
        private T tryDefaultValue <T>(ReferenceDataId <T> id)
        {
            if (id is HolidayCalendarId)
            {
                return((T)ImmutableHolidayCalendar.of((HolidayCalendarId)id, ImmutableList.of(), WEEKEND_DAYS));
            }
            return(null);
        }
 // validates a single entry
 private static void validateEntry <T1>(ReferenceDataId <T1> id, object value)
 {
     if (!id.ReferenceDataType.IsInstanceOfType(value))
     {
         if (value == null)
         {
             throw new System.ArgumentException(Messages.format("Value for identifier '{}' must not be null", id));
         }
         throw new System.InvalidCastException(Messages.format("Value for identifier '{}' does not implement expected type '{}': '{}'", id, id.ReferenceDataType.Name, value));
     }
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public <T> T queryValueOrNull(ReferenceDataId<T> id)
            public override T queryValueOrNull <T>(ReferenceDataId <T> id)
            {
                return(id.Equals(ID2) ? (T)VAL2 : (id.Equals(ID1) ? (T)VAL1 : null));
            }
예제 #4
0
        public T queryValueOrNull <T>(ReferenceDataId <T> id)
        {
            T value1 = refData1.queryValueOrNull(id);

            return(value1 != null ? value1 : refData2.queryValueOrNull(id));
        }
예제 #5
0
 //-------------------------------------------------------------------------
 public override bool containsValue <T1>(ReferenceDataId <T1> id)
 {
     return(refData1.containsValue(id) || refData2.containsValue(id));
 }
 /// <summary>
 /// Obtains an instance from a single reference data entry.
 /// <para>
 /// This returns an instance containing a single entry based on the specified identifier and value.
 /// This is primarily of interest to test cases.
 /// </para>
 /// <para>
 /// The resulting {@code ImmutableReferenceData} instance does not include the
 /// <seealso cref="ReferenceData#minimal() minimal"/> set of reference data that is essential for pricing.
 ///
 /// </para>
 /// </summary>
 /// @param <T>  the type of the reference data </param>
 /// <param name="id">  the identifier </param>
 /// <param name="value">  the reference data values </param>
 /// <returns> the reference data instance </returns>
 /// <exception cref="ClassCastException"> if a value does not match the parameterized type associated with the identifier </exception>
 public static ImmutableReferenceData of <T>(ReferenceDataId <T> id, T value)
 {
     // validation handles edge case where input by raw or polluted types
     validateEntry(id, value);
     return(new ImmutableReferenceData(ImmutableMap.of(id, value)));
 }
 // this should be a private method on the interface
 // extracted to aid inlining performance
 internal static string msgValueNotFound <T1>(ReferenceDataId <T1> id)
 {
     return(Messages.format("Reference data not found for identifier '{}' of type '{}'", id, id.GetType().Name));
 }
        //-------------------------------------------------------------------------
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public <T> T queryValueOrNull(ReferenceDataId<T> id)
        public T queryValueOrNull <T>(ReferenceDataId <T> id)
        {
            // no type check against id.getReferenceDataType() as checked in factory
            return((T)values.get(id));
        }
예제 #9
0
 public override bool containsValue <T1>(ReferenceDataId <T1> id)
 {
     return(underlying.queryValueOrNull(id) != default(T1) || id is HolidayCalendarId);
 }
예제 #10
0
        //-------------------------------------------------------------------------
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public <T> T queryValueOrNull(com.opengamma.strata.basics.ReferenceDataId<T> id)
        public T queryValueOrNull <T>(ReferenceDataId <T> id)
        {
            T found = underlying.queryValueOrNull(id);

            return(found == null?tryDefaultValue(id) : found);
        }