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  {
33      private boolean success;
34  
35      private List<CompilerMessage> compilerMessages;
36  
37      /**
38       * Constructs a successful compiler result with no messages.
39       */
40      public CompilerResult()
41      {
42          this.success = true;
43      }
44  
45      /**
46       * Constructs a compiler result.
47       * 
48       * @param success if the compiler process was successful or not
49       * @param compilerMessages a list of messages from the compiler process
50       */
51      public CompilerResult( boolean success, List<CompilerMessage> compilerMessages )
52      {
53          this.success = success;
54          this.compilerMessages = compilerMessages;
55      }
56  
57      public boolean isSuccess()
58      {
59          return success;
60      }
61  
62      public void setSuccess( boolean success )
63      {
64          this.success = success;
65      }
66  
67      public CompilerResult success( boolean success )
68      {
69          this.setSuccess( success );
70          return this;
71      }
72  
73      public List<CompilerMessage> getCompilerMessages()
74      {
75          if ( compilerMessages == null )
76          {
77              this.compilerMessages = new ArrayList<CompilerMessage>();
78          }
79          return compilerMessages;
80      }
81  
82      public void setCompilerMessages( List<CompilerMessage> compilerMessages )
83      {
84          this.compilerMessages = compilerMessages;
85      }
86  
87      public CompilerResult compilerMessages( List<CompilerMessage> compilerMessages )
88      {
89          this.setCompilerMessages( compilerMessages );
90          return this;
91      }
92  }