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

org.openl.rules.rest.service.ProjectTableCriteriaQuery Maven / Gradle / Ivy

There is a newer version: 5.27.9
Show newest version
package org.openl.rules.rest.service;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * Project criteria query. Used to filter project tables in {@link ProjectService}.
 *
 * @author Vladyslav Pikus
 */
public class ProjectTableCriteriaQuery {

    private final Collection kinds;
    private final String name;
    private final Map properties;

    private ProjectTableCriteriaQuery(Builder builder) {
        this.kinds = builder.kinds == null ? Collections.emptyList()
                : Collections.unmodifiableCollection(builder.kinds);
        this.name = builder.name;
        this.properties = builder.properties == null ? Collections.emptyMap() : Map.copyOf(builder.properties);
    }

    public Collection getKinds() {
        return kinds;
    }

    public Optional getName() {
        return Optional.ofNullable(name);
    }

    public Map getProperties() {
        return properties;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static class Builder {
        private Collection kinds;
        private String name;
        private Map properties = new HashMap<>();

        public Builder kinds(Collection kinds) {
            this.kinds = kinds;
            return this;
        }

        public Builder name(String name) {
            this.name = name;
            return this;
        }

        public Builder property(String name, Object value) {
            this.properties.put(name, value);
            return this;
        }

        public ProjectTableCriteriaQuery build() {
            return new ProjectTableCriteriaQuery(this);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy