<commit_before>package com.turlir.abakgists.model;

import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;

import com.turlir.abakgists.allgists.view.TypesFactory;
import com.turlir.abakgists.allgists.view.ViewModel;

public class GistModel
        extends ViewModel
        implements Parcelable {

    public final String id;

    public final String url;

    public final String created;

    @NonNull
    public final String description;

    public final String ownerLogin;

    public final String ownerAvatarUrl;

    @NonNull
    public final String note;

    public final boolean isLocal;

    public static final Parcelable.Creator<GistModel> CREATOR = new Parcelable.Creator<GistModel>() {
        @Override
        public GistModel createFromParcel(Parcel in) {
            return new GistModel(in);
        }

        @Override
        public GistModel[] newArray(int size) {
            return new GistModel[size];
        }
    };

    public GistModel(String id, String url, String created, @NonNull String description,
                     String ownerLogin, String ownerAvatarUrl, @NonNull String note, boolean isLocal) {
        this.id = id;
        this.url = url;
        this.created = created;
        this.description = description;
        this.ownerLogin = ownerLogin;
        this.ownerAvatarUrl = ownerAvatarUrl;
        this.note = note;
        this.isLocal = isLocal;
    }

    public GistModel(GistModel other, @NonNull String desc, @NonNull String note) {
        id = other.id;
        url = other.url;
        created = other.created;
        ownerLogin = other.ownerLogin;
        ownerAvatarUrl = other.ownerAvatarUrl;
        isLocal = other.isLocal;

        this.description = desc;
        this.note = note;
    }

    private GistModel(Parcel in) {
        url = in.readString();
        id = in.readString();
        description = in.readString();
        created = in.readString();
        note = in.readString();
        ownerLogin = in.readString();
        ownerAvatarUrl = in.readString();
        isLocal = in.readInt() == 1;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(url);
        dest.writeString(id);
        dest.writeString(description);
        dest.writeString(created);
        dest.writeString(note);
        dest.writeString(ownerLogin);
        dest.writeString(ownerAvatarUrl);
        dest.writeInt(isLocal ? 1 : 0);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public int type(TypesFactory factory) {
        return factory.type(this);
    }

    /**
     * различны ли элементы с точки зрения базы данных
     * @param other сравниваемый элемент
     * @return {@code true} - различны, иначе {@code false}
     */
    public boolean isDifferent(GistModel other) {
        return !other.id.equals(this.id);
    }

    public Uri insteadWebLink() {
        return Uri.parse(String.format("http://gist.github.com/%s/%s", ownerLogin, id));
    }

    @Override
    public String toString() {
        return "GistModel{" +
                "id='" + id + '\'' +
                ", description='" + description + '\'' +
                '}';
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 167 * result + url.hashCode();
        result = 167 * result + created.hashCode();
        result = 167 * result + description.hashCode();
        result = 167 * result + (ownerLogin != null ? ownerLogin.hashCode() : 0);
        result = 167 * result + (ownerAvatarUrl != null ? ownerAvatarUrl.hashCode() : 0);
        result = 167 * result + note.hashCode();
        return result;<commit_msg>improve GistModel<commit_after>package com.turlir.abakgists.model;

import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.turlir.abakgists.allgists.view.TypesFactory;
import com.turlir.abakgists.allgists.view.ViewModel;

public class GistModel
        extends ViewModel
        implements Parcelable {

    public final String id;

    public final String url;

    public final String created;

    @NonNull
    public final String description;

    @Nullable
    public final String ownerLogin;

    @Nullable
    public final String ownerAvatarUrl;

    @NonNull
    public final String note;

    public final boolean isLocal;

    public static final Parcelable.Creator<GistModel> CREATOR = new Parcelable.Creator<GistModel>() {
        @Override
        public GistModel createFromParcel(Parcel in) {
            return new GistModel(in);
        }

        @Override
        public GistModel[] newArray(int size) {
            return new GistModel[size];
        }
    };

    public GistModel(String id, String url, String created, @NonNull String description,
                     @Nullable String ownerLogin, @Nullable String ownerAvatarUrl, @NonNull String note, boolean isLocal) {
        this.id = id;
        this.url = url;
        this.created = created;
        this.description = description;
        this.ownerLogin = ownerLogin;
        this.ownerAvatarUrl = ownerAvatarUrl;
        this.note = note;
        this.isLocal = isLocal;
    }

    public GistModel(GistModel other, @NonNull String desc, @NonNull String note) {
        id = other.id;
        url = other.url;
        created = other.created;
        ownerLogin = other.ownerLogin;
        ownerAvatarUrl = other.ownerAvatarUrl;
        isLocal = other.isLocal;

        this.description = desc;
        this.note = note;
    }

    private GistModel(Parcel in) {
        url = in.readString();
        id = in.readString();
        description = in.readString();
        created = in.readString();
        note = in.readString();
        ownerLogin = in.readString();
        ownerAvatarUrl = in.readString();
        isLocal = in.readInt() == 1;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(url);
        dest.writeString(id);
        dest.writeString(description);
        dest.writeString(created);
        dest.writeString(note);
        dest.writeString(ownerLogin);
        dest.writeString(ownerAvatarUrl);
        dest.writeInt(isLocal ? 1 : 0);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public int type(TypesFactory factory) {
        return factory.type(this);
    }

    /**
     * различны ли элементы с точки зрения базы данных
     * @param other сравниваемый элемент
     * @return {@code true} - различны, иначе {@code false}
     */
    public boolean isDifferent(GistModel other) {
        return !other.id.equals(this.id);
    }

    /**
     * формирует ссылку на github.com
     * @return ссылка на этот гист
     */
    public Uri insteadWebLink() {
        if (ownerLogin != null) {
            return Uri.parse(String.format("http://gist.github.com/%s/%s", ownerLogin, id));
        } else {
            return Uri.parse(String.format("http://gist.github.com/%s", id));
        }
    }

    @Override
    public String toString() {
        return "GistModel{" +
               "id='" + id + '\'' +
               ", description='" + description + '\'' +
               ", note='" + note + '\'' +
               ", isLocal=" + isLocal +
               '}';
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 167 * result + url.hashCode();
        result = 167 * result + created.hashCode();
        result = 167 * result + description.hashCode();
        result = 167 * result + (ownerLogin != null ? ownerLogin.hashCode() : 0);
        result = 167 * result + (ownerAvatarUrl != null ? ownerAvatarUrl.hashCode() : 0);
        result = 167 * result + note.hashCode();
        return result;
{'fraction_non_alphanumeric': 0.10694113217020208, 'fraction_numerical': 0.006024852516631103, 'mean_word_length': 2.2403416022773484, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3225203', 'n_tokens_mistral': 2380, 'n_tokens_neox': 2307, 'n_words': 564}