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

com.example.StrangePersonValue Maven / Gradle / Ivy

There is a newer version: 0.8.0
Show newest version
package com.example;

import java.lang.Boolean;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * Value type StrangePersonValue.
 *
 * Auto-generated from specification.
 */
public final class StrangePersonValue {
    private final int id;

    private final String name;

    /**
     * Constructor.
     */
    private StrangePersonValue(int id, String name) {
        this.id = id;
        this.name = name;
    }

    /**
     * Factory method for builder.
     * @return a new builder for StrangePersonValue
     */
    public static Builder builder() {
        return new Builder();
    }

    /**
     * Getter for the property id.
     * @return the value of id
     */
    public int getId() {
        return id;
    }

    /**
     * Getter for the property name.
     * @return the value of name
     */
    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        return "StrangePersonValue[id=" + id + ", name=" + name + "]";
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name);
    }

    @Override
    public boolean equals(Object other) {
        if (other == this) {
            return true;
        }
        else if (other == null || !this.getClass().equals(other.getClass())) {
            return false;
        }
        final StrangePersonValue that = (StrangePersonValue) other;
        return this.id == that.id && (this.name == null && that.name == null || (this.name != null && this.name.equals(that.name)));
    }

    /**
     * The builder for StrangePersonValue.
     */
    public static final class Builder {
        private int id = 5;

        private String name = "";

        private Builder() {
        }

        /**
         * Method to configure property id on the builder.
         * @return this builder
         */
        public Builder id(int id) {
            this.id = id;
            return this;
        }

        /**
         * Method to configure property name on the builder.
         * @return this builder
         */
        public Builder name(String name) {
            this.name = name;
            return this;
        }

        /**
         * Applies the function to the builder if and only if the condition is {@code true}.
         * @param condition the condition to evaluate
         * @param function the function to apply
         * @return this builder
         */
        public Builder ifThen(Supplier condition, Function function) {
            if (condition.get()) {
                return function.apply(this);
            }
            else {
                return this;
            }
        }

        /**
         * Build an instance of StrangePersonValue.
         * @return a new instance of StrangePersonValue
         */
        public StrangePersonValue build() {
            return new StrangePersonValue(id, name);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy