package net.explorviz.settings.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import xyz.morphia.annotations.Entity;
import xyz.morphia.annotations.Reference;

/**
 * Represents a specific setting a user has set a value other than the default value for 
 */
@Entity("UserSetting")
public class UserSetting<T> {

  // the setting
  @Reference("Setting")
  @JsonIgnore
  private final String settingId;
  
  // the user id
  private final String userId;
  
  // the value
  private final T value;
  
  
  /**
   * Creates a new user setting.
   * @param userId the id of the user
   * @param setting the setting object
   * @param value the value for this setting
   */
  public UserSetting(String userId, String settingId, T value) {
    this.settingId = settingId;
    this.userId = userId;
    this.value = value;
  }


  public String getSettingId() {
    return settingId;
  }


  public String getUserId() {
    return userId;
  }


  public Object getValue() {
    return value;
  }

  
  private class UserSettingId {
    
    
    
  }

  
}

@@ -123,16 +123,92 @@
 Entity;%0A
+import xyz.morphia.annotations.Id;%0Aimport xyz.morphia.annotations.Property;%0A
 import x
@@ -241,16 +241,16 @@
 erence;%0A
-
 %0A/**%0A * 
@@ -400,143 +400,55 @@
 %0A%0A  
-// the setting%0A  @Reference(%22Setting%22)%0A  @JsonIgnore%0A  private final String settingId;%0A  %0A  // the user id%0A  private final String userI
+@Id%0A  private final UserSetting.UserSettingId i
 d;%0A 
@@ -740,55 +740,49 @@
 his.
-settingId = settingId;%0A    this.userId =
+id = new UserSettingId(settingId,
  userId
+)
 ;%0A  
@@ -853,16 +853,19 @@
  return 
+id.
 settingI
@@ -914,16 +914,19 @@
  return 
+id.
 userId;%0A
@@ -989,40 +989,541 @@
 %0A%0A  
-%0A  private class UserSettingId %7B
+/**%0A   * %0A   * A user setting is identified by both by the id of the user and the id of the setting.%0A   * This class functions as a composite key%0A   *%0A   */%0A  @Entity(noClassnameStored = true)%0A  private class UserSettingId %7B%0A    %0A    @Property(%22settingId%22)%0A    private String settingId;%0A    @Property(%22userId%22)%0A    private String userId;%0A    %0A    private UserSettingId(String settingId, String userId) %7B%0A      this.settingId = settingId;%0A      this.userId = userId;%0A    %7D%0A%0A    %0A    public UserSettingId() %7B%0A      // Serializing%0A    %7D
 %0A   

Add composite id to UserSetting