Initial opendaylight infrastructure commit!!
[controller.git] / third-party / net.sf.jung2 / src / main / java / edu / uci / ics / jung / algorithms / scoring / util / DelegateToEdgeTransformer.java
1 /*
2  * Created on Jul 11, 2008
3  *
4  * Copyright (c) 2008, 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.scoring.util;
13
14 import org.apache.commons.collections15.Transformer;
15
16 /**
17  * A <code>Transformer<VEPair,Number></code> that delegates its operation to a
18  * <code>Transformer<E,Number></code>.  Mainly useful for technical reasons inside 
19  * AbstractIterativeScorer; in essence it allows the edge weight instance 
20  * variable to be of type <code>VEPair,W</code> even if the edge weight 
21  * <code>Transformer</code> only operates on edges.
22  */
23 public class DelegateToEdgeTransformer<V,E> implements
24         Transformer<VEPair<V,E>,Number>
25 {
26         /**
27          * The transformer to which this instance delegates its function.
28          */
29     protected Transformer<E,? extends Number> delegate;
30     
31     /**
32      * Creates an instance with the specified delegate transformer.
33      * @param delegate the Transformer to which this instance will delegate
34      */
35     public DelegateToEdgeTransformer(Transformer<E,? extends Number> delegate)
36     {
37         this.delegate = delegate;
38     }
39     
40     /**
41      * @see Transformer#transform(Object)
42      */
43     public Number transform(VEPair<V,E> arg0)
44     {
45         return delegate.transform(arg0.getE());
46     }
47
48 }