com.tigerpenguin.places.model.Review.java Source code

Java tutorial

Introduction

Here is the source code for com.tigerpenguin.places.model.Review.java

Source

/*
 * Copyright (C) 2014 Brian Lee
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.tigerpenguin.places.model;

import android.os.Parcel;
import android.os.Parcelable;
import com.tigerpenguin.places.deserializer.HtmlStringDeserializer;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

import java.util.List;

public class Review extends JsonModel implements Parcelable {

    @JsonProperty(ASPECTS)
    private List<AspectRating> aspectRatings;

    @JsonProperty(AUTHOR_NAME)
    private String authorName;

    @JsonProperty(AUTHOR_URL)
    private String authorUrl;

    @JsonProperty(LANGUAGE)
    private Language language;

    @JsonProperty(RATING)
    private int rating;

    @JsonProperty(TEXT)
    @JsonDeserialize(using = HtmlStringDeserializer.class)
    private String text;

    @JsonProperty(TIME)
    private long submitTime;

    public Review() {
        // required for Jackson
    }

    @SuppressWarnings("unchecked")
    public Review(Parcel in) {
        aspectRatings = in.readArrayList(AspectRating.class.getClassLoader());
        authorName = in.readString();
        authorUrl = in.readString();
        language = (Language) in.readSerializable();
        rating = in.readInt();
        text = in.readString();
        submitTime = in.readLong();
    }

    public String getAuthorName() {
        return authorName;
    }

    public int getRating() {
        return rating;
    }

    public String getText() {
        return text;
    }

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

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeList(aspectRatings);
        dest.writeString(authorName);
        dest.writeString(authorUrl);
        dest.writeSerializable(language);
        dest.writeInt(rating);
        dest.writeString(text);
        dest.writeLong(submitTime);
    }

    public static final Creator<Review> CREATOR = new Creator<Review>() {
        @Override
        public Review createFromParcel(Parcel source) {
            return new Review(source);
        }

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