<commit_before>package io.rocketchat.core.factory;

import java.util.ArrayList;
import java.util.List;

import io.rocketchat.common.data.model.Room;
import io.rocketchat.core.RocketChatAPI;
import io.rocketchat.core.model.SubscriptionObject;

/**
 * Created by sachin on 29/7/17.
 */

// TODO: 29/7/17 add methods for getting rooms based on favourites, one to one and groups (public and private)
// TODO: 29/7/17 might have to make separate arraylist for each type, seems little impossible, better to keep generic
public class ChatRoomFactory {

    private RocketChatAPI api;
    private ArrayList<RocketChatAPI.ChatRoom> rooms;

    public ChatRoomFactory(RocketChatAPI api) {
        this.api = api;
        rooms = new ArrayList<>();
    }

    private RocketChatAPI.ChatRoom createChatRoom(Room room) {
        return api.new ChatRoom(room);
    }

    public ChatRoomFactory createChatRooms(List<SubscriptionObject> roomObjects) {
        removeAllChatRooms();
        for (Room room : roomObjects) {
            rooms.add(createChatRoom(room));
        }
        return this;
    }

    public ChatRoomFactory addChatRoom(Room room) {
        if (getChatRoomByName(room.getRoomName()) == null) {
            RocketChatAPI.ChatRoom newRoom = createChatRoom(room);
            rooms.add(newRoom);
        }
        return this;
    }

    public ArrayList<RocketChatAPI.ChatRoom> getChatRooms() {
        return rooms;
    }

    public RocketChatAPI.ChatRoom getChatRoomByName(String roomName) {
        for (RocketChatAPI.ChatRoom room : rooms) {
            if (room.getRoomData().getRoomName().equals(roomName)) {
                return room;
            }
        }
        return null;
    }

    public RocketChatAPI.ChatRoom getChatRoomById(String roomId) {
        for (RocketChatAPI.ChatRoom room : rooms) {<commit_msg>This is supposed to be generic<commit_after>package io.rocketchat.core.factory;

import java.util.ArrayList;
import java.util.List;

import io.rocketchat.common.data.model.Room;
import io.rocketchat.core.RocketChatAPI;
import io.rocketchat.core.model.SubscriptionObject;

/**
 * Created by sachin on 29/7/17.
 */

// TODO: 29/7/17 add methods for getting rooms based on favourites, one to one and groups (public and private)
// TODO: 29/7/17 might have to make separate arraylist for each type, seems little impossible, better to keep generic
public class ChatRoomFactory {

    private RocketChatAPI api;
    private ArrayList<RocketChatAPI.ChatRoom> rooms;

    public ChatRoomFactory(RocketChatAPI api) {
        this.api = api;
        rooms = new ArrayList<>();
    }

    private RocketChatAPI.ChatRoom createChatRoom(Room room) {
        return api.new ChatRoom(room);
    }

    public ChatRoomFactory createChatRooms(List<? extends Room> roomObjects) {
        removeAllChatRooms();
        for (Room room : roomObjects) {
            rooms.add(createChatRoom(room));
        }
        return this;
    }

    public ChatRoomFactory addChatRoom(Room room) {
        if (getChatRoomByName(room.getRoomName()) == null) {
            RocketChatAPI.ChatRoom newRoom = createChatRoom(room);
            rooms.add(newRoom);
        }
        return this;
    }

    public ArrayList<RocketChatAPI.ChatRoom> getChatRooms() {
        return rooms;
    }

    public RocketChatAPI.ChatRoom getChatRoomByName(String roomName) {
        for (RocketChatAPI.ChatRoom room : rooms) {
            if (room.getRoomData().getRoomName().equals(roomName)) {
                return room;
            }
        }
        return null;
    }

    public RocketChatAPI.ChatRoom getChatRoomById(String roomId) {
        for (RocketChatAPI.ChatRoom room : rooms) {
{'fraction_non_alphanumeric': 0.09209453952730236, 'fraction_numerical': 0.008149959250203748, 'mean_word_length': 2.7958762886597937, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5394681', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1064, 'n_words': 265}