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

com.oceanprotocol.squid.models.aquarius.SearchQuery Maven / Gradle / Ivy

Go to download

Squid facilitate the interaction of java clients with the Ocean Protocol network

There is a newer version: 0.6.2
Show newest version
/*
 * Copyright 2018 Ocean Protocol Foundation
 * SPDX-License-Identifier: Apache-2.0
 */

package com.oceanprotocol.squid.models.aquarius;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.oceanprotocol.squid.models.AbstractModel;
import com.oceanprotocol.squid.models.FromJsonToModel;

import java.util.HashMap;
import java.util.Map;

@JsonIgnoreProperties(ignoreUnknown = true)
public class SearchQuery extends AbstractModel implements FromJsonToModel {

    @JsonIgnore
    private static final int DEFAULT_OFFSET = 100;

    @JsonIgnore
    private static final int DEFAULT_PAGE = 1;

    @JsonIgnore
    private static final int DEFAULT_SORT = 1;

    @JsonProperty
    public int offset;

    @JsonProperty
    public int page;

    @JsonProperty
    public Map query = new HashMap<>();

    @JsonProperty
    public Sort sort;

    public static class Sort {
        @JsonProperty
        public int value;

        public Sort() {
            value = 1;
        }

        public Sort(int sort) {
            this.value = sort;
        }
    }

    public SearchQuery() {
        this.offset = DEFAULT_OFFSET;
        this.page = DEFAULT_PAGE;
        this.sort = new Sort();
    }

    public SearchQuery(HashMap params) {
        this(params, DEFAULT_OFFSET, DEFAULT_PAGE, DEFAULT_SORT);
    }

    public SearchQuery(Map params, int offset, int page, int sort) {
        this.query = params;
        this.offset = offset;
        this.page = page;
        this.sort = new Sort(sort);

    }

    public void addQueryParam(String field, Object value) {
        this.query.put(field, value);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy