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 import org.apache.maven.api.annotations.Experimental;
25
26
27
28
29
30
31
32 @Experimental
33 public interface XmlWriterRequest<T> {
34
35 Path getPath();
36
37 OutputStream getOutputStream();
38
39 Writer getWriter();
40
41 T getContent();
42
43 static <T> XmlWriterRequestBuilder<T> builder() {
44 return new XmlWriterRequestBuilder<>();
45 }
46
47 class XmlWriterRequestBuilder<T> {
48 Path path;
49 OutputStream outputStream;
50 Writer writer;
51 T content;
52
53 public XmlWriterRequestBuilder<T> path(Path path) {
54 this.path = path;
55 return this;
56 }
57
58 public XmlWriterRequestBuilder<T> outputStream(OutputStream outputStream) {
59 this.outputStream = outputStream;
60 return this;
61 }
62
63 public XmlWriterRequestBuilder<T> writer(Writer writer) {
64 this.writer = writer;
65 return this;
66 }
67
68 public XmlWriterRequestBuilder<T> content(T content) {
69 this.content = content;
70 return this;
71 }
72
73 public XmlWriterRequest<T> build() {
74 return new DefaultXmlWriterRequest<>(path, outputStream, writer, content);
75 }
76
77 private static class DefaultXmlWriterRequest<T> implements XmlWriterRequest<T> {
78 final Path path;
79 final OutputStream outputStream;
80 final Writer writer;
81 final T content;
82
83 DefaultXmlWriterRequest(Path path, OutputStream outputStream, Writer writer, T content) {
84 this.path = path;
85 this.outputStream = outputStream;
86 this.writer = writer;
87 this.content = content;
88 }
89
90 @Override
91 public Path getPath() {
92 return path;
93 }
94
95 @Override
96 public OutputStream getOutputStream() {
97 return outputStream;
98 }
99
100 @Override
101 public Writer getWriter() {
102 return writer;
103 }
104
105 @Override
106 public T getContent() {
107 return content;
108 }
109 }
110 }
111 }