<commit_before>package backend.resource;

import backend.IssueMetadata;
import backend.resource.serialization.SerializableIssue;
import org.eclipse.egit.github.core.Issue;
import org.eclipse.egit.github.core.Label;
import util.Utility;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * The guidelines in this class apply to all TurboResources.
 */
@SuppressWarnings("unused")
public class TurboIssue {

    public static final String STATE_CLOSED = "closed";
    public static final String STATE_OPEN = "open";

    /**
     * Must have reasonable, NON-NULL defaults.
     * Should be primitive types, or at least easily-serializable ones.
     * Should be specified in order.
     * Should be immutable as much as possible.
     */
    private void ______SERIALIZED_FIELDS______() {
    }

    // Immutable
    private final int id;
    private final String creator;
    private final LocalDateTime createdAt;
    private final boolean isPullRequest;


    // Mutable
    private String title;
    private String description;
    private LocalDateTime updatedAt;
    private int commentCount;
    private boolean isOpen;
    private Optional<String> assignee;
    private List<String> labels;
    private Optional<Integer> milestone;

    /**
     * Metadata associated with issues that is not serialized.
     */
    private void ______TRANSIENT_FIELDS______() {
    }

    private final String repoId;
    private IssueMetadata metadata;
    private Optional<LocalDateTime> markedReadAt;
    private boolean isCurrentlyRead;

    private void ______CONSTRUCTORS______() {
    }

    /**
     * Default constructor: provides reasonable defaults for things.
     */
    public TurboIssue(String repoId, int id, String title) {
        this.id = id;
        this.creator = "";
        this.createdAt = LocalDateTime.now();
        this.isPullRequest = false;

        mutableFieldDefaults();

        this.title = title;
        this.repoId = repoId;
    }

    /**
     * Immutable-conscious constructor.
     */
    public TurboIssue(String repoId, int id, String title,
                      String creator, LocalDateTime createdAt, boolean isPullRequest) {
        this.id = id;
        this.creator = creator;
        this.createdAt = createdAt;
        this.isPullRequest = isPullRequest;

        mutableFieldDefaults();

        this.title = title;
        this.repoId = repoId;
    }

    // Copy constructor
    public TurboIssue(TurboIssue issue) {
        this.id = issue.id;
        this.title = issue.title;
        this.creator = issue.creator;
        this.createdAt = issue.createdAt;
        this.isPullRequest = issue.isPullRequest;

        this.description = issue.description;
        this.updatedAt = issue.updatedAt;
        this.commentCount = issue.commentCount;
        this.isOpen = issue.isOpen;
        this.assignee = issue.assignee;
        this.labels = new ArrayList<>(issue.labels);
        this.milestone = issue.milestone;

        this.metadata = new IssueMetadata(issue.metadata);
        this.repoId = issue.repoId;
        this.markedReadAt = issue.markedReadAt;
        this.isCurrentlyRead = issue.isCurrentlyRead;
    }

    public TurboIssue(String repoId, Issue issue) {
        this.id = issue.getNumber();
        this.title = issue.getTitle();
        this.creator = issue.getUser().getLogin();
        this.createdAt = Utility.dateToLocalDateTime(issue.getCreatedAt());
        this.isPullRequest = isPullRequest(issue);

        this.description = issue.getBody();
        this.updatedAt = Utility.dateToLocalDateTime(issue.getUpdatedAt());
        this.commentCount = issue.getComments();
        this.isOpen = issue.getState().equals(STATE_OPEN);
        this.assignee = issue.getAssignee() == null
            ? Optional.empty()
            : Optional.of(issue.getAssignee().getLogin());
        this.labels = issue.getLabels().stream()
            .map(Label::getName)
            .collect(Collectors.toList());
        this.milestone = issue.getMilestone() == null
            ? Optional.empty()
            : Optional.of(issue.getMilestone().getNumber());

        this.metadata = new IssueMetadata();
        this.repoId = repoId;
        this.markedReadAt = Optional.empty();
        this.isCurrentlyRead = false;<commit_msg>Added check for null Issue body from GitHub<commit_after>package backend.resource;

import backend.IssueMetadata;
import backend.resource.serialization.SerializableIssue;
import org.eclipse.egit.github.core.Issue;
import org.eclipse.egit.github.core.Label;
import util.Utility;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * The guidelines in this class apply to all TurboResources.
 */
@SuppressWarnings("unused")
public class TurboIssue {

    public static final String STATE_CLOSED = "closed";
    public static final String STATE_OPEN = "open";

    /**
     * Must have reasonable, NON-NULL defaults.
     * Should be primitive types, or at least easily-serializable ones.
     * Should be specified in order.
     * Should be immutable as much as possible.
     */
    private void ______SERIALIZED_FIELDS______() {
    }

    // Immutable
    private final int id;
    private final String creator;
    private final LocalDateTime createdAt;
    private final boolean isPullRequest;


    // Mutable
    private String title;
    private String description;
    private LocalDateTime updatedAt;
    private int commentCount;
    private boolean isOpen;
    private Optional<String> assignee;
    private List<String> labels;
    private Optional<Integer> milestone;

    /**
     * Metadata associated with issues that is not serialized.
     */
    private void ______TRANSIENT_FIELDS______() {
    }

    private final String repoId;
    private IssueMetadata metadata;
    private Optional<LocalDateTime> markedReadAt;
    private boolean isCurrentlyRead;

    private void ______CONSTRUCTORS______() {
    }

    /**
     * Default constructor: provides reasonable defaults for things.
     */
    public TurboIssue(String repoId, int id, String title) {
        this.id = id;
        this.creator = "";
        this.createdAt = LocalDateTime.now();
        this.isPullRequest = false;

        mutableFieldDefaults();

        this.title = title;
        this.repoId = repoId;
    }

    /**
     * Immutable-conscious constructor.
     */
    public TurboIssue(String repoId, int id, String title,
                      String creator, LocalDateTime createdAt, boolean isPullRequest) {
        this.id = id;
        this.creator = creator;
        this.createdAt = createdAt;
        this.isPullRequest = isPullRequest;

        mutableFieldDefaults();

        this.title = title;
        this.repoId = repoId;
    }

    // Copy constructor
    public TurboIssue(TurboIssue issue) {
        this.id = issue.id;
        this.title = issue.title;
        this.creator = issue.creator;
        this.createdAt = issue.createdAt;
        this.isPullRequest = issue.isPullRequest;

        this.description = issue.description;
        this.updatedAt = issue.updatedAt;
        this.commentCount = issue.commentCount;
        this.isOpen = issue.isOpen;
        this.assignee = issue.assignee;
        this.labels = new ArrayList<>(issue.labels);
        this.milestone = issue.milestone;

        this.metadata = new IssueMetadata(issue.metadata);
        this.repoId = issue.repoId;
        this.markedReadAt = issue.markedReadAt;
        this.isCurrentlyRead = issue.isCurrentlyRead;
    }

    public TurboIssue(String repoId, Issue issue) {
        this.id = issue.getNumber();
        this.title = issue.getTitle() == null
            ? ""
            : issue.getTitle();
        this.creator = issue.getUser().getLogin();
        this.createdAt = Utility.dateToLocalDateTime(issue.getCreatedAt());
        this.isPullRequest = isPullRequest(issue);

        this.description = issue.getBody() == null
            ? ""
            : issue.getBody();
        this.updatedAt = Utility.dateToLocalDateTime(issue.getUpdatedAt());
        this.commentCount = issue.getComments();
        this.isOpen = issue.getState().equals(STATE_OPEN);
        this.assignee = issue.getAssignee() == null
            ? Optional.empty()
            : Optional.of(issue.getAssignee().getLogin());
        this.labels = issue.getLabels().stream()
            .map(Label::getName)
            .collect(Collectors.toList());
        this.milestone = issue.getMilestone() == null
            ? Optional.empty()
            : Optional.of(issue.getMilestone().getNumber());

        this.metadata = new IssueMetadata();
        this.repoId = repoId;
        this.markedReadAt = Optional.empty();
        this.isCurrentlyRead = false;
{'fraction_non_alphanumeric': 0.09844152931943043, 'fraction_numerical': 0.0, 'mean_word_length': 2.5880933226065967, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4034535', 'n_tokens_mistral': 2519, 'n_tokens_neox': 2402, 'n_words': 578}