OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 67 Rev 132
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.cc;
14
 package org.openconcerto.utils.cc;
15
 
15
 
-
 
16
import java.util.Map;
-
 
17
 
16
public abstract class Transformer<E, T> implements ITransformer<E, T>, IClosure<E>, org.apache.commons.collections.Transformer {
18
public abstract class Transformer<E, T> implements ITransformer<E, T>, IClosure<E>, org.apache.commons.collections.Transformer {
17
 
19
 
18
    private static final ITransformer<Object, Object> nopTransf = new ITransformer<Object, Object>() {
20
    private static final ITransformer<Object, Object> nopTransf = new ITransformer<Object, Object>() {
19
        @Override
21
        @Override
20
        public Object transformChecked(Object input) {
22
        public Object transformChecked(Object input) {
Line 25... Line 27...
25
    @SuppressWarnings("unchecked")
27
    @SuppressWarnings("unchecked")
26
    public static final <N> ITransformer<N, N> nopTransformer() {
28
    public static final <N> ITransformer<N, N> nopTransformer() {
27
        return (ITransformer<N, N>) nopTransf;
29
        return (ITransformer<N, N>) nopTransf;
28
    }
30
    }
29
 
31
 
-
 
32
    public static final <K, V> ITransformer<K, V> fromMap(final Map<K, V> map) {
-
 
33
        return new Transformer<K, V>() {
-
 
34
            @Override
-
 
35
            public V transformChecked(K input) {
-
 
36
                return map.get(input);
-
 
37
            }
-
 
38
        };
-
 
39
    }
-
 
40
 
30
    @SuppressWarnings("unchecked")
41
    @SuppressWarnings("unchecked")
31
    public final Object transform(Object input) {
42
    public final Object transform(Object input) {
32
        return this.transformChecked((E) input);
43
        return this.transformChecked((E) input);
33
    }
44
    }
34
 
45