/**
 * Retz
 * Copyright (C) 2016-2017 Nautilus Technologies, Inc.
 * <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 io.github.retz.planner.spi;

import io.github.retz.protocol.data.Job;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Plan {
    private Map<String, List<Job>> jobSpecs = new HashMap<>();
    private List<Job> toKeep = new LinkedList<>();
    private List<String> offerIdsToStock = new LinkedList<>();

    public Plan() {
    }

    public void setJob(String offerId, Job job) {
        List<Job> jobs = jobSpecs.getOrDefault(offerId, new LinkedList<>());
        jobs.add(job);
        if (!jobSpecs.containsKey(offerId)) {
            jobSpecs.put(offerId, jobs);
        }
    }

    public void addStock(String offerId) {
        offerIdsToStock.add(offerId);
    }

    public void addKeep(List<Job> jobs) {
        toKeep.addAll(jobs);
    }

    public Map<String, List<Job>> getJobSpecs() {
        return jobSpecs;
    }

    public List<Job> getToKeep() {
        return toKeep;
    }

    public List<String> getOfferIdsToStock() {
        return offerIdsToStock;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{").append("jobSpecs={");
        for (Map.Entry<String, List<Job>> entry : jobSpecs.entrySet()) {
            sb.append(entry.getKey()).append("={")
                    .append(String.join(",",
                            entry.getValue().stream().map(j -> j.pp()).collect(Collectors.toList())))
                    .append("},");
        }
        sb.append("}, toKeep={");
        sb.append(String.join(", ", toKeep.stream().map(j -> j.pp()).collect(Collectors.toList())));
        sb.append("}, offerIdsToStock={");
        sb.append(String.join(", ", offerIdsToStock));
        sb.append("}}");
        return sb.toString();
    }
}



@@ -3,16 +3,19 @@
 *%0A *
+   
  Retz%0A *
  Cop
@@ -10,16 +10,19 @@
  Retz%0A *
+   
  Copyrig
@@ -68,23 +68,22 @@
  Inc.%0A *
- %3Cp%3E
 %0A *
+   
  License
@@ -141,16 +141,19 @@
 se%22);%0A *
+   
  you may
@@ -212,16 +212,19 @@
 ense.%0A *
+   
  You may
@@ -258,23 +258,26 @@
 se at%0A *
- %3Cp%3E%0A *
+%0A *       
  http://
@@ -318,15 +318,14 @@
 0%0A *
- %3Cp%3E
 %0A *
+   
  Unl
@@ -391,16 +391,19 @@
 tware%0A *
+   
  distrib
@@ -463,16 +463,19 @@
 ASIS,%0A *
+   
  WITHOUT
@@ -542,16 +542,19 @@
 lied.%0A *
+   
  See the
@@ -616,16 +616,19 @@
 s and%0A *
+   
  limitat

Fix license text