/*
 * Copyright (C) 2013 tarent AG
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package org.osiam.resources.scim;

import java.util.HashSet;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;


/**
 * Java class for Group complex type.
 */
@JsonInclude(Include.NON_EMPTY)
public class Group extends CoreResource{

    private String displayName;
    private Set<MemberRef> members;

    //JSON Serializing
    public Group(){}


    public Group(Builder builder) {
        super(builder);
        this.displayName = builder.displayName;
        this.members = builder.members;
    }

    public static class Builder extends CoreResource.Builder{

        private String displayName;
        private Set<MemberRef> members = new HashSet<>();

        public Builder(){}

        public Builder(Group group) {
            id = group.getId();
            meta = group.getMeta();
            externalId = group.getExternalId();
            displayName = group.displayName;
            members = group.members;
        }

        public Builder setDisplayName(String displayName) {
            this.displayName = displayName;
            return this;
        }

        public Builder setId(String id) {
            super.id = id;
            return this;
        }
        
        public Builder setMeta(Meta meta) {
            super.meta = meta;
            return this;
        }
        
        public Builder setExternalId(String externalId) {
            super.externalId = externalId;
            return this;
        }
        
        public Builder setMembers(Set<MemberRef> members) {
            this.members = members;
            return this;
        }

        public Group build(){
            return new Group(this);
        }
    }

    /**
     * Gets the value of the displayName property.
     *
     * @return
     *     possible object is
     *     {@link String }
     *
     */
    public String getDisplayName() {
        return displayName;
    }

    public Set<MemberRef> getMembers() {
        return members;
    }

}

@@ -1150,57 +1150,8 @@
 m;%0A%0A
-import java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 impo
@@ -1261,16 +1261,65 @@
 clude;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 %0A/**%0A * 
@@ -1428,16 +1428,17 @@
 Resource
+ 
 %7B%0A%0A    p
@@ -1498,16 +1498,34 @@
  members
+ = new HashSet%3C%3E()
 ;%0A%0A    /
@@ -1560,17 +1560,23 @@
  Group()
-%7B
+ %7B%0A    
 %7D%0A%0A%0A    
@@ -1718,32 +1718,315 @@
 members;%0A    %7D%0A%0A
+    /**%0A     * Gets the value of the displayName property.%0A     *%0A     * @return possible object is%0A     *         %7B@link String %7D%0A     */%0A    public String getDisplayName() %7B%0A        return displayName;%0A    %7D%0A%0A    public Set%3CMemberRef%3E getMembers() %7B%0A        return members;%0A    %7D%0A%0A
     public stati
@@ -2069,16 +2069,17 @@
 .Builder
+ 
 %7B%0A%0A     
@@ -2192,17 +2192,27 @@
 uilder()
-%7B
+ %7B%0A        
 %7D%0A%0A     
@@ -2693,32 +2693,24 @@
 ;%0A        %7D%0A
-        
 %0A        pub
@@ -2804,32 +2804,24 @@
 ;%0A        %7D%0A
-        
 %0A        pub
@@ -2945,24 +2945,16 @@
       %7D%0A
-        
 %0A       
@@ -3106,16 +3106,17 @@
  build()
+ 
 %7B%0A      
@@ -3165,304 +3165,6 @@
   %7D%0A
-%0A    /**%0A     * Gets the value of the displayName property.%0A     *%0A     * @return%0A     *     possible object is%0A     *     %7B@link String %7D%0A     *%0A     */%0A    public String getDisplayName() %7B%0A        return displayName;%0A    %7D%0A%0A    public Set%3CMemberRef%3E getMembers() %7B%0A        return members;%0A    %7D%0A%0A
 %7D%0A

Make sure, members are always initialized with empty collection