package com.campmongoose.serversaturday.common.submission;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public abstract class AbstractSubmitter<B extends AbstractBuild, I, L> {

    protected final Map<String, B> builds = new HashMap<>();
    @Nonnull
    protected final String name;
    @Nonnull
    protected final UUID uuid;

    protected AbstractSubmitter(@Nonnull String name, @Nonnull UUID uuid) {
        this.name = name;
        this.uuid = uuid;
    }

    @Nullable
    public B getBuild(@Nonnull String name) {
        return builds.get(name);
    }

    @Nonnull
    public List<B> getBuilds() {
        return new ArrayList<>(builds.values());
    }

    @Nonnull
    public abstract I getMenuRepresentation();

    @Nonnull
    public String getName() {
        return name;
    }

    @Nonnull
    public UUID getUUID() {
        return uuid;
    }

    @Nonnull
    public abstract B newBuild(@Nonnull String name, @Nonnull L location);

    public boolean removeBuild(@Nonnull String name) {
        return builds.remove(name) != null;
    }

    public abstract void save(@Nonnull File file);
}

package com.campmongoose.serversaturday.common.submission;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public abstract class AbstractSubmitter<B extends AbstractBuild, I, L> {

    protected final Map<String, B> builds = new HashMap<>();
    @Nonnull
    protected final String name;
    @Nonnull
    protected final UUID uuid;

    protected AbstractSubmitter(@Nonnull String name, @Nonnull UUID uuid) {
        this.name = name;
        this.uuid = uuid;
    }

    @Nullable
    public B getBuild(@Nonnull String name) {
        return builds.get(name);
    }

    @Nonnull
    public List<B> getBuilds() {
        return new ArrayList<>(builds.values());
    }

    @Nonnull
    public abstract I getMenuRepresentation();

    @Nonnull
    public String getName() {
        return name;
    }

    @Nonnull
    public UUID getUUID() {
        return uuid;
    }

    @Nonnull
    public abstract B newBuild(@Nonnull String name, @Nonnull L location);

    public boolean removeBuild(@Nonnull String name) {
        return builds.remove(name) != null;
    }

    public void renameBuild(String newName, B build) {
        builds.remove(build.getName());
        build.setName(newName);
        builds.put(newName, build);
    }

    public abstract void save(@Nonnull File file);
}

Fix an issue with updating builds.
Fix an issue with updating builds.
