View Javadoc
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.internal.impl;
20  
21  import org.apache.maven.api.annotations.Experimental;
22  import org.apache.maven.api.annotations.Nonnull;
23  import org.apache.maven.api.services.MessageBuilder;
24  
25  @Experimental
26  public class DefaultMessageBuilder implements MessageBuilder {
27  
28      private final StringBuilder buffer;
29  
30      public DefaultMessageBuilder() {
31          this(new StringBuilder());
32      }
33  
34      public DefaultMessageBuilder(StringBuilder buffer) {
35          this.buffer = buffer;
36      }
37  
38      @Override
39      @Nonnull
40      public MessageBuilder debug(Object o) {
41          return a(o);
42      }
43  
44      @Override
45      @Nonnull
46      public MessageBuilder info(Object o) {
47          return a(o);
48      }
49  
50      @Override
51      @Nonnull
52      public MessageBuilder warning(Object o) {
53          return a(o);
54      }
55  
56      @Override
57      @Nonnull
58      public MessageBuilder error(Object o) {
59          return a(o);
60      }
61  
62      @Override
63      @Nonnull
64      public MessageBuilder success(Object o) {
65          return a(o);
66      }
67  
68      @Override
69      @Nonnull
70      public MessageBuilder failure(Object o) {
71          return a(o);
72      }
73  
74      @Override
75      @Nonnull
76      public MessageBuilder strong(Object o) {
77          return a(o);
78      }
79  
80      @Override
81      @Nonnull
82      public MessageBuilder mojo(Object o) {
83          return a(o);
84      }
85  
86      @Override
87      @Nonnull
88      public MessageBuilder project(Object o) {
89          return a(o);
90      }
91  
92      @Override
93      @Nonnull
94      public MessageBuilder a(char[] chars, int i, int i1) {
95          buffer.append(chars, i, i1);
96          return this;
97      }
98  
99      @Override
100     @Nonnull
101     public MessageBuilder a(char[] chars) {
102         buffer.append(chars);
103         return this;
104     }
105 
106     @Override
107     @Nonnull
108     public MessageBuilder a(CharSequence charSequence, int i, int i1) {
109         buffer.append(charSequence, i, i1);
110         return this;
111     }
112 
113     @Override
114     @Nonnull
115     public MessageBuilder a(CharSequence charSequence) {
116         buffer.append(charSequence);
117         return this;
118     }
119 
120     @Override
121     @Nonnull
122     public MessageBuilder a(Object o) {
123         buffer.append(o);
124         return this;
125     }
126 
127     @Override
128     @Nonnull
129     public MessageBuilder newline() {
130         buffer.append(System.getProperty("line.separator"));
131         return this;
132     }
133 
134     @Override
135     @Nonnull
136     public MessageBuilder format(String s, Object... objects) {
137         buffer.append(String.format(s, objects));
138         return this;
139     }
140 
141     @Override
142     @Nonnull
143     public String build() {
144         return buffer.toString();
145     }
146 
147     @Override
148     public String toString() {
149         return build();
150     }
151 }