Initial opendaylight infrastructure commit!!
[controller.git] / third-party / net.sf.jung2 / src / main / java / edu / uci / ics / jung / algorithms / util / MapSettableTransformer.java
1 /*
2  * Created on Aug 5, 2007
3  *
4  * Copyright (c) 2007, the JUNG Project and the Regents of the University 
5  * of California
6  * All rights reserved.
7  *
8  * This software is open-source under the BSD license; see either
9  * "license.txt" or
10  * http://jung.sourceforge.net/license.txt for a description.
11  */
12 package edu.uci.ics.jung.algorithms.util;
13
14 import java.util.Map;
15
16
17 /**
18  * A <code>SettableTransformer</code> that operates on an underlying <code>Map</code> instance.
19  * Similar to <code>MapTransformer</code>.
20  * 
21  * @author Joshua O'Madadhain
22  */
23 public class MapSettableTransformer<I, O> implements SettableTransformer<I, O>
24 {
25     protected Map<I,O> map;
26     
27     /**
28      * Creates an instance based on <code>m</code>.
29      */
30     public MapSettableTransformer(Map<I,O> m)
31     {
32         this.map = m;
33     }
34
35     public O transform(I input)
36     {
37         return map.get(input);
38     }
39
40     public void set(I input, O output)
41     {
42         map.put(input, output);
43     }
44 }