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 return isNameWithGroup() ? getName() + GROUP_PREFIX + getGroup() + GROUP_SUFIX : getName();
71 }
72
73 public boolean equals( Object o )
74 {
75 if ( this == o )
76 {
77 return true;
78 }
79 if ( o == null || getClass() != o.getClass() )
80 {
81 return false;
82 }
83 if ( !super.equals( o ) )
84 {
85 return false;
86 }
87
88 CategorizedReportEntry that = (CategorizedReportEntry) o;
89
90 return !( group != null ? !group.equals( that.group ) : that.group != null );
91
92 }
93
94 public int hashCode()
95 {
96 int result = super.hashCode();
97 result = 31 * result + ( group != null ? group.hashCode() : 0 );
98 return result;
99 }
100
101 private boolean isNameWithGroup()
102 {
103 return getGroup() != null && !getGroup().equals( getName() );
104 }
105 }