View Javadoc

1   //----------------------------------------------------------------------
2   // 
3   // PerfectJPattern: "Design patterns are good but components are better!" 
4   // IAdapter.java Copyright (c) 2009 Giovanni Azua Garcia
5   // bravegag@hotmail.com
6   //  
7   // This program is free software; you can redistribute it and/or
8   // modify it under the terms of the GNU General Public License
9   // as published by the Free Software Foundation; either version 3
10  // of the License, or (at your option) any later version.
11  //
12  // This program is distributed in the hope that it will be useful,
13  // but WITHOUT ANY WARRANTY; without even the implied warranty of
14  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  // GNU General Public License for more details.
16  //
17  // You should have received a copy of the GNU General Public License
18  // along with this program; if not, see <http://www.gnu.org/licenses/>.
19  //
20  //----------------------------------------------------------------------
21  package org.perfectjpattern.core.api.structural.adapter;
22  
23  import org.perfectjpattern.core.api.structural.ISurrogate;
24  
25  /**
26   * <b>Adapter Design Pattern</b>: Convert the interface of a class into another 
27   * interface clients expect. Adapter lets classes work together that couldn't 
28   * otherwise because of incompatible interfaces.
29   * <br/><br/>
30   * 
31   * <b>Responsibility</b> Abstract definition of the "Adapter": 
32   * <br/>
33   * <ul>
34   * <li>adapts the interface Adaptee to the Target interface.</li> 
35   * </ul>
36   *
37   * @param <T> <code>Target</code> element type
38   * @param <A> <code>Adaptee</code> element type
39   * 
40   * @author <a href="mailto:bravegag@hotmail.com">Giovanni Azua</a>
41   * @version $Revision: 1.0 $Date: Jan 28, 2009 12:51:08 PM $
42   */
43  public 
44  interface IAdapter<T, A>
45  extends ISurrogate<T>
46  {
47      //------------------------------------------------------------------------
48      // public
49      //------------------------------------------------------------------------
50      /**
51       * Returns the <code>Target</code> instance
52       * 
53       * @return <code>Target</code> instance
54       */
55      public T
56      getTarget();    
57  
58      //------------------------------------------------------------------------
59      /**
60       * Returns the <code>Adaptee</code> instance
61       * 
62       * @return <code>Adaptee</code> instance
63       */
64      public A
65      getAdaptee();
66      
67      //------------------------------------------------------------------------
68      /**
69       * Sets the adapting strategy e.g. exact, name, user-defined
70       * 
71       * @param anAdaptingStrategy {@link IAdaptingStrategy} instance to assign
72       * @throws IllegalArgumentException 'anAdaptingStrategy' must not be null
73       */
74      public void
75      setAdaptingStrategy(IAdaptingStrategy anAdaptingStrategy)
76      throws IllegalArgumentException;
77  }