Add convenience method to SubclassClassifier
This commit is contained in:
40
pipeline.yml
40
pipeline.yml
@@ -17,6 +17,26 @@ resources:
|
||||
source:
|
||||
url: {{slack-url}}
|
||||
|
||||
slack-failure: &slack-failure
|
||||
put: slack
|
||||
params:
|
||||
attachments:
|
||||
- color: danger
|
||||
fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <FAILURE>"
|
||||
text: "<!here> Build has failed"
|
||||
title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
|
||||
title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
|
||||
|
||||
slack-success: &slack-success
|
||||
put: slack
|
||||
params:
|
||||
attachments:
|
||||
- color: good
|
||||
fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <SUCCESS>"
|
||||
text: "Build has succeeded"
|
||||
title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
|
||||
title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
|
||||
|
||||
jobs:
|
||||
- name: build
|
||||
plan:
|
||||
@@ -106,23 +126,3 @@ jobs:
|
||||
spring_password: {{spring-password}}
|
||||
on_failure: *slack-failure
|
||||
on_success: *slack-success
|
||||
|
||||
slack-failure: &slack-failure
|
||||
put: slack
|
||||
params:
|
||||
attachments:
|
||||
- color: danger
|
||||
fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <FAILURE>"
|
||||
text: "<!here> Build has failed"
|
||||
title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
|
||||
title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
|
||||
|
||||
slack-success: &slack-success
|
||||
put: slack
|
||||
params:
|
||||
attachments:
|
||||
- color: good
|
||||
fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME <SUCCESS>"
|
||||
text: "Build has succeeded"
|
||||
title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME"
|
||||
title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
|
||||
|
||||
@@ -85,6 +85,16 @@ public class SubclassClassifier<T, C> implements Classifier<T, C> {
|
||||
this.classified = new ConcurrentHashMap<Class<? extends T>, C>(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a classification. The keys is the type and this will be mapped along with all
|
||||
* subclasses to the corresponding value. The most specific types will match first.
|
||||
* @param type the type of the input object
|
||||
* @param target the target value for all such types
|
||||
*/
|
||||
public void add(Class<? extends T> type, C target) {
|
||||
this.classified.put(type, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value from the type map whose key is the class of the given Throwable,
|
||||
* or its nearest ancestor if a subclass.
|
||||
|
||||
Reference in New Issue
Block a user