List of usage examples for org.apache.commons.lang3.tuple Pair getValue
@Override
public R getValue()
Gets the value from this pair.
This method implements the Map.Entry interface returning the right element as the value.
From source file:com.trenako.utility.PeriodUtilsTests.java
@Test public void shouldCalculatePeriodForOneHour() { int numberOfHours = 1; DateTime start = new DateTime(2010, 1, 1, 10, 30); DateTime end = start.plusHours(numberOfHours); Pair<String, Integer> hourPair = PeriodUtils.period(start, end); assertEquals(HOUR_LABEL, hourPair.getKey()); assertEquals(numberOfHours, (int) hourPair.getValue()); }
From source file:com.trenako.utility.PeriodUtilsTests.java
@Test public void shouldCalculatePeriodForWeeks() { int numberOfWeeks = 3; DateTime start = new DateTime(2010, 1, 1, 10, 30); DateTime end = start.plusWeeks(numberOfWeeks); Pair<String, Integer> weekPair = PeriodUtils.period(start, end); assertEquals(WEEKS_LABEL, weekPair.getKey()); assertEquals(numberOfWeeks, (int) weekPair.getValue()); }
From source file:com.trenako.utility.PeriodUtilsTests.java
@Test public void shouldCalculatePeriodForHours() { int numberOfHours = 23; DateTime start = new DateTime(2010, 1, 1, 10, 30); DateTime end = start.plusHours(numberOfHours); Pair<String, Integer> hourPair = PeriodUtils.period(start, end); assertEquals(HOURS_LABEL, hourPair.getKey()); assertEquals(numberOfHours, (int) hourPair.getValue()); }
From source file:com.trenako.utility.PeriodUtilsTests.java
@Test public void shouldCalculatePeriodForOneYear() { int numberOfYears = 1; DateTime start = new DateTime(2010, 1, 1, 10, 30); DateTime end = start.plusYears(numberOfYears); Pair<String, Integer> yearsPair = PeriodUtils.period(start, end); assertEquals(YEAR_LABEL, yearsPair.getKey()); assertEquals(numberOfYears, (int) yearsPair.getValue()); }
From source file:com.trenako.utility.PeriodUtilsTests.java
@Test public void shouldCalculatePeriodForYears() { int numberOfYears = 3; DateTime start = new DateTime(2010, 1, 1, 10, 30); DateTime end = start.plusYears(numberOfYears); Pair<String, Integer> yearsPair = PeriodUtils.period(start, end); assertEquals(YEARS_LABEL, yearsPair.getKey()); assertEquals(numberOfYears, (int) yearsPair.getValue()); }
From source file:com.trenako.utility.PeriodUtilsTests.java
@Test public void shouldCalculatePeriodForOneMonth() { int numberOfMonths = 1; DateTime start = new DateTime(2010, 1, 1, 10, 30); DateTime end = start.plusMonths(numberOfMonths); Pair<String, Integer> monthPair = PeriodUtils.period(start, end); assertEquals(MONTH_LABEL, monthPair.getKey()); assertEquals(numberOfMonths, (int) monthPair.getValue()); }
From source file:com.astamuse.asta4d.web.test.form.field.FieldRenderBuilder.java
public Renderer toRenderer(boolean forEdit) { Renderer renderer = Renderer.create(); for (FormFieldPrepareRenderer prepare : prepareList) { String fieldName = ((SimpleFormFieldPrepareRenderer) prepare).getGivenFieldName(); renderer.add(prepare.preRender(editSelector(fieldName), displaySelector(fieldName))); }/* w ww. ja v a 2 s .c o m*/ FormFieldValueRenderer valueRenderer; try { valueRenderer = valueRenderCls.newInstance(); for (Pair<String, Object> value : valueList) { String edit = editSelector(value.getKey()); String display = displaySelector(value.getKey()); renderer.add(forEdit ? valueRenderer.renderForEdit(edit, value.getValue()) : valueRenderer.renderForDisplay(edit, display, value.getValue())); } } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException(e); } for (FormFieldPrepareRenderer prepare : prepareList) { String fieldName = ((SimpleFormFieldPrepareRenderer) prepare).getGivenFieldName(); renderer.add(prepare.postRender(editSelector(fieldName), displaySelector(fieldName))); } return renderer; }
From source file:com.trenako.utility.PeriodUtilsTests.java
@Test public void shouldCalculatePeriodForMonths() { int numberOfMonths = 11; DateTime start = new DateTime(2010, 1, 1, 10, 30); DateTime end = start.plusMonths(numberOfMonths); Pair<String, Integer> monthPair = PeriodUtils.period(start, end); assertEquals(MONTHS_LABEL, monthPair.getKey()); assertEquals(numberOfMonths, (int) monthPair.getValue()); }
From source file:com.linkedin.pinot.server.api.resources.MmapDebugResource.java
@GET @Path("memory/offheap") @ApiOperation(value = "View current off-heap allocations", notes = "Lists all off-heap allocations and their associated sizes") @ApiResponses(value = { @ApiResponse(code = 200, message = "Success") }) @Produces(MediaType.APPLICATION_JSON)//from w w w .j av a2s . co m public Map<String, List<AllocationInfo>> getOffHeapSizes() throws ResourceException { List<AllocationInfo> allocations = new ArrayList<>(); List<Pair<MmapUtils.AllocationContext, Integer>> allocationsMap = MmapUtils.getAllocationsAndSizes(); for (Pair<MmapUtils.AllocationContext, Integer> allocation : allocationsMap) { AllocationInfo info = new AllocationInfo(); info.context = allocation.getKey().getContext(); info.type = allocation.getKey().getContext(); info.size = allocation.getValue(); allocations.add(info); } Map<String, List<AllocationInfo>> allocationMap = new HashMap<>(); allocationMap.put("allocations", allocations); return allocationMap; }
From source file:com.trenako.utility.PeriodUtilsTests.java
@Test public void shouldCalculatePeriodForOneMinute() { int numberOfMinutes = 1; DateTime start = new DateTime(2010, 1, 1, 10, 30); DateTime end = start.plusMinutes(numberOfMinutes); Pair<String, Integer> minutePair = PeriodUtils.period(start, end); assertEquals(MINUTE_LABEL, minutePair.getKey()); assertEquals(numberOfMinutes, (int) minutePair.getValue()); }