@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 97440432: // first return ((ObjIntPair<?>) bean).getFirst(); case -906279820: // second return ((ObjIntPair<?>) bean).getSecond(); } return super.propertyGet(bean, propertyName, quiet); }
@Override public ScenarioArray<?> convertedTo(Currency resultCurrency, ScenarioFxRateProvider fxRateProvider) { int scenarioCount = getScenarioCount(); if (fxRateProvider.getScenarioCount() != scenarioCount) { throw new IllegalArgumentException(Messages.format( "Expected {} FX rates but received {}", scenarioCount, fxRateProvider.getScenarioCount())); } ImmutableList<Object> converted = zipWithIndex(values.stream()) .map(tp -> convert(resultCurrency, fxRateProvider, tp.getFirst(), tp.getSecond())) .collect(toImmutableList()); return DefaultScenarioArray.of(converted); }
@Test(dataProvider = "factory") public void test_of_getters(String first, int second) { ObjIntPair<String> test = ObjIntPair.of(first, second); assertEquals(test.getFirst(), first); assertEquals(test.getSecond(), second, TOLERANCE); }
@Test(dataProvider = "factory") public void test_ofPair(String first, int second) { Pair<String, Integer> pair = Pair.of(first, second); ObjIntPair<String> test = ObjIntPair.ofPair(pair); assertEquals(test.getFirst(), first); assertEquals(test.getSecond(), second, TOLERANCE); }