package org.example.tampoposerverdtram.resources;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.*;
public class User {
private Activities activities = new Activities();
private String lastUpdatedTime;
private String name;
private String email;
private Map<String, String> friends;
public Map<String, Object> getValue() {
Map temp_nil12 = new HashMap<>();
temp_nil12.put("friends",this.getFriends());
temp_nil12.put("name",this.getName());
temp_nil12.put("email",this.getEmail());
temp_nil12.put("activities",this.activities.getValue());
temp_nil12.put("lastUpdatedTime",this.getLastUpdatedTime());
return temp_nil12;
}
public Activities getActivities() {
return this.activities;
}
public void updateLastUpdatedTimeFromUpdatedTime(String self, String userId, int activityId, String updatedTime) {
this.lastUpdatedTime = updatedTime;
}
public String getLastUpdatedTime() {
return this.lastUpdatedTime;
}
public String getName() {
return this.name;
}
public void updateName(String userId, String name) {
this.name = name;
}
public String getEmail() {
return this.email;
}
public void updateEmail(String userId, String email) {
this.email = email;
}
public void updateFriendsFromDeletedFriendPair(String self, String deletedFriendPair_json) throws JsonProcessingException {
Map<String, Object> deletedFriendPair = new HashMap<>();
{
Map<String, Object> i = new ObjectMapper().readValue(deletedFriendPair_json, HashMap.class);
deletedFriendPair = i;
}
if (self.equals(deletedFriendPair.get("user1Id"))) {
Map<String, String> temp_if31;
if (this.friends.containsKey(deletedFriendPair.get("pairId"))) {
this.friends.remove(deletedFriendPair.get("pairId"));
temp_if31 = this.friends;
} else {
temp_if31 = this.friends;
}this.friends = temp_if31;
}
if (self.equals(deletedFriendPair.get("user1Id"))) {
Map<String, String> temp_if30;
if (this.friends.containsKey(deletedFriendPair.get("pairId"))) {
this.friends.remove(deletedFriendPair.get("pairId"));
temp_if30 = this.friends;
} else {
temp_if30 = this.friends;
}
this.friends = temp_if30;
}
}
public void updateFriendsFromPair(String self, String pid, String pair_json) throws JsonProcessingException {
Map<String, Object> pair = new HashMap<>();
{
Map<String, Object> i = new ObjectMapper().readValue(pair_json, HashMap.class);
pair = i;
}
if (self.equals(pair.get("user0Id"))) {
this.friends.put(pid,(String) pair.get("user1Id"));
}
if (self.equals(pair.get("user1Id"))) {
this.friends.put(pid,(String) pair.get("user0Id"));
}
}
public Map<String, String> getFriends() {
return this.friends;
}
public User(String name, String lastUpdatedTime, String email, Map<String, String> friends) {
this.name = name;
this.lastUpdatedTime = lastUpdatedTime;
this.email = email;
this.friends = friends;
}
}