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
27 * @see MessageBuilderFactory
28 */
29 public interface MessageBuilder {
30 /**
31 * Append message content in success style.
32 * By default, bold green
33 * @param message the message to append
34 * @return the current builder
35 */
36 @Nonnull
37 MessageBuilder success(Object message);
38
39 /**
40 * Append message content in warning style.
41 * By default, bold yellow
42 * @param message the message to append
43 * @return the current builder
44 */
45 @Nonnull
46 MessageBuilder warning(Object message);
47
48 /**
49 * Append message content in failure style.
50 * By default, bold red
51 * @param message the message to append
52 * @return the current builder
53 */
54 @Nonnull
55 MessageBuilder failure(Object message);
56
57 /**
58 * Append message content in strong style.
59 * By default, bold
60 * @param message the message to append
61 * @return the current builder
62 */
63 @Nonnull
64 MessageBuilder strong(Object message);
65
66 /**
67 * Append message content in mojo style.
68 * By default, green
69 * @param message the message to append
70 * @return the current builder
71 */
72 @Nonnull
73 MessageBuilder mojo(Object message);
74
75 /**
76 * Append message content in project style.
77 * By default, cyan
78 * @param message the message to append
79 * @return the current builder
80 */
81 @Nonnull
82 MessageBuilder project(Object message);
83
84 //
85 // message building methods modelled after Ansi methods
86 //
87 /**
88 * Append content to the message buffer.
89 * @param value the content to append
90 * @param offset the index of the first {@code char} to append
91 * @param len the number of {@code char}s to append
92 * @return the current builder
93 */
94 @Nonnull
95 MessageBuilder a(char[] value, int offset, int len);
96
97 /**
98 * Append content to the message buffer.
99 * @param value the content to append
100 * @return the current builder
101 */
102 @Nonnull
103 MessageBuilder a(char[] value);
104
105 /**
106 * Append content to the message buffer.
107 * @param value the content to append
108 * @param start the starting index of the subsequence to be appended
109 * @param end the end index of the subsequence to be appended
110 * @return the current builder
111 */
112 @Nonnull
113 MessageBuilder a(CharSequence value, int start, int end);
114
115 /**
116 * Append content to the message buffer.
117 * @param value the content to append
118 * @return the current builder
119 */
120 @Nonnull
121 MessageBuilder a(CharSequence value);
122
123 /**
124 * Append content to the message buffer.
125 * @param value the content to append
126 * @return the current builder
127 */
128 @Nonnull
129 MessageBuilder a(Object value);
130
131 /**
132 * Append newline to the message buffer.
133 * @return the current builder
134 */
135 @Nonnull
136 MessageBuilder newline();
137
138 /**
139 * Append formatted content to the buffer.
140 * @see String#format(String, Object...)
141 * @param pattern a <a href="../util/Formatter.html#syntax">format string</a>
142 * @param args arguments referenced by the format specifiers in the format string
143 * @return the current builder
144 */
145 @Nonnull
146 MessageBuilder format(String pattern, Object... args);
147
148 /**
149 * Return the built message.
150 * @return the message
151 */
152 @Nonnull
153 String build();
154 }