package com.google.sps.data;

import java.util.HashSet;
import java.util.Set;

public final class VolunteeringOpportunity {
  private final long opportunityId =
    10000000L; // TODO: Needed for storing ID from DB, replace using ID generated by DB
  private String name;
  private int numSpotsLeft;
  private Set<String> requiredSkills;
  private Set<User> volunteers;

  public static class Builder {
    // Required parameters
    private String name;
    private int numSpotsLeft;

    // Optional parameters
    private Set<String> requiredSkills;
    private Set<User> volunteers;

    public Builder(String name, int numSpotsLeft) {
      this.name = name;
      this.numSpotsLeft = numSpotsLeft;
      this.requiredSkills = new HashSet<>();
      this.volunteers = new HashSet<>();
    }

    public Builder setName(String name) {
      this.name = name;
      return this;
    }

    public Builder setNumSpotsLeft(int numSpotsLeft) {
      this.numSpotsLeft = numSpotsLeft;
      return this;
    }

    public Builder setRequiredSkills(Set<String> requiredSkills) {
      this.requiredSkills = requiredSkills;
      return this;
    }

    public Builder addRequiredSkill(String requiredSkill) {
      this.requiredSkills.add(requiredSkill);
      return this;
    }

    public Builder removeRequiredSkill(String requiredSkill) {
      this.requiredSkills.remove(requiredSkill);
      return this;
    }

    public Builder setVolunteers(Set<User> volunteers) {
      this.volunteers = volunteers;
      return this;
    }

    public Builder addVolunteer(User volunteer) {
      this.volunteers.add(volunteer);
      return this;
    }

    public Builder removeVolunteer(User volunteer) {
      this.volunteers.remove(volunteer);
      return this;
    }

    public VolunteeringOpportunity build() {
      return new VolunteeringOpportunity(this);
    }

    public Builder mergeFrom(VolunteeringOpportunity other) {
      this.name = other.getName();
      this.numSpotsLeft = other.getNumSpotsLeft();

      if (!other.getRequiredSkills().isEmpty()) {
        this.requiredSkills = other.getRequiredSkills();
      }
      if (!other.getVolunteers().isEmpty()) {
        this.volunteers = other.getVolunteers();
      }
      return this;
    }
  }

  private VolunteeringOpportunity(Builder builder) {
    name = builder.name;
    numSpotsLeft = builder.numSpotsLeft;
    requiredSkills = builder.requiredSkills;
    volunteers = builder.volunteers;
  }

  public long getOpportunityId() {
    return this.opportunityId;
  }

  public String getName() {
    return this.name;
  }

  public Set<String> getRequiredSkills() {
    return this.requiredSkills;
  }

  public int getNumSpotsLeft() {
    return this.numSpotsLeft;
  }

  public Set<User> getVolunteers() {
    return this.volunteers;
  }

  public Builder toBuilder() {
    return new Builder(this.name, this.numSpotsLeft).mergeFrom(this);
  }

  @Override
  public String toString() {
    return String.format("Name: %s\nNumber of spots left: %d\n", this.name, this.numSpotsLeft);
  }
}

@@ -70,16 +70,39 @@
 til.Set;
+%0Aimport java.util.UUID;
 %0A%0Apublic
@@ -154,16 +154,12 @@
 ate 
-final lo
+Stri
 ng o
@@ -174,98 +174,35 @@
 tyId
- =%0A    10000000L; // TODO: Needed for storing ID from DB, replace using ID generated by DB
+;%0A  private String eventId;
 %0A  p
@@ -371,32 +371,125 @@
 ired parameters%0A
+    private String opportunityId = UUID.randomUUID().toString();%0A    private String eventId;%0A
     private Stri
@@ -652,24 +652,40 @@
 lder(String 
+eventId, String 
 name, int nu
@@ -690,32 +690,62 @@
 numSpotsLeft) %7B%0A
+      this.eventId = eventId;%0A
       this.name 
@@ -877,32 +877,160 @@
 Set%3C%3E();%0A    %7D%0A%0A
+    public Builder setOpportunityId(String opportunityId) %7B%0A      this.opportunityId = opportunityId;%0A      return this;%0A    %7D%0A%0A
     public Build
@@ -2144,24 +2144,118 @@
 ty other) %7B%0A
+      this.opportunityId = other.getOpportunityId();%0A      this.eventId = other.getEventId();%0A
       this.n
@@ -2626,24 +2626,98 @@
  builder) %7B%0A
+    opportunityId = builder.opportunityId;%0A    eventId = builder.eventId;%0A
     name = b
@@ -2870,10 +2870,12 @@
 lic 
-lo
+Stri
 ng g
@@ -2926,24 +2926,85 @@
 ityId;%0A  %7D%0A%0A
+  public String getEventId() %7B%0A    return this.eventId;%0A  %7D%0A%0A
   public Str
@@ -3318,16 +3318,30 @@
 Builder(
+this.eventId, 
 this.nam

Add missing setter for opportunityId to VolunteeringOpporutnity.