<commit_before>package com.google.sps.data;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Entity;
import java.util.ArrayList;
import java.util.List;
import com.google.sps.service.DatabaseService;

public class Room {
    public static final String ROOM_ENTITY_NAME = "Room";
    public static final String TITLE_PROPERTY_KEY = "title";
    public static final String DESCRIPTION_PROPERTY_KEY = "description";
    public static final String HOST_PROPERTY_KEY = "host";
    public static final String FOLLOWERS_PROPERTY_KEY = "followers";
    public static final String FORMS_PROPERTY_KEY = "forms";
    

    private Entity entity;

    public Room(Entity entity) {
        this.entity = entity;
    }

    public Room(User host, String title, String description) { 
        this.entity = new Entity(Room.ROOM_ENTITY_NAME);
        this.entity.setProperty(Room.TITLE_PROPERTY_KEY, title);
        this.entity.setProperty(Room.DESCRIPTION_PROPERTY_KEY, description);
        this.entity.setProperty(Room.HOST_PROPERTY_KEY, host.getUserKey());
        this.entity.setProperty(Room.FOLLOWERS_PROPERTY_KEY, null);
        this.entity.setProperty(Room.FORMS_PROPERTY_KEY, null);
    }

    public Entity getRoomEntity() {
        return this.entity;
    }

    public Key getHost() {
        return (Key) this.entity.getProperty(Room.HOST_PROPERTY_KEY);
    }

    public void setHost(User host) { 
        this.entity.setProperty(Room.HOST_PROPERTY_KEY, host.getUserKey());
    }

    public String getTitle() {
        return (String) this.entity.getProperty(Room.TITLE_PROPERTY_KEY);
    }

    public void setTitle(String title){
        this.entity.setProperty(Room.TITLE_PROPERTY_KEY, title);
    }

    @SuppressWarnings("unchecked")
    public List<Key> getAllFollowers() {
        return (ArrayList<Key>) this.entity.getProperty(Room.FOLLOWERS_PROPERTY_KEY);
    }

    @SuppressWarnings("unchecked")
    public List<Key> getAllForms() { 
        return (ArrayList<Key>) this.entity.getProperty(Room.FORMS_PROPERTY_KEY); 
    }
    
    @SuppressWarnings("unchecked")
    public void addFollower(User follower) {
        List<Key> followers = (ArrayList<Key>) this.entity.getProperty(Room.FOLLOWERS_PROPERTY_KEY);
        if(followers == null){
            followers = new ArrayList<>();
        }
        followers.add(follower.getUserKey());
        this.entity.setProperty(Room.FOLLOWERS_PROPERTY_KEY, followers);
    }

    @SuppressWarnings("unchecked")
    public void removeFollower(User follower) {
        List<Key> followers = (ArrayList<Key>) this.entity.getProperty(Room.FOLLOWERS_PROPERTY_KEY);
        if(followers == null){
            return;
        } else {
            followers.remove(follower.getUserKey());
            this.entity.setProperty(Room.FOLLOWERS_PROPERTY_KEY, followers);
        }
    }

    @SuppressWarnings("unchecked")
    public void addForm(Form form) {
        List<Key> forms = (ArrayList<Key>) this.entity.getProperty(Room.FORMS_PROPERTY_KEY);
        if(forms == null){
            forms = new ArrayList<>();
        }
        forms.add(form.getFormKey());
        this.entity.setProperty(Room.FORMS_PROPERTY_KEY, forms);
    }

    @SuppressWarnings("unchecked")
    public void removeForm(Form form) {
        List<Key> forms = (ArrayList<Key>) this.entity.getProperty(Room.FORMS_PROPERTY_KEY);
        if(forms == null){
            return;
        } else {
            forms.remove(form.getFormKey());
            this.entity.setProperty(Room.FORMS_PROPERTY_KEY, forms);
        }
    }

    @SuppressWarnings("unchecked")
    public boolean isFollowerInRoom(User follower) {
        List<Key> followers = (ArrayList<Key>) this.entity.getProperty(Room.FOLLOWERS_PROPERTY_KEY);
        return (!(followers.lastIndexOf(follower.getUserKey()) == -1));
    }
}<commit_msg>Change add/remove followers to properly reference arrayLists<commit_after>package com.google.sps.data;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Entity;
import java.util.ArrayList;
import java.util.List;
import com.google.sps.service.DatabaseService;

public class Room {
    public static final String ROOM_ENTITY_NAME = "Room";
    public static final String TITLE_PROPERTY_KEY = "title";
    public static final String DESCRIPTION_PROPERTY_KEY = "description";
    public static final String HOST_PROPERTY_KEY = "host";
    public static final String FOLLOWERS_PROPERTY_KEY = "followers";

    private Entity entity;

    public Room(Entity entity) {
        this.entity = entity;
    }

    public Room(User host, String title, String description) { 
        this.entity = new Entity(Room.ROOM_ENTITY_NAME);
        this.entity.setProperty(Room.TITLE_PROPERTY_KEY, title);
        this.entity.setProperty(Room.DESCRIPTION_PROPERTY_KEY, description);
        this.entity.setProperty(Room.HOST_PROPERTY_KEY, host.getUserKey());
    }

    public Entity getRoomEntity() {
        return this.entity;
    }

    public Key getHost() {
        return (Key) this.entity.getProperty(Room.HOST_PROPERTY_KEY);
    }

    public void setHost(User host) { 
        this.entity.setProperty(Room.HOST_PROPERTY_KEY, host.getUserKey());
    }

    public String getTitle() {
        return (String) this.entity.getProperty(Room.TITLE_PROPERTY_KEY);
    }

    public void setTitle(String title){
        this.entity.setProperty(Room.TITLE_PROPERTY_KEY, title);
    }

    @SuppressWarnings("unchecked")
    public List<Key> getAllFollowers() {
        return (ArrayList<Key>) this.entity.getProperty(Room.FOLLOWERS_PROPERTY_KEY);
    }
    
    @SuppressWarnings("unchecked")
    public void addFollower(User follower) {
        if (this.entity.getProperty(Room.FOLLOWERS_PROPERTY_KEY) == null) {
            this.entity.setProperty(Room.FOLLOWERS_PROPERTY_KEY, new ArrayList<Key>());
        }
        ArrayList<Key> followers = (ArrayList<Key>) this.entity.getProperty(Room.FOLLOWERS_PROPERTY_KEY);
        followers.add(follower.getUserKey());
    }

    @SuppressWarnings("unchecked")
    public void removeFollower(User follower) {
        if (this.entity.getProperty(Room.FOLLOWERS_PROPERTY_KEY) == null) {
            this.entity.setProperty(Room.FOLLOWERS_PROPERTY_KEY, new ArrayList<Key>());
        }
        ArrayList<Key> followers = (ArrayList<Key>) this.entity.getProperty(Room.FOLLOWERS_PROPERTY_KEY);
        followers.remove(follower.getUserKey());
    }

    @SuppressWarnings("unchecked")
    public boolean isFollowerInRoom(User follower) {
        List<Key> followers = (ArrayList<Key>) this.entity.getProperty(Room.FOLLOWERS_PROPERTY_KEY);
        return (!(followers.lastIndexOf(follower.getUserKey()) == -1));
    }
}
{'fraction_non_alphanumeric': 0.11064965885493919, 'fraction_numerical': 0.0002966478789676654, 'mean_word_length': 3.3928338762214985, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '410616', 'n_tokens_mistral': 2015, 'n_tokens_neox': 2016, 'n_words': 355}