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

cc.shacocloud.mirage.web.RequestMappingInfo Maven / Gradle / Ivy

package cc.shacocloud.mirage.web;

import cc.shacocloud.mirage.web.bind.annotation.RequestMapping;
import io.vertx.core.http.HttpMethod;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.springframework.util.ObjectUtils;

import java.util.Arrays;

/**
 * 请求映射信息
 *
 * @see RequestMapping
 */
@Getter
@Builder
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public final class RequestMappingInfo {

    private final String[] paths;

    private final HttpMethod[] methods;

    private final String[] consumes;

    private final String[] produces;


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RequestMappingInfo that = (RequestMappingInfo) o;
        return Arrays.equals(paths, that.paths) &&
                Arrays.equals(methods, that.methods) &&
                Arrays.equals(consumes, that.consumes) &&
                Arrays.equals(produces, that.produces);
    }

    @Override
    public int hashCode() {
        int result = Arrays.hashCode(paths);
        result = 31 * result + Arrays.hashCode(methods);
        result = 31 * result + Arrays.hashCode(consumes);
        result = 31 * result + Arrays.hashCode(produces);
        return result;
    }


    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder("{");

        if (!ObjectUtils.isEmpty(this.paths)) {
            builder.append(" paths ").append(Arrays.toString(this.paths));
        }

        if (!ObjectUtils.isEmpty(this.methods)) {
            builder.append(", methods ").append(Arrays.toString(this.methods));
        }

        if (!ObjectUtils.isEmpty(this.consumes)) {
            builder.append(", consumes ").append(Arrays.toString(this.consumes));
        }
        if (!ObjectUtils.isEmpty(this.produces)) {
            builder.append(", produces ").append(Arrays.toString(this.produces));
        }
        builder.append(" }");
        return builder.toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy