// Copyright (c) 2017, Worcade. Please see the AUTHORS file for details.
// All rights reserved. Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package net.worcade.client.query;

import net.worcade.client.internal.WorcadeQuery;

import java.util.Collection;

public interface Query<T extends EntityField> {
    static Builder<AssetField> asset() {
        return WorcadeQuery.builder();
    }

    static Builder<ConversationField> conversation() {
        return WorcadeQuery.builder();
    }

    static Builder<GroupField> group() {
        return WorcadeQuery.builder();
    }

    static Builder<RoomField> room() {
        return WorcadeQuery.builder();
    }

    static Builder<SiteField> site() {
        return WorcadeQuery.builder();
    }

    static Builder<ContactField> contacts() {
        return WorcadeQuery.builder();
    }

    static Builder<WebhookField> webhook() {
        return WorcadeQuery.builder();
    }

    interface Builder<T extends EntityField> {

        /**
         * Add the specified fields to the result
         */
        @SuppressWarnings("unchecked")
        Builder<T> fields(T... fields);

        /**
         * Add the specified fields to the result
         */
        Builder<T> fields(Collection<T> fields);

        /**
         * Add the specified filter to the query.
         * Filters for different fields will be AND'ed
         * Filters on the same field with different value will be OR'ed
         *
         * Not all fields can be filtered. For details, see the <a href="https://worcade.net/doc">Worcade API doc</a>
         */
        Builder<T> filter(T field, String value);

        /**
         * Add an order to the query. Multiple orders can be specified.
         *
         * Not all fields can be used for ordering. For details, see the <a href="https://worcade.net/doc">Worcade API doc</a>
         */
        Builder<T> order(T field, boolean ascending);

        /**
         * Limit the amount of results returned.
         * Defaults to 10. Cannot exceed 100.
         */
        Builder<T> limit(int limit);

        Query<T> build();
    }
}

@@ -622,32 +622,119 @@
 ilder();%0A    %7D%0A%0A
+    static Builder%3CLabelField%3E label() %7B%0A        return WorcadeQuery.builder();%0A    %7D%0A%0A
     static Build
@@ -2219,24 +2219,121 @@
 nt limit);%0A%0A
+        /**%0A         * Text to search for%0A         */%0A        Builder%3CT%3E search(String search);%0A%0A
         Quer

Implement list query for labels