Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The useJakartaValidation configuration option does not appear to work. This results in generated code using javax.validation that does not always work with Java 17.


Resulting generated class example:

Code Block
languagejava

package com.example.asyncmethod.models;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.validation.Valid;
import javax.validation.constraints.DecimalMin;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
    "lumens",
    "sentAt"
})
public class lightMeasuredPayload implements Serializable
{

    /**
     * Light intensity measured in lumens.
     * 
     */
    @JsonProperty("lumens")
    @JsonPropertyDescription("Light intensity measured in lumens.")
    @DecimalMin("0")
    private Long lumens;
    /**
     * Date and time when the message was sent.
     * 
     */
    @JsonProperty("sentAt")
    @JsonPropertyDescription("Date and time when the message was sent.")
    private String sentAt;
    @JsonIgnore
    @Valid
    private Map<String, Object> additionalProperties = new LinkedHashMap<String, Object>();
    protected final static Object NOT_FOUND_VALUE = new Object();
    private final static long serialVersionUID = 6984519541679788517L;

    /**
     * Light intensity measured in lumens.
     * 
     */
    @JsonProperty("lumens")
    public Long getLumens() {
        return lumens;
    }

    /**
     * Light intensity measured in lumens.
     * 
     */
    @JsonProperty("lumens")
    public void setLumens(Long lumens) {
        this.lumens = lumens;
    }

    public lightMeasuredPayload withLumens(Long lumens) {
        this.lumens = lumens;
        return this;
    }

    /**
     * Date and time when the message was sent.
     * 
     */
    @JsonProperty("sentAt")
    public String getSentAt() {
        return sentAt;
    }

    /**
     * Date and time when the message was sent.
     * 
     */
    @JsonProperty("sentAt")
    public void setSentAt(String sentAt) {
        this.sentAt = sentAt;
    }

    public lightMeasuredPayload withSentAt(String sentAt) {
        this.sentAt = sentAt;
        return this;
    }

    @JsonAnyGetter
    public Map<String, Object> getAdditionalProperties() {
        return this.additionalProperties;
    }

    @JsonAnySetter
    public void setAdditionalProperty(String name, Object value) {
        this.additionalProperties.put(name, value);
    }

    public lightMeasuredPayload withAdditionalProperty(String name, Object value) {
        this.additionalProperties.put(name, value);
        return this;
    }

    protected boolean declaredProperty(String name, Object value) {
        if ("lumens".equals(name)) {
            if (value instanceof Long) {
                setLumens(((Long) value));
            } else {
                throw new IllegalArgumentException(("property \"lumens\" is of type \"java.lang.Long\", but got "+ value.getClass().toString()));
            }
            return true;
        } else {
            if ("sentAt".equals(name)) {
                if (value instanceof String) {
                    setSentAt(((String) value));
                } else {
                    throw new IllegalArgumentException(("property \"sentAt\" is of type \"java.lang.String\", but got "+ value.getClass().toString()));
                }
                return true;
            } else {
                return false;
            }
        }
    }

    protected Object declaredPropertyOrNotFound(String name, Object notFoundValue) {
        if ("lumens".equals(name)) {
            return getLumens();
        } else {
            if ("sentAt".equals(name)) {
                return getSentAt();
            } else {
                return notFoundValue;
            }
        }
    }

    @SuppressWarnings({
        "unchecked"
    })
    public<T >T get(String name) {
        Object value = declaredPropertyOrNotFound(name, lightMeasuredPayload.NOT_FOUND_VALUE);
        if (lightMeasuredPayload.NOT_FOUND_VALUE!= value) {
            return ((T) value);
        } else {
            return ((T) getAdditionalProperties().get(name));
        }
    }

    public void set(String name, Object value) {
        if (!declaredProperty(name, value)) {
            getAdditionalProperties().put(name, ((Object) value));
        }
    }

    public lightMeasuredPayload with(String name, Object value) {
        if (!declaredProperty(name, value)) {
            getAdditionalProperties().put(name, ((Object) value));
        }
        return this;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(lightMeasuredPayload.class.getName()).append('@').append(Integer.toHexString(System.identityHashCode(this))).append('[');
        sb.append("lumens");
        sb.append('=');
        sb.append(((this.lumens == null)?"<null>":this.lumens));
        sb.append(',');
        sb.append("sentAt");
        sb.append('=');
        sb.append(((this.sentAt == null)?"<null>":this.sentAt));
        sb.append(',');
        sb.append("additionalProperties");
        sb.append('=');
        sb.append(((this.additionalProperties == null)?"<null>":this.additionalProperties));
        sb.append(',');
        if (sb.charAt((sb.length()- 1)) == ',') {
            sb.setCharAt((sb.length()- 1), ']');
        } else {
            sb.append(']');
        }
        return sb.toString();
    }

    @Override
    public int hashCode() {
        int result = 1;
        result = ((result* 31)+((this.lumens == null)? 0 :this.lumens.hashCode()));
        result = ((result* 31)+((this.sentAt == null)? 0 :this.sentAt.hashCode()));
        result = ((result* 31)+((this.additionalProperties == null)? 0 :this.additionalProperties.hashCode()));
        return result;
    }

    @Override
    public boolean equals(Object other) {
        if (other == this) {
            return true;
        }
        if ((other instanceof lightMeasuredPayload) == false) {
            return false;
        }
        lightMeasuredPayload rhs = ((lightMeasuredPayload) other);
        return ((((this.lumens == rhs.lumens)||((this.lumens!= null)&&this.lumens.equals(rhs.lumens)))&&((this.sentAt == rhs.sentAt)||((this.sentAt!= null)&&this.sentAt.equals(rhs.sentAt))))&&((this.additionalProperties == rhs.additionalProperties)||((this.additionalProperties!= null)&&this.additionalProperties.equals(rhs.additionalProperties))));
    }

}



MultiAPI Generator