select and deselect parameters as output to JSON ,depending up on the incoming request in java
<p>For example I have an incoming request with URL: "/cid/{cid}/{action}" </p>

<p>For path variable {action} I can have two values i.e.  {action}: <strong>1)list  2)tile</strong></p>

<p>My POJO class with parameters for JSON output is below:</p>

<pre class="lang-java prettyprint-override"><code>public class Area {

    private Integer aId;
    private String aName;
    private Integer allSpaces;
    private Integer violated;
    private Integer percent;
    private Integer level;
    private List&lt;Space&gt; space = new ArrayList&lt;Space&gt;(); // this List should be depend on condition

    public Area(Integer aId, String aName, Integer allSpaces, Integer violated, Integer percent, Integer level) {
        this.aId = aId;
        this.aName = aName;
        this.allSpaces = allSpaces;
        this.level = level;
        this.violated = violated;
        this.percent = percent;
    }

    public Integer getaId() {
        return aId;
    }

    public void setaId(Integer aId) {
        this.aId = aId;
    }

    public String getaName() {
        return aName;
    }

    public void setaName(String aName) {
        this.aName = aName;
    }

    public Area addSpace(Space s) {
        space.add(s);

        return this;
    }

    public List&lt;Space&gt; getSpace() {
        return space;
    }

    public void setSpace(List&lt;Space&gt; space) {
        this.space = space;
    }

    public Integer getAllSpaces() {
        return allSpaces;
    }

    public void setAllSpaces(Integer allSpaces) {
        this.allSpaces = allSpaces;
    }

    public Integer getViolated() {
        return violated;
    }

    public void setViolated(Integer violated) {
        this.violated = violated;
    }

    public Integer getPercent() {
        return percent;
    }

    public void setPercent(Integer percent) {
        this.percent = percent;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }
}
</code></pre>

<p>My output should not consist the parameter <code>private List space = new ArrayList()</code> for <em>action =list</em> but show it for <em>action=tile</em>.</p>

<p>It will of great help if any body can help me with this.</p>
