/*
 * Copyright 2015 52°North Initiative for Geospatial Open Source
 * Software GmbH
 *
 * 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 org.n52.iceland.ogc.ows;

import java.util.Collection;
import java.util.Collections;
import java.util.SortedSet;
import java.util.TreeSet;

import org.n52.iceland.util.CollectionHelper;

/**
 * @since 1.0.0
 * 
 */
public class OwsParameterValuePossibleValues implements OwsParameterValue {

    private SortedSet<String> values;

    public OwsParameterValuePossibleValues(Collection<String> values) {
        this.values = values == null ? new TreeSet<String>() : new TreeSet<String>(values);
    }

    public OwsParameterValuePossibleValues(String value) {
        this(Collections.singleton(value));
    }

    public OwsParameterValuePossibleValues(Enum<?> value) {
        this(value.name());
    }
    
    public OwsParameterValuePossibleValues() {
    }

    public SortedSet<String> getValues() {
        return Collections.unmodifiableSortedSet(values);
    }
    
    public void addValue(String value) {
    	addValues(Collections.singleton(value));
    }
    
    public void addValue(Enum<?> value) {
    	addValues(Collections.singleton(value.name()));
    }
    
    public void addValues(Collection<String> values) {
    	if (isSetValues()) {
    		if (values != null) {
                this.values.addAll(values);
            }
    	} else { 
    		this.values = values == null ? new TreeSet<String>() : new TreeSet<String>(values);
    	}
    }

    public void setValues(Collection<String> values) {
        this.values.clear();
        if (values != null) {
            this.values.addAll(values);
        }
    }
    
    public boolean isSetValues() {
    	return CollectionHelper.isNotEmpty(getValues());
    }

}

@@ -834,16 +834,56 @@
 elper;%0A%0A
+import com.google.common.collect.Sets;%0A%0A
 /**%0A * @
@@ -1015,16 +1015,36 @@
 %3E values
+ = Sets.newTreeSet()
 ;%0A%0A    p
@@ -1122,82 +1122,17 @@
     
-this.values = values == null ? new TreeSet%3CString%3E() : new TreeSet%3CString%3E
+setValues
 (val
@@ -1340,36 +1340,32 @@
 .name());%0A    %7D%0A
-    
 %0A    public OwsP
@@ -1392,24 +1392,61 @@
 eValues() %7B%0A
+        this(new TreeSet%3CString%3E());%0A
     %7D%0A%0A    p
@@ -1539,36 +1539,32 @@
 (values);%0A    %7D%0A
-    
 %0A    public void
@@ -1585,33 +1585,36 @@
 ng value) %7B%0A    
-%09
+    
 addValues(Collec
@@ -1636,36 +1636,32 @@
 (value));%0A    %7D%0A
-    
 %0A    public void
@@ -1691,17 +1691,20 @@
 ) %7B%0A    
-%09
+    
 addValue
@@ -1745,28 +1745,24 @@
 ()));%0A    %7D%0A
-    
 %0A    public 
@@ -1809,17 +1809,20 @@
 ) %7B%0A    
-%09
+    
 if (isSe
@@ -1838,18 +1838,24 @@
 ) %7B%0A    
-%09%09
+        
 if (valu
@@ -1934,17 +1934,20 @@
     
-%09
+    
 %7D else %7B
  %0A  
@@ -1946,16 +1946,21 @@
 se %7B
- 
 %0A
+        
     
-%09%09
 this
@@ -2043,17 +2043,20 @@
 s);%0A    
-%09
+    
 %7D%0A    %7D%0A
@@ -2226,20 +2226,16 @@
 %7D%0A    %7D%0A
-    
 %0A    pub
@@ -2270,9 +2270,12 @@
     
-%09
+    
 retu

Refactor initialization of class variable and formatting