@Test public void fromProxy() { TypeMirror typeMirror = declaredTypeOf(ImmutableList.class, Integer.class); Serializer serializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment).get(); CodeBlock actualCodeBlock = serializer.fromProxy(CodeBlock.of("x")); assertThat(actualCodeBlock.toString()) .isEqualTo( String.format( "x.stream().map(%s.wrapper(value$ -> value$)).collect(%s.toImmutableList())", FUNCTION_WITH_EXCEPTIONS, IMMUTABLE_LIST)); }
@Override public Optional<Serializer> getSerializer( TypeMirror typeMirror, SerializerFactory factory, ProcessingEnvironment processingEnv) { if (!isImmutableList(typeMirror)) { return Optional.empty(); } TypeMirror containedType = getContainedType(typeMirror); Serializer containedTypeSerializer = factory.getSerializer(containedType); if (containedTypeSerializer.isIdentity()) { return Optional.empty(); } return Optional.of(new ImmutableListSerializer(containedTypeSerializer, processingEnv)); }
ImmutableListSerializerExtension implements SerializerExtension { @Override public Optional<Serializer> getSerializer( TypeMirror typeMirror, SerializerFactory factory, ProcessingEnvironment processingEnv) { if (!isImmutableList(typeMirror)) { return Optional.empty(); } TypeMirror containedType = getContainedType(typeMirror); Serializer containedTypeSerializer = factory.getSerializer(containedType); if (containedTypeSerializer.isIdentity()) { return Optional.empty(); } return Optional.of(new ImmutableListSerializer(containedTypeSerializer, processingEnv)); } }
ImmutableListSerializerExtension implements SerializerExtension { @Override public Optional<Serializer> getSerializer( TypeMirror typeMirror, SerializerFactory factory, ProcessingEnvironment processingEnv) { if (!isImmutableList(typeMirror)) { return Optional.empty(); } TypeMirror containedType = getContainedType(typeMirror); Serializer containedTypeSerializer = factory.getSerializer(containedType); if (containedTypeSerializer.isIdentity()) { return Optional.empty(); } return Optional.of(new ImmutableListSerializer(containedTypeSerializer, processingEnv)); } ImmutableListSerializerExtension(); }
ImmutableListSerializerExtension implements SerializerExtension { @Override public Optional<Serializer> getSerializer( TypeMirror typeMirror, SerializerFactory factory, ProcessingEnvironment processingEnv) { if (!isImmutableList(typeMirror)) { return Optional.empty(); } TypeMirror containedType = getContainedType(typeMirror); Serializer containedTypeSerializer = factory.getSerializer(containedType); if (containedTypeSerializer.isIdentity()) { return Optional.empty(); } return Optional.of(new ImmutableListSerializer(containedTypeSerializer, processingEnv)); } ImmutableListSerializerExtension(); @Override Optional<Serializer> getSerializer(
      TypeMirror typeMirror, SerializerFactory factory, ProcessingEnvironment processingEnv); }
ImmutableListSerializerExtension implements SerializerExtension { @Override public Optional<Serializer> getSerializer( TypeMirror typeMirror, SerializerFactory factory, ProcessingEnvironment processingEnv) { if (!isImmutableList(typeMirror)) { return Optional.empty(); } TypeMirror containedType = getContainedType(typeMirror); Serializer containedTypeSerializer = factory.getSerializer(containedType); if (containedTypeSerializer.isIdentity()) { return Optional.empty(); } return Optional.of(new ImmutableListSerializer(containedTypeSerializer, processingEnv)); } ImmutableListSerializerExtension(); @Override Optional<Serializer> getSerializer(
      TypeMirror typeMirror, SerializerFactory factory, ProcessingEnvironment processingEnv);  }