<commit_before>package com.charlesmadere.hummingbird.models;

import android.content.res.Resources;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.WorkerThread;

import com.charlesmadere.hummingbird.misc.ParcelableUtils;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.annotations.SerializedName;

public abstract class AbsNotification implements Parcelable {

    @SerializedName("source")
    private AbsSource mSource;

    @SerializedName("seen")
    private boolean mSeen;

    @SerializedName("created_at")
    private SimpleDate mCreatedAt;

    @SerializedName("id")
    private String mId;


    @Override
    public boolean equals(final Object o) {
        return o instanceof AbsNotification && mId.equalsIgnoreCase(((AbsNotification) o).getId());
    }

    public SimpleDate getCreatedAt() {
        return mCreatedAt;
    }

    public String getId() {
        return mId;
    }

    public AbsSource getSource() {
        return mSource;
    }

    public abstract CharSequence getText(final Resources res);

    public abstract Type getType();

    public User getUser() {
        return mSource.getUser();
    }

    @Override
    public int hashCode() {
        return mId.hashCode();
    }

    @WorkerThread
    public void hydrate(final Feed feed) {
        mSource.hydrate(feed);
    }

    public boolean isSeen() {
        return mSeen;
    }

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

    protected void readFromParcel(final Parcel source) {
        mSource = ParcelableUtils.readAbsNotificationAbsSource(source);
        mSeen = source.readInt() != 0;
        mCreatedAt = source.readParcelable(SimpleDate.class.getClassLoader());
        mId = source.readString();
    }

    @Override
    public void writeToParcel(final Parcel dest, final int flags) {
        ParcelableUtils.writeAbsNotificationAbsSource(mSource, dest, flags);
        dest.writeInt(mSeen ? 1 : 0);
        dest.writeParcelable(mCreatedAt, flags);
        dest.writeString(mId);
    }


    public static abstract class AbsSource implements Parcelable {
        @SerializedName("id")
        private String mId;

        public String getId() {
            return mId;
        }

        public abstract Type getType();

        public abstract User getUser();

        @WorkerThread
        public abstract void hydrate(final Feed feed);

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

        protected void readFromParcel(final Parcel source) {
            mId = source.readString();
        }

        @Override
        public void writeToParcel(final Parcel dest, final int flags) {
            dest.writeString(mId);
        }

        public enum Type implements Parcelable {
            @SerializedName("story")
            STORY,

            @SerializedName("substory")
            SUBSTORY;

            public static Type from(final String type) {
                switch (type) {
                    case "story":
                        return STORY;

                    case "substory":
                        return SUBSTORY;

                    default:
                        throw new IllegalArgumentException("encountered unknown " +
                                Type.class.getName() + ": \"" + type + '"');
                }
            }

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

            @Override
            public void writeToParcel(final Parcel dest, final int flags) {
                dest.writeInt(ordinal());
            }

            public static final Creator<Type> CREATOR = new Creator<Type>() {
                @Override
                public Type createFromParcel(final Parcel source) {
                    final int ordinal = source.readInt();
                    return values()[ordinal];
                }

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

        public static final JsonDeserializer<AbsSource> JSON_DESERIALIZER = new JsonDeserializer<AbsSource>() {
            @Override
            public AbsSource deserialize(final JsonElement json,
                    final java.lang.reflect.Type typeOfT, final JsonDeserializationContext context)
                    throws JsonParseException {<commit_msg>tiny cleanup<commit_after>package com.charlesmadere.hummingbird.models;

import android.content.res.Resources;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.WorkerThread;

import com.charlesmadere.hummingbird.misc.ParcelableUtils;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.annotations.SerializedName;

public abstract class AbsNotification implements Parcelable {

    @SerializedName("source")
    private AbsSource mSource;

    @SerializedName("seen")
    private boolean mSeen;

    @SerializedName("created_at")
    private SimpleDate mCreatedAt;

    @SerializedName("id")
    private String mId;


    @Override
    public boolean equals(final Object o) {
        return o instanceof AbsNotification && mId.equalsIgnoreCase(((AbsNotification) o).getId());
    }

    public SimpleDate getCreatedAt() {
        return mCreatedAt;
    }

    public String getId() {
        return mId;
    }

    public AbsSource getSource() {
        return mSource;
    }

    public abstract CharSequence getText(final Resources res);

    public abstract Type getType();

    public User getUser() {
        return mSource.getUser();
    }

    @Override
    public int hashCode() {
        return mId.hashCode();
    }

    @WorkerThread
    public void hydrate(final Feed feed) {
        mSource.hydrate(feed);
    }

    public boolean isSeen() {
        return mSeen;
    }

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

    protected void readFromParcel(final Parcel source) {
        mSource = ParcelableUtils.readAbsNotificationAbsSource(source);
        mSeen = source.readInt() != 0;
        mCreatedAt = source.readParcelable(SimpleDate.class.getClassLoader());
        mId = source.readString();
    }

    @Override
    public void writeToParcel(final Parcel dest, final int flags) {
        ParcelableUtils.writeAbsNotificationAbsSource(mSource, dest, flags);
        dest.writeInt(mSeen ? 1 : 0);
        dest.writeParcelable(mCreatedAt, flags);
        dest.writeString(mId);
    }


    public static abstract class AbsSource implements Parcelable {
        @SerializedName("id")
        private String mId;

        public String getId() {
            return mId;
        }

        public abstract Type getType();

        public abstract User getUser();

        @WorkerThread
        public abstract void hydrate(final Feed feed);

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

        protected void readFromParcel(final Parcel source) {
            mId = source.readString();
        }

        @Override
        public void writeToParcel(final Parcel dest, final int flags) {
            dest.writeString(mId);
        }

        public enum Type implements Parcelable {
            @SerializedName("story")
            STORY,

            @SerializedName("substory")
            SUBSTORY;

            public static Type from(final String type) {
                switch (type) {
                    case "story":
                        return STORY;

                    case "substory":
                        return SUBSTORY;

                    default:
                        throw new IllegalArgumentException("encountered unknown " +
                                Type.class.getName() + ": \"" + type + '"');
                }
            }

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

            @Override
            public void writeToParcel(final Parcel dest, final int flags) {
                dest.writeInt(ordinal());
            }

            public static final Creator<Type> CREATOR = new Creator<Type>() {
                @Override
                public Type createFromParcel(final Parcel source) {
                    return values()[source.readInt()];
                }

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

        public static final JsonDeserializer<AbsSource> JSON_DESERIALIZER = new JsonDeserializer<AbsSource>() {
            @Override
            public AbsSource deserialize(final JsonElement json,
                    final java.lang.reflect.Type typeOfT, final JsonDeserializationContext context)
                    throws JsonParseException {
{'fraction_non_alphanumeric': 0.08151351351351352, 'fraction_numerical': 0.0012972972972972972, 'mean_word_length': 1.9698234349919743, 'pattern_counts': {'":': 6, '<': 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': '6038294', 'n_tokens_mistral': 2458, 'n_tokens_neox': 2311, 'n_words': 587}