// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.maps.route.models;

import com.azure.core.annotation.Immutable;
import com.azure.core.models.GeoPosition;
import com.azure.maps.route.implementation.models.LatLongPair;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
import java.util.stream.Collectors;

/**
 * A description of a part of a route, comprised of a list of points. Each additional waypoint provided in the request
 * will result in an additional leg in the returned route.
 */
@Immutable
public final class RouteLeg {
    /*
     * Summary object for route section.
     */
    @JsonProperty(value = "summary", access = JsonProperty.Access.WRITE_ONLY)
    private RouteLegSummary summary;

    /*
     * Points array
     */
    @JsonProperty(value = "points", access = JsonProperty.Access.WRITE_ONLY)
    private List<LatLongPair> points;

    /**
     * Get the summary property: Summary object for route section.
     *
     * @return the summary value.
     */
    public RouteLegSummary getSummary() {
        return this.summary;
    }

    /**
     * Returns a list of {@link GeoPosition} coordinates.
     *
     * @return a list of {@code GeoPosition} coordinates.
     */
    public List<GeoPosition> getPoints() {
        return this.points.stream()
                .map(item -> new GeoPosition(item.getLongitude(), item.getLatitude()))
                .collect(Collectors.toList());
    }
}
