1 package org.apache.maven.surefire.report;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public class CategorizedReportEntry
26 extends SimpleReportEntry
27 implements ReportEntry
28 {
29 private static final String GROUP_PREFIX = " (of ";
30
31 private static final String GROUP_SUFIX = ")";
32
33 private final String group;
34
35 public CategorizedReportEntry( String source, String name, String group )
36 {
37 this( source, name, group, null, null );
38 }
39
40 public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
41 Integer elapsed )
42 {
43 super( source, name, stackTraceWriter, elapsed );
44 this.group = group;
45 }
46
47 public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
48 Integer elapsed, String message )
49 {
50 super( source, name, stackTraceWriter, elapsed, message );
51 this.group = group;
52 }
53
54 public static ReportEntry reportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
55 Integer elapsed, String message )
56 {
57 return group != null
58 ? new CategorizedReportEntry( source, name, group, stackTraceWriter, elapsed, message )
59 : new SimpleReportEntry( source, name, stackTraceWriter, elapsed, message );
60 }
61
62 public String getGroup()
63 {
64 return group;
65 }
66
67 @Override
68 public String getNameWithGroup()
69 {
70 StringBuilder result = new StringBuilder();
71 result.append( getName() );
72
73 if ( getGroup() != null && !getName().equals( getGroup() ) )
74 {
75 result.append( GROUP_PREFIX );
76 result.append( getGroup() );
77 result.append( GROUP_SUFIX );
78 }
79
80 return result.toString();
81 }
82
83 public boolean equals( Object o )
84 {
85 if ( this == o )
86 {
87 return true;
88 }
89 if ( o == null || getClass() != o.getClass() )
90 {
91 return false;
92 }
93 if ( !super.equals( o ) )
94 {
95 return false;
96 }
97
98 CategorizedReportEntry that = (CategorizedReportEntry) o;
99
100 return !( group != null ? !group.equals( that.group ) : that.group != null );
101
102 }
103
104 public int hashCode()
105 {
106 int result = super.hashCode();
107 result = 31 * result + ( group != null ? group.hashCode() : 0 );
108 return result;
109 }
110 }