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