BagGrouped implements Pack, Unpack { public static Long interpretLong(Object v) { if (v == null) { return null; } else if (v instanceof Number) { return ((Number) v).longValue(); } else if (v instanceof String) { return Longs.tryParse((String) v); } else { return null; } } BagGrouped(ByteString bagId, GroupBySpec spec, Namespace<ByteString, ByteString> active,
            Namespace<ByteString, ByteString> archive); static Long interpretLong(Object v); @Override void pack(List<Object[]> tuples); @Override Object[][] unpack(); final Namespace<ByteString, ByteString> ACTIVE; final GroupBySpec spec; final ByteString bagId; final int tupleSize; }
@Test public void testInterpretLong() { assertEquals(null, BagGrouped.interpretLong(null)); assertEquals((Long) 1L, BagGrouped.interpretLong(1)); assertEquals((Long) 5L, BagGrouped.interpretLong(5.7)); assertEquals((Long) 1L, BagGrouped.interpretLong("1")); assertEquals(null, BagGrouped.interpretLong("5.7")); assertEquals(null, BagGrouped.interpretLong("hello")); }