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

org.zalando.riptide.Bindings Maven / Gradle / Ivy

package org.zalando.riptide;

/*
 * ⁣​
 * Riptide
 * ⁣⁣
 * Copyright (C) 2015 Zalando SE
 * ⁣⁣
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ​⁣
 */

import com.google.common.reflect.TypeToken;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;

public final class Bindings {

    Bindings() {
        // package private so we can trick code coverage
    }

    public static  PartialBinding on(final A attribute) {
        return new PartialBinding<>(attribute);
    }

    /**
     * Creates an any condition for the given type. Note that this method is meant to be
     * used as a base for specialized factory methods, e.g. like {@link #anyStatus()}.
     *
     * @param type attribute type
     * @param   generic attribute type
     * @return an any condition on the given attribute type
     * @see #any(TypeToken)
     * @see #anySeries()
     * @see #anyStatus()
     * @see #anyStatusCode()
     * @see #anyContentType()
     */
    public static  PartialBinding any(final Class type) {
        return any(TypeToken.of(type));
    }
    
    /**
     * Creates a wildcard condition for the given type. Note that this method is meant to be
     * used as a base for specialized factory methods, e.g. like {@link #anyStatus()}.
     * 
     * @param type attribute type
     * @param  generic attribute type
     * @return an any condition on the given attribute type
     * @see #any(Class) 
     * @see #anySeries() 
     * @see #anyStatus() 
     * @see #anyStatusCode() 
     * @see #anyContentType() 
     */
    public static  PartialBinding any(@SuppressWarnings("UnusedParameters") final TypeToken type) {
        return new PartialBinding<>(null);
    }

    public static PartialBinding anySeries() {
        return any(HttpStatus.Series.class);
    }

    public static PartialBinding anyStatus() {
        return any(HttpStatus.class);
    }
    
    public static PartialBinding anyStatusCode() {
        return any(Integer.class);
    }

    public static PartialBinding anyContentType() {
        return any(MediaType.class);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy