public class ExecutionReport extends Object implements Serializable
Map. Besides, it provides a
series of operations, such as regex search and lambda forEach
to improve convenience.| Modifier and Type | Method and Description |
|---|---|
static @NotNull ExecutionReport |
create()
Create a new empty report.
|
static @NotNull ExecutionReport |
create(Map<String,Object> reports)
Create a new report which contains given values.
|
void |
forEach(BiConsumer<String,Object> action)
Performs the given action for each entry in this map until all entries
have been processed or the action throws an exception.
|
Object |
get(String key)
Get the value associated with the specified key.
|
<T> T |
get(String key,
Class<T> clazz)
Get the value associated with the specified key in generic T type.
|
ExecutionReport |
getCategory(String category)
Get a sub-report which only contains the given category.
|
Double |
getDouble(String key)
Get the value associated with the specified key in
Double type. |
Integer |
getInt(String key)
Get the value associated with the specified key in
Integer type. |
Long |
getLong(String key)
Get the value associated with the specified key in
Long type. |
String |
getString(String key)
Get the value associated with the specified key in
String type. |
ExecutionReport |
merge(ExecutionReport other)
Merge another report into this one.
|
String |
print()
Print the container to the console.
|
void |
put(Map<String,Object> reports)
Add a series of key-value pairs in the report.
|
void |
put(String key,
Object value)
Associate the specified value with the specified key in the report.
|
ExecutionReport |
search(String pattern)
Get a sub-report matches the given regex pattern.
|
@NotNull @Contract(value=" -> new") public static @NotNull ExecutionReport create()
@NotNull @Contract(value="_ -> new") public static @NotNull ExecutionReport create(Map<String,Object> reports)
reports - the given valuespublic void put(String key, Object value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified keypublic void put(Map<String,Object> reports)
reports - a series of key-value pairspublic Object get(String key)
key - the specified keypublic String getString(String key)
String type.key - the specified keypublic Integer getInt(String key)
Integer type.key - the specified keypublic Long getLong(String key)
Long type.key - the specified keypublic Double getDouble(String key)
Double type.key - the specified keypublic <T> T get(String key, Class<T> clazz)
T - target object typekey - the specified keyclazz - target type classpublic ExecutionReport getCategory(String category)
For example, origin report contains (A, 1), (A.a, 2), (A.b, 3), (B, 4), (B.a, 5).
Then, through getCategory("A"), we will get a sub-report which only contains
(A, 1), (A.a, 2), (A.b, 3).
category - the specified categorypublic ExecutionReport search(String pattern)
For example, origin report contains (T.u.a, 1), (T.u.b, 2), (T.v.a, 3), (T.v.b, 4).
Then, through search("T\\..+\\.a"), we will get a sub-report which only contains
(T.u.a, 1), (T.v.a, 3).
pattern - the regex formulapublic ExecutionReport merge(ExecutionReport other)
Notice: If there exists duplicate key, the value in another report will override the value in current report.
other - another reportpublic String print()
public void forEach(BiConsumer<String,Object> action)
action - The action to be performed for each entryCopyright © 2019. All rights reserved.