1010
1111/** Stores status instrumentation results */
1212public class InstrumentationResult {
13-
1413 public enum Status {
1514 INSTALLED ,
1615 BLOCKED ,
17- ERROR ;
16+ ERROR
1817 }
1918
2019 private final Status status ;
21-
2220 private final Map <ProbeId , List <DiagnosticMessage >> diagnostics ;
2321 private final String sourceFileName ;
2422 private final String typeName ;
2523 private final String methodName ;
26- private final String signature ;
2724 private final int methodStart ;
25+ private final String signature ;
2826
2927 public static class Factory {
30-
3128 public static InstrumentationResult blocked (String className ) {
32- return new InstrumentationResult (Status .BLOCKED , null , className );
29+ return new InstrumentationResult (Status .BLOCKED , className , null );
3330 }
3431
3532 public static InstrumentationResult blocked (
@@ -38,38 +35,38 @@ public static InstrumentationResult blocked(
3835 definitions .forEach (
3936 probeDefinition ->
4037 diagnostics .put (probeDefinition .getProbeId (), Arrays .asList (messages )));
41- return new InstrumentationResult (Status .BLOCKED , diagnostics , className );
38+ return new InstrumentationResult (Status .BLOCKED , diagnostics , null , className , null );
4239 }
4340 }
4441
45- private InstrumentationResult (
46- Status status , Map <ProbeId , List <DiagnosticMessage >> diagnostics , String className ) {
47- this (status , diagnostics , className , null );
42+ public InstrumentationResult (
43+ Status status , Map <ProbeId , List <DiagnosticMessage >> diagnostics , MethodInfo methodInfo ) {
44+ this .status = status ;
45+ this .diagnostics = diagnostics ;
46+ this .sourceFileName = methodInfo .getSourceFileName ();
47+ this .typeName = methodInfo .getTypeName ();
48+ this .methodName = methodInfo .getMethodName ();
49+ this .methodStart = methodInfo .getMethodStart ();
50+ this .signature = methodInfo .getSignature ();
51+ }
52+
53+ public InstrumentationResult (Status status , String className , String methodName ) {
54+ this (status , null , className , className , methodName );
4855 }
4956
5057 public InstrumentationResult (
5158 Status status ,
5259 Map <ProbeId , List <DiagnosticMessage >> diagnostics ,
60+ String sourceFileName ,
5361 String className ,
54- String method ) {
62+ String methodName ) {
5563 this .status = status ;
5664 this .diagnostics = diagnostics ;
65+ this .sourceFileName = sourceFileName ;
5766 this .typeName = className ;
58- this .methodName = method ;
59- this .sourceFileName = null ;
60- this .signature = null ;
67+ this .methodName = methodName ;
6168 this .methodStart = -1 ;
62- }
63-
64- public InstrumentationResult (
65- Status status , Map <ProbeId , List <DiagnosticMessage >> diagnostics , MethodInfo methodInfo ) {
66- this .status = status ;
67- this .diagnostics = diagnostics ;
68- this .sourceFileName = methodInfo .getSourceFileName ();
69- this .typeName = methodInfo .getTypeName ();
70- this .methodName = methodInfo .getMethodName ();
71- this .methodStart = methodInfo .getMethodStart ();
72- this .signature = methodInfo .getSignature ();
69+ this .signature = null ;
7370 }
7471
7572 public boolean isError () {
@@ -111,17 +108,9 @@ public String getMethodSignature() {
111108 @ Generated
112109 @ Override
113110 public String toString () {
114- return "InstrumentationResult{"
115- + "status="
116- + status
117- + ", diagnostics="
118- + diagnostics
119- + ", typeName='"
120- + typeName
121- + '\''
122- + ", methodName='"
123- + methodName
124- + '\''
125- + '}' ;
111+ return String .format (
112+ "InstrumentationResult{typeName='%s', methodName='%s', methodStart=%d, signature='%s',"
113+ + " sourceFileName='%s', status=%s. diagnostics=%s}" ,
114+ typeName , methodName , methodStart , signature , sourceFileName , status , diagnostics );
126115 }
127116}
0 commit comments