package com.amazonaws.a2s.model;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;


/**
 <p>Java class for anonymous complex type.
 
 <p>The following schema fragment specifies the expected content contained within this class.
 
 <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="AverageRating" type="{http://www.w3.org/2001/XMLSchema}decimal" minOccurs="0"/>
 *         &lt;element name="TotalReviews" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" minOccurs="0"/>
 *         &lt;element name="TotalReviewPages" type="{http://www.w3.org/2001/XMLSchema}nonNegativeInteger" minOccurs="0"/>
 *         &lt;element ref="{http://webservices.amazon.com/AWSECommerceService/2007-10-29}Review" maxOccurs="unbounded" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 </pre>
 * Generated by AWS Code Generator
 <p/>
 * Thu Jan 10 05:27:59 PST 2008
 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "averageRating",
    "totalReviews",
    "totalReviewPages",
    "review"
})
@XmlRootElement(name = "CustomerReviews")
public class CustomerReviews {

    @XmlElement(name = "AverageRating")
    protected BigDecimal averageRating;
    @XmlElement(name = "TotalReviews")
    @XmlSchemaType(name = "nonNegativeInteger")
    protected BigInteger totalReviews;
    @XmlElement(name = "TotalReviewPages")
    @XmlSchemaType(name = "nonNegativeInteger")
    protected BigInteger totalReviewPages;
    @XmlElement(name = "Review")
    protected List<Review> review;

    /**
     * Gets the value of the averageRating property.
     
     @return
     *     possible object is
     *     {@link BigDecimal }
     *     
     */
    public BigDecimal getAverageRating() {
        return averageRating;
    }

    /**
     * Sets the value of the averageRating property.
     
     @param value
     *     allowed object is
     *     {@link BigDecimal }
     *     
     */
    public void setAverageRating(BigDecimal value) {
        this.averageRating = value;
    }

    public boolean isSetAverageRating() {
        return (this.averageRating!= null);
    }

    /**
     * Gets the value of the totalReviews property.
     
     @return
     *     possible object is
     *     {@link BigInteger }
     *     
     */
    public BigInteger getTotalReviews() {
        return totalReviews;
    }

    /**
     * Sets the value of the totalReviews property.
     
     @param value
     *     allowed object is
     *     {@link BigInteger }
     *     
     */
    public void setTotalReviews(BigInteger value) {
        this.totalReviews = value;
    }

    public boolean isSetTotalReviews() {
        return (this.totalReviews!= null);
    }

    /**
     * Gets the value of the totalReviewPages property.
     
     @return
     *     possible object is
     *     {@link BigInteger }
     *     
     */
    public BigInteger getTotalReviewPages() {
        return totalReviewPages;
    }

    /**
     * Sets the value of the totalReviewPages property.
     
     @param value
     *     allowed object is
     *     {@link BigInteger }
     *     
     */
    public void setTotalReviewPages(BigInteger value) {
        this.totalReviewPages = value;
    }

    public boolean isSetTotalReviewPages() {
        return (this.totalReviewPages!= null);
    }

    /**
     * Gets the value of the review property.
     
     <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the review property.
     
     <p>
     * For example, to add a new item, do as follows:
     <pre>
     *    getReview().add(newItem);
     </pre>
     
     
     <p>
     * Objects of the following type(s) are allowed in the list
     {@link Review }
     
     
     */
    public List<Review> getReview() {
        if (review == null) {
            review = new ArrayList<Review>();
        }
        return this.review;
    }

    public boolean isSetReview() {
        return ((this.review!= null)&&(!this.review.isEmpty()));
    }

    public void unsetReview() {
        this.review = null;
    }

    /**
     * Sets the value of the AverageRating property.
     
     @param value
     @return
     *     this instance
     */
    public CustomerReviews withAverageRating(BigDecimal value) {
        setAverageRating(value);
        return this;
    }

    /**
     * Sets the value of the TotalReviews property.
     
     @param value
     @return
     *     this instance
     */
    public CustomerReviews withTotalReviews(BigInteger value) {
        setTotalReviews(value);
        return this;
    }

    /**
     * Sets the value of the TotalReviewPages property.
     
     @param value
     @return
     *     this instance
     */
    public CustomerReviews withTotalReviewPages(BigInteger value) {
        setTotalReviewPages(value);
        return this;
    }

    /**
     * Sets the value of the Review property.
     
     @param values
     @return
     *     this instance
     */
    public CustomerReviews withReview(Review... values) {
        for (Review value: values) {
            getReview().add(value);
        }
        return this;
    }

    /**
     * Sets the value of the review property.
     
     @param review
     *     allowed object is
     *     {@link Review }
     *     
     */
    public void setReview(List<Review> review) {
        this.review = review;
    }
    

    /**
     
     * XML fragment representation of this object
     
     @return XML fragment for this object. Name for outer
     * tag expected to be set by calling method. This fragment
     * returns inner properties representation only
     */
    protected String toXMLFragment() {
        StringBuffer xml = new StringBuffer();
        if (isSetAverageRating()) {
            xml.append("<AverageRating>");
            xml.append(getAverageRating() "");
            xml.append("</AverageRating>");
        }
        if (isSetTotalReviews()) {
            xml.append("<TotalReviews>");
            xml.append(getTotalReviews() "");
            xml.append("</TotalReviews>");
        }
        if (isSetTotalReviewPages()) {
            xml.append("<TotalReviewPages>");
            xml.append(getTotalReviewPages() "");
            xml.append("</TotalReviewPages>");
        }
        java.util.List<Review> reviewList = getReview();
        for (Review review : reviewList) {
            xml.append("<Review>");
            xml.append(review.toXMLFragment());
            xml.append("</Review>");
        }
        return xml.toString();
    }

    /**
     
     * Escape XML special characters
     */
    private String escapeXML(String string) {
        StringBuffer sb = new StringBuffer();
        int length = string.length();
        for (int i = 0; i < length; ++i) {
            char c = string.charAt(i);
            switch (c) {
            case '&':
                sb.append("&amp;");
                break;
            case '<':
                sb.append("&lt;");
                break;
            case '>':
                sb.append("&gt;");
                break;
            case '\'':
                sb.append("&#039;");
                break;
            case '"':
                sb.append("&quot;");
                break;
            default:
                sb.append(c);
            }
        }
        return sb.toString();
    }


}