/**
 * Copyright © 2016 Sascha Lamp (sascha.lamp@outlook.de)
 * <p>
 * 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
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * 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.
 */
package de.lampware.racing.istats.model;

/**
 * TODO JavaDoc
 *
 * @author sasch.
 */
public class SubsessionResultsRow implements IracingModel {

    private final String carNumber;
    private final int customerId;
    private final String displayName;
    private final int groupId;
    private final int carClassId;
    private final int simSessionNumber;
    private final int startingPosition;
    private final int lapsCompleted;
    private final int lapsLed;
    private final int oldIrating;
    private final int newIrating;

    private SubsessionResultsRow(Builder builder) {
        carNumber = builder.carNumber;
        customerId = builder.customerId;
        displayName = builder.displayName;
        groupId = builder.groupId;
        carClassId = builder.carClassId;
        simSessionNumber = builder.simSessionNumber;
        startingPosition = builder.startingPosition;
        lapsCompleted = builder.lapsCompleted;
        lapsLed = builder.lapsLed;
        oldIrating = builder.oldIrating;
        newIrating = builder.newIrating;
    }

    public static Builder builder() {
        return new Builder();
    }

    public String getCarNumber() {
        return carNumber;
    }

    public int getCustomerId() {
        return customerId;
    }

    public String getDisplayName() {
        return displayName;
    }

    public int getGroupId() {
        return groupId;
    }

    public int getCarClassId() {
        return carClassId;
    }

    public int getSimSessionNumber() {
        return simSessionNumber;
    }

    public int getStartingPosition() {
        return startingPosition;
    }

    public int getLapsCompleted() {
        return lapsCompleted;
    }

    public int getLapsLed() {
        return lapsLed;
    }

    public int getOldIrating() {
        return oldIrating;
    }

    public int getNewIrating() {
        return newIrating;
    }

    /**
     * {@code SubsessionResultsRow} builder static inner class.
     */
    public static final class Builder {

        private String carNumber;
        private int customerId;
        private String displayName;
        private int groupId;
        private int carClassId;
        private int simSessionNumber;
        private int startingPosition;
        private int lapsCompleted;
        private int lapsLed;
        private int oldIrating;
        private int newIrating;

        private Builder() {
        }

        /**
         * Sets the {@code carNumber} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param val the {@code carNumber} to set
         * @return a reference to this Builder
         */
        public Builder withCarNumber(String val) {
            carNumber = val;
            return this;
        }

        /**
         * Sets the {@code customerId} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param val the {@code customerId} to set
         * @return a reference to this Builder
         */
        public Builder withCustomerId(int val) {
            customerId = val;
            return this;
        }

        /**
         * Sets the {@code displayName} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param val the {@code displayName} to set
         * @return a reference to this Builder
         */
        public Builder withDisplayName(String val) {
            displayName = val;
            return this;
        }

        /**
         * Sets the {@code groupId} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param val the {@code groupId} to set
         * @return a reference to this Builder
         */
        public Builder withGroupId(int val) {
            groupId = val;
            return this;
        }

        /**
         * Sets the {@code carClassId} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param val the {@code carClassId} to set
         * @return a reference to this Builder
         */
        public Builder withCarClassId(int val) {
            carClassId = val;
            return this;
        }

        /**
         * Sets the {@code simSessionNumber} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param val the {@code simSessionNumber} to set
         * @return a reference to this Builder
         */
        public Builder withSimSessionNumber(int val) {
            simSessionNumber = val;
            return this;
        }

        /**
         * Sets the {@code startingPosition} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param val the {@code startingPosition} to set
         * @return a reference to this Builder
         */
        public Builder withStartingPosition(int val) {
            startingPosition = val;
            return this;
        }

        /**
         * Sets the {@code lapsCompleted} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param val the {@code lapsCompleted} to set
         * @return a reference to this Builder
         */
        public Builder withLapsCompleted(int val) {
            lapsCompleted = val;
            return this;
        }

        /**
         * Sets the {@code lapsLed} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param val the {@code lapsLed} to set
         * @return a reference to this Builder
         */
        public Builder withLapsLed(int val) {
            lapsLed = val;
            return this;
        }

        /**
         * Sets the {@code oldIrating} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param val the {@code oldIrating} to set
         * @return a reference to this Builder
         */
        public Builder withOldIrating(int val) {
            oldIrating = val;
            return this;
        }

        /**
         * Sets the {@code newIrating} and returns a reference to this Builder so that the methods can be chained together.
         *
         * @param val the {@code newIrating} to set
         * @return a reference to this Builder
         */
        public Builder withNewIrating(int val) {
            newIrating = val;
            return this;
        }

        /**
         * Returns a {@code SubsessionResultsRow} built from the parameters previously set.
         *
         * @return a {@code SubsessionResultsRow} built with parameters of this {@code SubsessionResultsRow.Builder}
         */
        public SubsessionResultsRow build() {
            return new SubsessionResultsRow(this);
        }
    }
}
