StreamResource extends AbstractStreamResource { public StreamResource setContentType(String contentType) { if (contentType == null) { throw new IllegalArgumentException("Content type cannot be null"); } setContentTypeResolver((resource, context) -> contentType); return this; } StreamResource(String name, StreamResourceWriter writer);  StreamResource(String name, InputStreamFactory factory); StreamResourceWriter getWriter(); StreamResource setContentTypeResolver(ContentTypeResolver resolver); StreamResource setContentType(String contentType); ContentTypeResolver getContentTypeResolver(); @Override String getName();  }
@Test public void setContentType() { StreamResource resource = new StreamResource("foo", () -> makeEmptyStream()); resource.setContentType("bar"); Assert.assertNotNull(resource.getContentTypeResolver()); assertContentType(resource, resource.getContentTypeResolver()); }