package com.utic.center.utic.traf.server.dto.utic;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@Builder
@NoArgsConstructor//(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class TrafficGrade implements Serializable {
    private static final long serialVersionUID = 1L;

    private Integer roadRank;
    private Integer minSpeed;
    private Integer maxSpeed;

    private Integer limitMinSpeed;
    private Integer limitMaxSpeed;

    public int getTrafficGrade(int speed) {
        if (speed <= 0) return 0;

        if (this.minSpeed > speed)
            return 3;

        if (this.maxSpeed < speed)
            return 1;

        return 2;
    }

}
