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