OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 177 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 177 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
Line 15... Line 15...
15
 
15
 
16
import java.util.ArrayList;
16
import java.util.ArrayList;
17
import java.util.Arrays;
17
import java.util.Arrays;
18
import java.util.Collections;
18
import java.util.Collections;
19
import java.util.List;
19
import java.util.List;
-
 
20
import java.util.function.Function;
20
import java.util.regex.Pattern;
21
import java.util.regex.Pattern;
21
 
22
 
22
public class SystemUtils {
23
public class SystemUtils {
23
 
24
 
24
    /**
25
    /**
Line 121... Line 122...
121
            else
122
            else
122
                System.setProperty(this.name, CollectionUtils.join(newList, this.getSeparator()));
123
                System.setProperty(this.name, CollectionUtils.join(newList, this.getSeparator()));
123
            return true;
124
            return true;
124
        }
125
        }
125
    }
126
    }
-
 
127
 
-
 
128
    static public final <T extends Enum<T>> T getEnumFromProperty(final String propName, final Class<T> clazz, final T def) {
-
 
129
        final String prop = System.getProperty(propName);
-
 
130
        if (prop == null)
-
 
131
            return def;
-
 
132
        return Enum.valueOf(clazz, propName);
-
 
133
    }
-
 
134
 
-
 
135
    static public final <T> T getProperty(final String propName, final Function<String, T> func, final T def) {
-
 
136
        final String prop = System.getProperty(propName);
-
 
137
        if (prop == null)
-
 
138
            return def;
-
 
139
        return func.apply(prop);
-
 
140
    }
126
}
141
}