Class Product

  • All Implemented Interfaces:
    Serializable

    @Entity
    public class Product
    extends InventoryRepresentation
    This class represents a specific product. It has been mapped to both the DB, XML, and JSON -- which is not that common to do and causes some conflict. JAX-RS originally only had to support JAXB (i.e., @Xml annotations) and each vendor added optional extensions to support alternate formats like JSON. One common approach was to apply the Xml-centric JAXB bindings to JSON marshaling. That is what was done by the Jackson JSON marshaler. Jackson also had annotations (@Json) that could override JAXB (@Xml) annotations. That is how things sat for < jee8. With jee8 and jax-rs 2.1, JSON-B was created and support mandated. This example was written before full jee8 compliance. Thus it has been annotated with JSOB-B annotations (@Jsonb) and Jackson (@Json) annotations so that it will work with both jee7 and jee8 deployments. The client will always be using JSON-B. The use of JAXB annotations for Json does confuse the marshaling decision logic. So we have to make sure we have JSON-B annotations on the class, and passed to the marshaling methods. Of course -- if your marshaled class is a true DTO, then there is much less need for overrides.
    See Also:
    Serialized Form
    • Constructor Detail

      • Product

        public Product()
      • Product

        public Product​(String name)
    • Method Detail

      • getId

        public int getId()
      • setId

        public void setId​(int id)
      • getName

        public String getName()
      • setName

        public void setName​(String name)
      • getQuantity

        public Integer getQuantity()
      • setQuantity

        public void setQuantity​(Integer quantity)
      • getPrice

        public Double getPrice()
      • setPrice

        public void setPrice​(Double price)
      • getProtectedValue

        public String getProtectedValue()
      • setProtectedValue

        public void setProtectedValue​(String protectedValue)
      • withProtectedValue

        public Product withProtectedValue​(String string)