Switch to exclusiveWith
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2017 Pivotal, Inc.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -11,9 +21,15 @@ import org.yaml.snakeyaml.nodes.MappingNode;
|
||||
import org.yaml.snakeyaml.nodes.Node;
|
||||
import org.yaml.snakeyaml.nodes.SequenceNode;
|
||||
|
||||
/**
|
||||
* Constraints for Manifest YAML structure
|
||||
*
|
||||
* @author Alex Boyko
|
||||
*
|
||||
*/
|
||||
public class ManifestConstraints {
|
||||
|
||||
public static Constraint mutuallyExclusive(String... propertyIds) {
|
||||
public static Constraint exclusiveWith(String... propertyIds) {
|
||||
return (dc, parent, node, type, problems) -> {
|
||||
Set<String> keys = new HashSet<>();
|
||||
Node root = dc.getAST().getNodes().get(0);
|
||||
|
||||
@@ -127,7 +127,7 @@ public class ManifestYmlSchema implements YamlSchema {
|
||||
}
|
||||
|
||||
YAtomicType t_domain = f.yatomic("Domain");
|
||||
t_domain.require(ManifestConstraints.mutuallyExclusive("routes"));
|
||||
t_domain.require(ManifestConstraints.exclusiveWith("routes"));
|
||||
if (domainsProvider != null) {
|
||||
t_domain.addHintProvider(domainsProvider);
|
||||
t_domain.parseWith(ManifestYmlValueParsers.fromValueHints(domainsProvider, t_domain, ManifestYamlSchemaProblemsTypes.UNKNOWN_DOMAIN_PROBLEM));
|
||||
@@ -173,19 +173,19 @@ public class ManifestYmlSchema implements YamlSchema {
|
||||
TOPLEVEL_TYPE.addProperty("inherit", t_string, descriptionFor("inherit"));
|
||||
|
||||
YSeqType routesType = f.yseq(route);
|
||||
routesType.require(ManifestConstraints.mutuallyExclusive("domain", "domains", "host", "hosts", "no-hostname"));
|
||||
routesType.require(ManifestConstraints.exclusiveWith("domain", "domains", "host", "hosts", "no-hostname"));
|
||||
|
||||
YSeqType domainsType = f.yseq(t_domain);
|
||||
domainsType.require(ManifestConstraints.mutuallyExclusive("routes"));
|
||||
domainsType.require(ManifestConstraints.exclusiveWith("routes"));
|
||||
|
||||
YSeqType hostsType = f.yseq(t_string);
|
||||
hostsType.require(ManifestConstraints.mutuallyExclusive("routes"));
|
||||
hostsType.require(ManifestConstraints.exclusiveWith("routes"));
|
||||
|
||||
YAtomicType hostType = f.yatomic("String");
|
||||
hostType.require(ManifestConstraints.mutuallyExclusive("routes"));
|
||||
hostType.require(ManifestConstraints.exclusiveWith("routes"));
|
||||
|
||||
YAtomicType noHostType = f.yenum("boolean", "true", "false");
|
||||
noHostType.require(ManifestConstraints.mutuallyExclusive("routes"));
|
||||
noHostType.require(ManifestConstraints.exclusiveWith("routes"));
|
||||
|
||||
YTypedPropertyImpl[] props = {
|
||||
f.yprop("buildpack", t_buildpack),
|
||||
|
||||
Reference in New Issue
Block a user