OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 17 | Rev 182 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17 Rev 177
Line 11... Line 11...
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.utils;
14
 package org.openconcerto.utils;
15
 
15
 
-
 
16
import java.util.ArrayList;
16
import java.util.Arrays;
17
import java.util.Arrays;
17
import java.util.Collections;
18
import java.util.Collections;
18
import java.util.List;
19
import java.util.List;
19
import java.util.regex.Pattern;
20
import java.util.regex.Pattern;
20
 
21
 
Line 96... Line 97...
96
                System.setProperty(this.name, newVal);
97
                System.setProperty(this.name, newVal);
97
                return true;
98
                return true;
98
            } else
99
            } else
99
                return false;
100
                return false;
100
        }
101
        }
-
 
102
 
-
 
103
        public final boolean remove(final String value) {
-
 
104
            return this.remove(value, true);
-
 
105
        }
-
 
106
 
-
 
107
        public final boolean remove(final String value, final boolean unsetIfEmpty) {
-
 
108
            if (value == null)
-
 
109
                throw new NullPointerException("Null value");
-
 
110
            final List<String> l = getValues();
-
 
111
            if (l == null || l.size() == 0 || !l.contains(value))
-
 
112
                return false;
-
 
113
 
-
 
114
            final List<String> newList = new ArrayList<>(l.size() - 1);
-
 
115
            for (final String item : l) {
-
 
116
                if (!item.equals(value))
-
 
117
                    newList.add(item);
-
 
118
            }
-
 
119
            if (unsetIfEmpty && newList.isEmpty())
-
 
120
                System.clearProperty(this.name);
-
 
121
            else
-
 
122
                System.setProperty(this.name, CollectionUtils.join(newList, this.getSeparator()));
-
 
123
            return true;
-
 
124
        }
101
    }
125
    }
102
}
126
}