-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add validation to include/exlude jobs regular expressions
- Loading branch information
1 parent
5f3a210
commit 98e20c1
Showing
4 changed files
with
147 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/org/datadog/jenkins/plugins/datadog/util/conversion/PatternListConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.datadog.jenkins.plugins.datadog.util.conversion; | ||
|
||
import com.thoughtworks.xstream.converters.Converter; | ||
import com.thoughtworks.xstream.converters.MarshallingContext; | ||
import com.thoughtworks.xstream.converters.UnmarshallingContext; | ||
import com.thoughtworks.xstream.io.HierarchicalStreamReader; | ||
import com.thoughtworks.xstream.io.HierarchicalStreamWriter; | ||
import java.util.List; | ||
import java.util.regex.Pattern; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.datadog.jenkins.plugins.datadog.DatadogUtilities; | ||
|
||
public class PatternListConverter implements Converter { | ||
|
||
@Override | ||
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { | ||
String string = DatadogUtilities.listToCstr((List<Pattern>) source, Pattern::toString); | ||
context.convertAnother(string); | ||
} | ||
|
||
@Override | ||
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { | ||
String string = (String) context.convertAnother(null, String.class); | ||
if (StringUtils.isBlank(string)) { | ||
return null; | ||
} | ||
return DatadogUtilities.cstrToList(string, Pattern::compile); | ||
} | ||
|
||
@Override | ||
public boolean canConvert(Class type) { | ||
return List.class.isAssignableFrom(type); | ||
} | ||
} |