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

com.zepben.vertxutils.routing.handlers.params.QueryParamRule Maven / Gradle / Ivy

There is a newer version: 1.5.0-SNAPSHOT2
Show newest version
/*
 * Copyright 2020 Zeppelin Bend Pty Ltd
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

package com.zepben.vertxutils.routing.handlers.params;

import com.zepben.annotations.EverythingIsNonnullByDefault;

import javax.annotation.Nullable;

@EverythingIsNonnullByDefault
public class QueryParamRule extends ParamRule {

    @Nullable private final T defaultValue;
    private final boolean isRequired;

    public static  QueryParamRule of(String name, RequestValueConverter converter) {
        return new QueryParamRule<>(name, converter, null, false);
    }

    public static  QueryParamRule of(String name, RequestValueConverter converter, T defaultValue) {
        return new QueryParamRule<>(name, converter, defaultValue, false);
    }

    public static  QueryParamRule ofRequired(String name, RequestValueConverter converter) {
        return new QueryParamRule<>(name, converter, null, true);
    }

    private QueryParamRule(String name, RequestValueConverter converter, @Nullable T defaultValue, boolean isRequired) {
        super(name, converter);
        this.defaultValue = defaultValue;
        this.isRequired = isRequired;
    }

    @Nullable
    public T defaultValue() {
        return defaultValue;
    }

    public boolean isRequired() {
        return isRequired;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy