Sha256: 91ff46b3f8e3446b5aa218c6da379b8b2106d10bb059921bf0ebd2c066c8d2f1

Contents?: true

Size: 1.72 KB

Versions: 6

Compression:

Stored size: 1.72 KB

Contents

package org.embulk.input;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.base.Objects;

import java.util.ArrayList;
import java.util.List;

public class ParamsConfig {

    private final List<QueryConfig> queries;

    @JsonCreator
    public ParamsConfig(List<QueryConfig> queries) {
        this.queries = queries;
    }

    @JsonValue
    public List<QueryConfig> getQueries() {
        return queries;
    }

    public List<List<QueryConfig.Query>> expandQueries() {
        List<List<QueryConfig.Query>> base = new ArrayList<>(queries.size());
        for (QueryConfig p : queries) {
            base.add(p.expand());
        }

        int productSize = 1;
        int baseSize = base.size();
        for (int i = 0; i < baseSize; productSize *= base.get(i).size(), i++) ;

        List<List<QueryConfig.Query>> expands = new ArrayList<>(productSize);
        for (int i = 0; i < productSize; i++) {
            int j = 1;
            List<QueryConfig.Query> query = new ArrayList<>();
            for (List<QueryConfig.Query> list : base) {
                QueryConfig.Query pc = list.get((i / j) % list.size());
                query.add(pc);
                j *= list.size();
            }
            expands.add(query);
        }

        return expands;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof ParamsConfig)) {
            return false;
        }
        ParamsConfig other = (ParamsConfig) obj;
        return Objects.equal(queries, other.queries);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(queries);
    }

}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
embulk-input-http-0.0.12 src/main/java/org/embulk/input/ParamsConfig.java
embulk-input-http-0.0.11 src/main/java/org/embulk/input/ParamsConfig.java
embulk-input-http-0.0.9 src/main/java/org/embulk/input/ParamsConfig.java
embulk-input-http-0.0.8 src/main/java/org/embulk/input/ParamsConfig.java
embulk-input-http-0.0.7 src/main/java/org/embulk/input/ParamsConfig.java
embulk-input-http-0.0.6 src/main/java/org/embulk/input/ParamsConfig.java