public static <E> ThriftType list(ThriftType valueType) { checkNotNull(valueType, "valueType is null"); return list(new DefaultThriftTypeReference(valueType)); }
@Test public void testCollectionThriftTypes() throws Exception { testRoundTripSerialize(set(STRING), ImmutableSet.of("some string", "another string")); testRoundTripSerialize(list(STRING), ImmutableList.of("some string", "another string")); testRoundTripSerialize(map(STRING, STRING), ImmutableMap.of("1", "one", "2", "two")); }
return list(getThriftType(elementType));
return list(getCollectionElementThriftTypeReference(elementType));
@Test public void testCoercedCollection() throws Exception { testRoundTripSerialize(set(I32.coerceTo(Integer.class)), ImmutableSet.of(1, 2, 3)); testRoundTripSerialize(list(I32.coerceTo(Integer.class)), ImmutableList.of(4, 5, 6)); testRoundTripSerialize(map(I32.coerceTo(Integer.class), I32.coerceTo(Integer.class)), ImmutableMap.of(1, 2, 2, 4, 3, 9)); }
@Test public void testEnum() throws Exception { ThriftEnumMetadata<Fruit> fruitEnumMetadata = new ThriftEnumMetadataBuilder<>(Fruit.class).build(); ThriftEnumMetadata<Letter> letterEnumMetadata = new ThriftEnumMetadataBuilder<>(Letter.class).build(); testRoundTripSerialize(Fruit.CHERRY); testRoundTripSerialize(Letter.C); testRoundTripSerialize(enumType(fruitEnumMetadata), Fruit.CHERRY); testRoundTripSerialize(enumType(letterEnumMetadata), Letter.C); testRoundTripSerialize(list(enumType(fruitEnumMetadata)), ImmutableList.copyOf(Fruit.values())); testRoundTripSerialize(list(enumType(letterEnumMetadata)), ImmutableList.copyOf(Letter.values())); }