1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.api.services.xml;
20
21 import java.io.OutputStream;
22 import java.io.Writer;
23 import java.nio.file.Path;
24
25 import org.apache.maven.api.annotations.Experimental;
26
27
28
29
30
31
32
33 @Experimental
34 public interface XmlWriterRequest<T> {
35
36 Path getPath();
37
38 OutputStream getOutputStream();
39
40 Writer getWriter();
41
42 T getContent();
43
44 static <T> XmlWriterRequestBuilder<T> builder() {
45 return new XmlWriterRequestBuilder<>();
46 }
47
48 class XmlWriterRequestBuilder<T> {
49 Path path;
50 OutputStream outputStream;
51 Writer writer;
52 T content;
53
54 public XmlWriterRequestBuilder<T> path(Path path) {
55 this.path = path;
56 return this;
57 }
58
59 public XmlWriterRequestBuilder<T> outputStream(OutputStream outputStream) {
60 this.outputStream = outputStream;
61 return this;
62 }
63
64 public XmlWriterRequestBuilder<T> writer(Writer writer) {
65 this.writer = writer;
66 return this;
67 }
68
69 public XmlWriterRequestBuilder<T> content(T content) {
70 this.content = content;
71 return this;
72 }
73
74 public XmlWriterRequest<T> build() {
75 return new DefaultXmlWriterRequest<>(path, outputStream, writer, content);
76 }
77
78 private static class DefaultXmlWriterRequest<T> implements XmlWriterRequest<T> {
79 final Path path;
80 final OutputStream outputStream;
81 final Writer writer;
82 final T content;
83
84 DefaultXmlWriterRequest(Path path, OutputStream outputStream, Writer writer, T content) {
85 this.path = path;
86 this.outputStream = outputStream;
87 this.writer = writer;
88 this.content = content;
89 }
90
91 @Override
92 public Path getPath() {
93 return path;
94 }
95
96 @Override
97 public OutputStream getOutputStream() {
98 return outputStream;
99 }
100
101 @Override
102 public Writer getWriter() {
103 return writer;
104 }
105
106 @Override
107 public T getContent() {
108 return content;
109 }
110 }
111 }
112 }