All Downloads are FREE. Search and download functionalities are using the official Maven repository.

apoc.schema.SchemaConfig Maven / Gradle / Ivy

There is a newer version: 5.24.0
Show newest version
package apoc.schema;

import java.util.*;

/**
 * @author ab-larus
 * @since 17.12.18
 */
public class SchemaConfig {

    private Set labels;
    private Set excludeLabels;
    private Set relationships;
    private Set excludeRelationships;

    public Set getLabels() {
        return labels;
    }

    public Set getExcludeLabels() {
        return excludeLabels;
    }

    public Set getRelationships() {
        return relationships;
    }

    public Set getExcludeRelationships() {
        return excludeRelationships;
    }

    public SchemaConfig(Map config) {
        config = config != null ? config : Collections.emptyMap();
        this.labels = new HashSet<>((Collection)config.getOrDefault("labels", Collections.EMPTY_SET));
        this.excludeLabels = new HashSet<>((Collection) config.getOrDefault("excludeLabels", Collections.EMPTY_SET));
        validateParameters(this.labels, this.excludeLabels, "labels");
        this.relationships = new HashSet<>((Collection)config.getOrDefault("relationships", Collections.EMPTY_SET));
        this.excludeRelationships = new HashSet<>((Collection)config.getOrDefault("excludeRelationships", Collections.EMPTY_SET));
        validateParameters(this.relationships, this.excludeRelationships, "relationships");
    }

    private void validateParameters(Set include, Set exclude, String parameterType){
        if(!include.isEmpty() && !exclude.isEmpty())
            throw new IllegalArgumentException(String.format("Parameters %s and exclude%s are both valuated. Please check parameters and valuate only one.", parameterType, parameterType));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy