1 /*
2 * This file is part of dependency-check-core.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * Copyright (c) 2017 The OWASP Foundation. All Rights Reserved.
17 */
18 package org.owasp.dependencycheck.maven;
19
20 import org.apache.commons.lang3.StringUtils;
21 import org.owasp.dependencycheck.utils.Filter;
22
23 /**
24 * {@link Filter} implementation to exclude artifacts whose type matches a
25 * regular expression.
26 *
27 * @author ercpe
28 */
29 public class ArtifactTypeExcluded extends Filter<String> {
30
31 /**
32 * The regular expression for the exclusion filter.
33 */
34 private final String regex;
35
36 /**
37 * Creates a new instance.
38 *
39 * @param excludeRegex The regular expression to match the artifacts type
40 * against
41 */
42 public ArtifactTypeExcluded(final String excludeRegex) {
43 this.regex = excludeRegex;
44 }
45
46 /**
47 * {@inheritDoc}
48 */
49 @Override
50 public boolean passes(final String artifactType) {
51
52 return StringUtils.isNotEmpty(regex) && StringUtils.isNotEmpty(artifactType) && artifactType.matches(regex);
53 }
54 }