// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.configserver;

import com.google.common.collect.ImmutableSortedSet;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.RotationName;

import java.util.Objects;
import java.util.Optional;
import java.util.Set;

/**
 *  Represents an exclusive load balancer, assigned to an application's cluster.
 *
 * @author mortent
 */
public class LoadBalancer {

    private final String id;
    private final ApplicationId application;
    private final ClusterSpec.Id cluster;
    private final HostName hostname;
    private final Optional<String> dnsZone;
    private final Set<RotationName> rotations;

    // TODO(mpolden): Kept for API compatibility with internal code. This constructor can be removed when all usages are
    // TODO(mpolden): removed
    public LoadBalancer(String id, ApplicationId application, ClusterSpec.Id cluster, HostName hostname,
                        Optional<String> dnsZone, Set<RotationName> rotations) {
        this.id = Objects.requireNonNull(id, "id must be non-null");
        this.application = Objects.requireNonNull(application, "application must be non-null");
        this.cluster = Objects.requireNonNull(cluster, "cluster must be non-null");
        this.hostname = Objects.requireNonNull(hostname, "hostname must be non-null");
        this.dnsZone = Objects.requireNonNull(dnsZone, "dnsZone must be non-null");
        this.rotations = ImmutableSortedSet.copyOf(Objects.requireNonNull(rotations, "rotations must be non-null"));
    }

    public LoadBalancer(String id, ApplicationId application, ClusterSpec.Id cluster, HostName hostname,
                        Optional<String> dnsZone) {
        this.id = Objects.requireNonNull(id, "id must be non-null");
        this.application = Objects.requireNonNull(application, "application must be non-null");
        this.cluster = Objects.requireNonNull(cluster, "cluster must be non-null");
        this.hostname = Objects.requireNonNull(hostname, "hostname must be non-null");
        this.dnsZone = Objects.requireNonNull(dnsZone, "dnsZone must be non-null");
        this.rotations = Set.of();
    }

    public String id() {
        return id;
    }

    public ApplicationId application() {
        return application;
    }

    public ClusterSpec.Id cluster() {
        return cluster;
    }

    public HostName hostname() {
        return hostname;
    }

    public Optional<String> dnsZone() {
        return dnsZone;
    }

    public Set<RotationName> rotations() {
        return rotations;
    }

}

@@ -183,61 +183,8 @@
 r;%0A%0A
-import com.google.common.collect.ImmutableSortedSet;%0A
 impo
@@ -228,16 +228,16 @@
 tionId;%0A
+
 import c
@@ -322,56 +322,8 @@
 ame;
-%0Aimport com.yahoo.config.provision.RotationName;
 %0A%0Aim
@@ -376,30 +376,8 @@
 nal;
-%0Aimport java.util.Set;
 %0A%0A/*
@@ -714,936 +714,8 @@
 one;
-%0A    private final Set%3CRotationName%3E rotations;%0A%0A    // TODO(mpolden): Kept for API compatibility with internal code. This constructor can be removed when all usages are%0A    // TODO(mpolden): removed%0A    public LoadBalancer(String id, ApplicationId application, ClusterSpec.Id cluster, HostName hostname,%0A                        Optional%3CString%3E dnsZone, Set%3CRotationName%3E rotations) %7B%0A        this.id = Objects.requireNonNull(id, %22id must be non-null%22);%0A        this.application = Objects.requireNonNull(application, %22application must be non-null%22);%0A        this.cluster = Objects.requireNonNull(cluster, %22cluster must be non-null%22);%0A        this.hostname = Objects.requireNonNull(hostname, %22hostname must be non-null%22);%0A        this.dnsZone = Objects.requireNonNull(dnsZone, %22dnsZone must be non-null%22);%0A        this.rotations = ImmutableSortedSet.copyOf(Objects.requireNonNull(rotations, %22rotations must be non-null%22));%0A    %7D
 %0A%0A  
@@ -1293,43 +1293,8 @@
 %22);%0A
-        this.rotations = Set.of();%0A
     
@@ -1593,24 +1593,24 @@
 dnsZone() %7B%0A
+
         retu
@@ -1632,82 +1632,6 @@
  %7D%0A%0A
-    public Set%3CRotationName%3E rotations() %7B%0A        return rotations;%0A    %7D%0A%0A
 %7D%0A

Remove rotations from LoadBalancer