<commit_before>
package ualberta.g12.adventurecreator.data;

import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/** Models the list of stories */
public class StoryList extends LModel implements Serializable {
    private List<Story> stories;

    public StoryList() {
        this.stories = new ArrayList<Story>();

        // // TODO: Implement a way to load and store these stories
        stories.add(new Story("Good Night Moon", "<NAME>"));
        stories.add(new Story("We Have To Go Back", "<NAME>"));
    }

    public StoryList(Story s) {
        this.stories = new ArrayList<Story>();
        this.stories.add(s);
    }

    /**
     * gets all stories in story list
     * 
     * @return the list of stories
     */
    public List<Story> getAllStories() {
        return this.stories;
    }

    /**
     * sets all stories in story list
     */
    public void setAllStories(List<Story> stories) {
        this.stories = stories;
        notifyViews();
    }

    /**
     * adds a story to the story listview/application
     * 
     * @param s story that has been added
     */
    public void addStory(Story s) {
        stories.add(s);
        notifyViews();
    }

    /**
     * deletes a story from the listview/application
     * 
     * @param s story to be deleted
     */
    public void deleteStory(Story s) {
        stories.remove(s);
        notifyViews();
    }

    /**
     * finds if story list contains a story object
     * 
     * @param s storylist of stories
     * @return number of stoies within the story list
     */
    public Story getStory(Story s) {
        Story temp = null;
        for (int i = 0; i < stories.size(); i++) {
            if (stories.get(i) == s) {
                temp = stories.get(i);
            }
        }
        return temp;
    }

    /**
     * finds and returns a story based on title
     * 
     * @param title tile of the story
     * @return story based on title
     */
    public Story getStory(String title) {
        // Shouldn't this method be called getSToryByTitle then?
        // Chris
        Story temp = null;
        for (int i = 0; i < stories.size(); i++) {
            if (stories.get(i).getTitle() == title) {
                temp = stories.get(i);
            }
        }
        return temp;
    }

    /**
     * Finds and returns the story based on the stories id <br>
     * If two stories have the same id - this should be impossible, return the
     * first story that we find
     * 
     * @param id of story to return
     * @return the story or null
     */
    public Story getStoryById(int id) {
        for (Story s : stories) {
            if (s.getId() == id) {
                return s;
            }
        }
        return null;
    }
<commit_msg>Changed string comparisions to use .equals instead of ==, as == will never return they are the same unless they're the same object<commit_after>
package ualberta.g12.adventurecreator.data;

import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/** Models the list of stories */
public class StoryList extends LModel implements Serializable {
    private List<Story> stories;

    public StoryList() {
        this.stories = new ArrayList<Story>();

        // // TODO: Implement a way to load and store these stories
        stories.add(new Story("Good Night Moon", "<NAME>"));
        stories.add(new Story("We Have To Go Back", "<NAME>"));
    }

    public StoryList(Story s) {
        this.stories = new ArrayList<Story>();
        this.stories.add(s);
    }

    /**
     * gets all stories in story list
     * 
     * @return the list of stories
     */
    public List<Story> getAllStories() {
        return this.stories;
    }

    /**
     * sets all stories in story list
     */
    public void setAllStories(List<Story> stories) {
        this.stories = stories;
        notifyViews();
    }

    /**
     * adds a story to the story listview/application
     * 
     * @param s story that has been added
     */
    public void addStory(Story s) {
        stories.add(s);
        notifyViews();
    }

    /**
     * deletes a story from the listview/application
     * 
     * @param s story to be deleted
     */
    public void deleteStory(Story s) {
        stories.remove(s);
        notifyViews();
    }

    /**
     * finds if story list contains a story object
     * 
     * @param s storylist of stories
     * @return number of stoies within the story list
     */
    public Story getStory(Story s) {
        Story temp = null;
        for (int i = 0; i < stories.size(); i++) {
            if (stories.get(i) == s) {
                temp = stories.get(i);
            }
        }
        return temp;
    }

    /**
     * finds and returns a story based on title
     * 
     * @param title tile of the story
     * @return story based on title
     */
    public Story getStory(String title) {
        // Shouldn't this method be called getSToryByTitle then?
        // Chris
        Story temp = null;
        for (int i = 0; i < stories.size(); i++) {
            if (stories.get(i).getTitle().equals(title)) {
                temp = stories.get(i);
            }
        }
        return temp;
    }

    /**
     * Finds and returns the story based on the stories id <br>
     * If two stories have the same id - this should be impossible, return the
     * first story that we find
     * 
     * @param id of story to return
     * @return the story or null
     */
    public Story getStoryById(int id) {
        for (Story s : stories) {
            if (s.getId() == id) {
                return s;
            }
        }
        return null;
    }

{'fraction_non_alphanumeric': 0.10509885535900104, 'fraction_numerical': 0.001387443635102324, 'mean_word_length': 1.7846450989859972, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 19, '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': '3829700', 'n_tokens_mistral': 1703, 'n_tokens_neox': 1635, 'n_words': 563}