View Javadoc

1   package org.apache.maven.surefire.report;
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  /**
23   * @author Kristian Rosenvold
24   */
25  public class CategorizedReportEntry
26      extends SimpleReportEntry
27      implements ReportEntry
28  {
29      private final String group;
30  
31      public CategorizedReportEntry( String source, String name, String group )
32      {
33          this( source, name, group, null, null );
34      }
35  
36      public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
37                                     Integer elapsed )
38      {
39          super( source, name, stackTraceWriter, elapsed );
40          this.group = group;
41      }
42  
43      public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
44                                     Integer elapsed, String message )
45      {
46          super( source, name, stackTraceWriter, elapsed, message );
47          this.group = group;
48      }
49  
50      public static ReportEntry reportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
51                                             Integer elapsed, String message )
52      {
53          return group != null
54              ? new CategorizedReportEntry( source, name, group, stackTraceWriter, elapsed, message )
55              : new SimpleReportEntry( source, name, stackTraceWriter, elapsed, message );
56      }
57  
58      public String getGroup()
59      {
60          return group;
61      }
62  
63      public boolean equals( Object o )
64      {
65          if ( this == o )
66          {
67              return true;
68          }
69          if ( o == null || getClass() != o.getClass() )
70          {
71              return false;
72          }
73          if ( !super.equals( o ) )
74          {
75              return false;
76          }
77  
78          CategorizedReportEntry that = (CategorizedReportEntry) o;
79  
80          return !( group != null ? !group.equals( that.group ) : that.group != null );
81  
82      }
83  
84      public int hashCode()
85      {
86          int result = super.hashCode();
87          result = 31 * result + ( group != null ? group.hashCode() : 0 );
88          return result;
89      }
90  }