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

org.glowroot.ui.ImmutableJsonServiceMapping Maven / Gradle / Ivy

There is a newer version: 0.9.28
Show newest version
package org.glowroot.ui;

import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonCreator;
import org.glowroot.agent.shaded.fasterxml.jackson.annotation.JsonProperty;
import org.glowroot.agent.shaded.google.common.base.MoreObjects;
import org.glowroot.agent.shaded.google.common.base.Preconditions;
import org.glowroot.agent.shaded.google.common.collect.Lists;
import java.util.List;
import java.util.regex.Pattern;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;

/**
 * Immutable implementation of {@link HttpServerHandler.JsonServiceMapping}.
 * 

* Use builder to create immutable instances: * {@code ImmutableJsonServiceMapping.builder()}. */ @SuppressWarnings("all") @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "HttpServerHandler.JsonServiceMapping"}) @Immutable final class ImmutableJsonServiceMapping extends HttpServerHandler.JsonServiceMapping { private final HttpServerHandler.HttpMethod httpMethod; private final String path; private final java.lang.Object service; private final String methodName; private final Pattern pattern; private ImmutableJsonServiceMapping( HttpServerHandler.HttpMethod httpMethod, String path, java.lang.Object service, String methodName) { this.httpMethod = httpMethod; this.path = path; this.service = service; this.methodName = methodName; this.pattern = Preconditions.checkNotNull(super.pattern()); } /** * @return value of {@code httpMethod} attribute */ @JsonProperty @Override HttpServerHandler.HttpMethod httpMethod() { return httpMethod; } /** * @return value of {@code path} attribute */ @JsonProperty @Override String path() { return path; } /** * @return value of {@code service} attribute */ @JsonProperty @Override java.lang.Object service() { return service; } /** * @return value of {@code methodName} attribute */ @JsonProperty @Override String methodName() { return methodName; } /** * @return computed at construction value of {@code pattern} attribute */ @JsonProperty @Override Pattern pattern() { return pattern; } /** * Copy current immutable object by setting value for {@link HttpServerHandler.JsonServiceMapping#httpMethod() httpMethod}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for httpMethod * @return modified copy of the {@code this} object */ public final ImmutableJsonServiceMapping withHttpMethod(HttpServerHandler.HttpMethod value) { if (this.httpMethod == value) return this; HttpServerHandler.HttpMethod newValue = Preconditions.checkNotNull(value); return new ImmutableJsonServiceMapping(newValue, this.path, this.service, this.methodName); } /** * Copy current immutable object by setting value for {@link HttpServerHandler.JsonServiceMapping#path() path}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for path * @return modified copy of the {@code this} object */ public final ImmutableJsonServiceMapping withPath(String value) { if (this.path == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableJsonServiceMapping(this.httpMethod, newValue, this.service, this.methodName); } /** * Copy current immutable object by setting value for {@link HttpServerHandler.JsonServiceMapping#service() service}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for service * @return modified copy of the {@code this} object */ public final ImmutableJsonServiceMapping withService(java.lang.Object value) { if (this.service == value) return this; java.lang.Object newValue = Preconditions.checkNotNull(value); return new ImmutableJsonServiceMapping(this.httpMethod, this.path, newValue, this.methodName); } /** * Copy current immutable object by setting value for {@link HttpServerHandler.JsonServiceMapping#methodName() methodName}. * Shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value new value for methodName * @return modified copy of the {@code this} object */ public final ImmutableJsonServiceMapping withMethodName(String value) { if (this.methodName == value) return this; String newValue = Preconditions.checkNotNull(value); return new ImmutableJsonServiceMapping(this.httpMethod, this.path, this.service, newValue); } /** * This instance is equal to instances of {@code ImmutableJsonServiceMapping} with equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof ImmutableJsonServiceMapping && equalTo((ImmutableJsonServiceMapping) another); } private boolean equalTo(ImmutableJsonServiceMapping another) { return httpMethod.equals(another.httpMethod) && path.equals(another.path) && service.equals(another.service) && methodName.equals(another.methodName) && pattern.equals(another.pattern); } /** * Computes hash code from attributes: {@code httpMethod}, {@code path}, {@code service}, {@code methodName}, {@code pattern}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + httpMethod.hashCode(); h = h * 17 + path.hashCode(); h = h * 17 + service.hashCode(); h = h * 17 + methodName.hashCode(); h = h * 17 + pattern.hashCode(); return h; } /** * Prints immutable value {@code JsonServiceMapping...} with attribute values, * excluding any non-generated and auxiliary attributes. * @return string representation of value */ @Override public String toString() { return MoreObjects.toStringHelper("JsonServiceMapping") .add("httpMethod", httpMethod) .add("path", path) .add("service", service) .add("methodName", methodName) .add("pattern", pattern) .toString(); } /** * Simple representation of this value type suitable Jackson binding * @deprecated Do not use this type directly, it exists only for Jackson-binding infrastructure */ @Deprecated static final class Json { @JsonProperty @Nullable HttpServerHandler.HttpMethod httpMethod; @JsonProperty @Nullable String path; @JsonProperty @Nullable java.lang.Object service; @JsonProperty @Nullable String methodName; @JsonProperty @Nullable Pattern pattern; } /** * @param json JSON-bindable data structure * @return immutable value type * @deprecated Do not use this method directly, it exists only for Jackson-binding infrastructure */ @Deprecated @JsonCreator static ImmutableJsonServiceMapping fromJson(Json json) { ImmutableJsonServiceMapping.Builder builder = ImmutableJsonServiceMapping.builder(); if (json.httpMethod != null) { builder.httpMethod(json.httpMethod); } if (json.path != null) { builder.path(json.path); } if (json.service != null) { builder.service(json.service); } if (json.methodName != null) { builder.methodName(json.methodName); } return builder.build(); } /** * Creates immutable copy of {@link HttpServerHandler.JsonServiceMapping}. * Uses accessors to get values to initialize immutable instance. * If an instance is already immutable, it is returned as is. * @param instance instance to copy * @return copied immutable JsonServiceMapping instance */ static ImmutableJsonServiceMapping copyOf(HttpServerHandler.JsonServiceMapping instance) { if (instance instanceof ImmutableJsonServiceMapping) { return (ImmutableJsonServiceMapping) instance; } return ImmutableJsonServiceMapping.builder() .copyFrom(instance) .build(); } /** * Creates builder for {@link org.glowroot.ui.ImmutableJsonServiceMapping ImmutableJsonServiceMapping}. * @return new ImmutableJsonServiceMapping builder */ static ImmutableJsonServiceMapping.Builder builder() { return new ImmutableJsonServiceMapping.Builder(); } /** * Builds instances of {@link org.glowroot.ui.ImmutableJsonServiceMapping ImmutableJsonServiceMapping}. * Initialize attributes and then invoke {@link #build()} method to create * immutable instance. *

{@code Builder} is not thread safe and generally should not be stored in field or collection, * but used immediately to create instances. */ @NotThreadSafe static final class Builder { private static final long INIT_BIT_HTTP_METHOD = 0x1L; private static final long INIT_BIT_PATH = 0x2L; private static final long INIT_BIT_SERVICE = 0x4L; private static final long INIT_BIT_METHOD_NAME = 0x8L; private long initBits = 0xf; private @Nullable HttpServerHandler.HttpMethod httpMethod; private @Nullable String path; private @Nullable java.lang.Object service; private @Nullable String methodName; private Builder() {} /** * Fill builder with attribute values from provided {@link HttpServerHandler.JsonServiceMapping} instance. * Regular attribute values will be replaced with ones of an instance. * Instance's absent optional values will not replace present values. * @param instance instance to copy values from * @return {@code this} builder for chained invocation */ public final Builder copyFrom(HttpServerHandler.JsonServiceMapping instance) { Preconditions.checkNotNull(instance); httpMethod(instance.httpMethod()); path(instance.path()); service(instance.service()); methodName(instance.methodName()); return this; } /** * Initializes value for {@link HttpServerHandler.JsonServiceMapping#httpMethod() httpMethod}. * @param httpMethod value for httpMethod * @return {@code this} builder for chained invocation */ public final Builder httpMethod(HttpServerHandler.HttpMethod httpMethod) { this.httpMethod = Preconditions.checkNotNull(httpMethod); initBits &= ~INIT_BIT_HTTP_METHOD; return this; } /** * Initializes value for {@link HttpServerHandler.JsonServiceMapping#path() path}. * @param path value for path * @return {@code this} builder for chained invocation */ public final Builder path(String path) { this.path = Preconditions.checkNotNull(path); initBits &= ~INIT_BIT_PATH; return this; } /** * Initializes value for {@link HttpServerHandler.JsonServiceMapping#service() service}. * @param service value for service * @return {@code this} builder for chained invocation */ public final Builder service(java.lang.Object service) { this.service = Preconditions.checkNotNull(service); initBits &= ~INIT_BIT_SERVICE; return this; } /** * Initializes value for {@link HttpServerHandler.JsonServiceMapping#methodName() methodName}. * @param methodName value for methodName * @return {@code this} builder for chained invocation */ public final Builder methodName(String methodName) { this.methodName = Preconditions.checkNotNull(methodName); initBits &= ~INIT_BIT_METHOD_NAME; return this; } /** * Builds new {@link org.glowroot.ui.ImmutableJsonServiceMapping ImmutableJsonServiceMapping}. * @return immutable instance of JsonServiceMapping * @throws exception {@code java.lang.IllegalStateException} if any required attributes are missing */ public ImmutableJsonServiceMapping build() throws IllegalStateException { checkRequiredAttributes(); return new ImmutableJsonServiceMapping(httpMethod, path, service, methodName); } private boolean httpMethodIsSet() { return (initBits & INIT_BIT_HTTP_METHOD) == 0; } private boolean pathIsSet() { return (initBits & INIT_BIT_PATH) == 0; } private boolean serviceIsSet() { return (initBits & INIT_BIT_SERVICE) == 0; } private boolean methodNameIsSet() { return (initBits & INIT_BIT_METHOD_NAME) == 0; } private void checkRequiredAttributes() throws IllegalStateException { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); if (!httpMethodIsSet()) attributes.add("httpMethod"); if (!pathIsSet()) attributes.add("path"); if (!serviceIsSet()) attributes.add("service"); if (!methodNameIsSet()) attributes.add("methodName"); return "Cannot build JsonServiceMapping, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy