View Javadoc
1   package org.codehaus.plexus.compiler;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  
24  /**
25   * The result returned from a compiling language processor (aka compiler), possibly including
26   * some messages.
27   *
28   * @author Olivier Lamy
29   * @since 2.0
30   */
31  public class CompilerResult {
32      private boolean success;
33  
34      private List<CompilerMessage> compilerMessages;
35  
36      /**
37       * Constructs a successful compiler result with no messages.
38       */
39      public CompilerResult() {
40          this.success = true;
41      }
42  
43      /**
44       * Constructs a compiler result.
45       *
46       * @param success if the compiler process was successful or not
47       * @param compilerMessages a list of messages from the compiler process
48       */
49      public CompilerResult(boolean success, List<CompilerMessage> compilerMessages) {
50          this.success = success;
51          this.compilerMessages = compilerMessages;
52      }
53  
54      public boolean isSuccess() {
55          return success;
56      }
57  
58      public void setSuccess(boolean success) {
59          this.success = success;
60      }
61  
62      public CompilerResult success(boolean success) {
63          this.setSuccess(success);
64          return this;
65      }
66  
67      public List<CompilerMessage> getCompilerMessages() {
68          if (compilerMessages == null) {
69              this.compilerMessages = new ArrayList<>();
70          }
71          return compilerMessages;
72      }
73  
74      public void setCompilerMessages(List<CompilerMessage> compilerMessages) {
75          this.compilerMessages = compilerMessages;
76      }
77  
78      public CompilerResult compilerMessages(List<CompilerMessage> compilerMessages) {
79          this.setCompilerMessages(compilerMessages);
80          return this;
81      }
82  }