summaryrefslogtreecommitdiffstats
path: root/models-tosca/src/main
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-15 13:09:53 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-15 13:09:53 +0000
commitaca88111b78129371aebd6d2c9250a8abb9cc2ac (patch)
tree6f14a4457456a6bfd85e3fb41416293c1e02e20a /models-tosca/src/main
parentddd8b56d7bce562a9990199af9bfe36be4c2ca56 (diff)
parentc8d0a3d8b7df3b09ce3405f1192754fdef7026d3 (diff)
Merge "Add prefix matching for policy version"
Diffstat (limited to 'models-tosca/src/main')
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java
index bb0026e9a..012f7de34 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,16 +40,19 @@ import org.onap.policy.models.base.PfObjectFilter;
public class ToscaPolicyFilter implements PfObjectFilter<ToscaPolicy> {
public static final String LATEST_VERSION = "LATEST";
- // Regular expression
+ // Exact expression
private String name;
- // Regular Expression, set to LATEST_VERRSION to get the latest version
+ // Exact match, set to LATEST_VERSION to get the latest version
private String version;
- // Regular expression
+ // version prefix
+ private String versionPrefix;
+
+ // Exact expression
private String type;
- // Regular Expression, set to LATEST_VERRSION to get the latest version
+ // Exact Expression, set to LATEST_VERSION to get the latest version
private String typeVersion;
@Override
@@ -56,11 +60,11 @@ public class ToscaPolicyFilter implements PfObjectFilter<ToscaPolicy> {
// @formatter:off
List<ToscaPolicy> returnList = originalList.stream()
- .filter(p -> filterString(p.getName(), name))
- .filter(p -> LATEST_VERSION.equals(version)
- || filterString(p.getVersion(), version))
- .filter(p -> filterString(p.getType(), type))
- .filter(p -> filterString(p.getTypeVersion(), typeVersion))
+ .filter(filterStringPred(name, ToscaPolicy::getName))
+ .filter(filterStringPred((LATEST_VERSION.equals(version) ? null : version), ToscaPolicy::getVersion))
+ .filter(filterPrefixPred(versionPrefix, ToscaPolicy::getVersion))
+ .filter(filterStringPred(type, ToscaPolicy::getType))
+ .filter(filterStringPred(typeVersion, ToscaPolicy::getTypeVersion))
.collect(Collectors.toList());
// @formatter:off