1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.maven.api.services;
20
21 import org.apache.maven.api.annotations.Nonnull;
22
23 /**
24 * Message builder that supports configurable styling.
25 *
26 * @since 4.0.0
27 * @see MessageBuilderFactory
28 */
29 public interface MessageBuilder {
30
31 /**
32 * Append message content in trace style.
33 * By default, bold magenta
34 *
35 * @param message the message to append
36 * @return the current builder
37 */
38 @Nonnull
39 MessageBuilder trace(Object message);
40
41 /**
42 * Append message content in debug style.
43 * By default, bold cyan
44 *
45 * @param message the message to append
46 * @return the current builder
47 */
48 @Nonnull
49 MessageBuilder debug(Object message);
50
51 /**
52 * Append message content in info style.
53 * By default, bold blue
54 *
55 * @param message the message to append
56 * @return the current builder
57 */
58 @Nonnull
59 MessageBuilder info(Object message);
60
61 /**
62 * Append message content in warning style.
63 * By default, bold yellow
64 *
65 * @param message the message to append
66 * @return the current builder
67 */
68 @Nonnull
69 MessageBuilder warning(Object message);
70
71 /**
72 * Append message content in error style.
73 * By default, bold red
74 *
75 * @param message the message to append
76 * @return the current builder
77 */
78 @Nonnull
79 MessageBuilder error(Object message);
80
81 /**
82 * Append message content in success style.
83 * By default, bold green
84 *
85 * @param message the message to append
86 * @return the current builder
87 */
88 @Nonnull
89 MessageBuilder success(Object message);
90
91 /**
92 * Append message content in failure style.
93 * By default, bold red
94 *
95 * @param message the message to append
96 * @return the current builder
97 */
98 @Nonnull
99 MessageBuilder failure(Object message);
100
101 /**
102 * Append message content in strong style.
103 * By default, bold
104 *
105 * @param message the message to append
106 * @return the current builder
107 */
108 @Nonnull
109 MessageBuilder strong(Object message);
110
111 /**
112 * Append message content in mojo style.
113 * By default, green
114 *
115 * @param message the message to append
116 * @return the current builder
117 */
118 @Nonnull
119 MessageBuilder mojo(Object message);
120
121 /**
122 * Append message content in project style.
123 * By default, cyan
124 *
125 * @param message the message to append
126 * @return the current builder
127 */
128 @Nonnull
129 MessageBuilder project(Object message);
130
131 //
132 // message building methods modelled after Ansi methods
133 //
134 /**
135 * Append content to the message buffer.
136 *
137 * @param value the content to append
138 * @param offset the index of the first {@code char} to append
139 * @param len the number of {@code char}s to append
140 * @return the current builder
141 */
142 @Nonnull
143 MessageBuilder a(char[] value, int offset, int len);
144
145 /**
146 * Append content to the message buffer.
147 *
148 * @param value the content to append
149 * @return the current builder
150 */
151 @Nonnull
152 MessageBuilder a(char[] value);
153
154 /**
155 * Append content to the message buffer.
156 *
157 * @param value the content to append
158 * @param start the starting index of the subsequence to be appended
159 * @param end the end index of the subsequence to be appended
160 * @return the current builder
161 */
162 @Nonnull
163 MessageBuilder a(CharSequence value, int start, int end);
164
165 /**
166 * Append content to the message buffer.
167 *
168 * @param value the content to append
169 * @return the current builder
170 */
171 @Nonnull
172 MessageBuilder a(CharSequence value);
173
174 /**
175 * Append content to the message buffer.
176 *
177 * @param value the content to append
178 * @return the current builder
179 */
180 @Nonnull
181 MessageBuilder a(Object value);
182
183 /**
184 * Append newline to the message buffer.
185 *
186 * @return the current builder
187 */
188 @Nonnull
189 MessageBuilder newline();
190
191 /**
192 * Append formatted content to the buffer.
193 * @see String#format(String, Object...)
194 *
195 * @param pattern a <a href="../util/Formatter.html#syntax">format string</a>
196 * @param args arguments referenced by the format specifiers in the format string
197 * @return the current builder
198 */
199 @Nonnull
200 MessageBuilder format(String pattern, Object... args);
201
202 /**
203 * Return the built message.
204 *
205 * @return the message
206 */
207 @Nonnull
208 String build();
209
210 /**
211 * Set the buffer length.
212 *
213 * @param length the new length
214 */
215 void setLength(int length);
216 }