|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| AbstractReceiver | Line # 34 | 5 | 18.2% | 4 | 2 | 77.8% |
0.7777778
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| No Tests | |||
| 1 | //---------------------------------------------------------------------- | |
| 2 | // | |
| 3 | // PerfectJPattern: "Design patterns are good but components are better!" | |
| 4 | // AbstractReceiver.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.behavioral.command; | |
| 22 | ||
| 23 | import org.apache.commons.lang.*; | |
| 24 | import org.perfectjpattern.core.api.behavioral.command.*; | |
| 25 | ||
| 26 | ||
| 27 | /** | |
| 28 | * Reusable base abstract implementation of {@link IReceiver} | |
| 29 | * | |
| 30 | * @author <a href="mailto:bravegag@hotmail.com">Giovanni Azua</a> | |
| 31 | * @version $Revision: 1.0 $Date: Apr 13, 2008 2:24:53 PM $ | |
| 32 | */ | |
| 33 | public abstract | |
| 34 | class AbstractReceiver<P, R> | |
| 35 | implements IReceiver<P, R> | |
| 36 | { | |
| 37 | //------------------------------------------------------------------------ | |
| 38 | // public | |
| 39 | //------------------------------------------------------------------------ | |
| 40 | /** | |
| 41 | * {@inheritDoc} | |
| 42 | */ | |
| 43 | 3 |
public R |
| 44 | getResult() | |
| 45 | { | |
| 46 | 3 | return theResult; |
| 47 | } | |
| 48 | ||
| 49 | //------------------------------------------------------------------------ | |
| 50 | /** | |
| 51 | * {@inheritDoc} | |
| 52 | */ | |
| 53 | 3 |
public void |
| 54 | setParameter(P aParameter) | |
| 55 | throws IllegalArgumentException | |
| 56 | { | |
| 57 | 3 | Validate.notNull(aParameter, "'aParameter' must not be null"); |
| 58 | ||
| 59 | 3 | theParameter = aParameter; |
| 60 | } | |
| 61 | ||
| 62 | //------------------------------------------------------------------------ | |
| 63 | // protected | |
| 64 | //------------------------------------------------------------------------ | |
| 65 | /** | |
| 66 | * Returns the previously assigned Parameter | |
| 67 | * | |
| 68 | * @return the parameter | |
| 69 | */ | |
| 70 | 0 |
protected P |
| 71 | getParameter() | |
| 72 | { | |
| 73 | 0 | return theParameter; |
| 74 | } | |
| 75 | ||
| 76 | //------------------------------------------------------------------------ | |
| 77 | /** | |
| 78 | * Sets the Result | |
| 79 | * | |
| 80 | * @param aResult the result to set | |
| 81 | */ | |
| 82 | 3 |
protected void |
| 83 | setResult(R aResult) | |
| 84 | { | |
| 85 | assert aResult != null : "'aResult' must not be null"; | |
| 86 | ||
| 87 | 3 | theResult = aResult; |
| 88 | } | |
| 89 | ||
| 90 | //------------------------------------------------------------------------ | |
| 91 | // members | |
| 92 | //------------------------------------------------------------------------ | |
| 93 | private P theParameter; | |
| 94 | private R theResult; | |
| 95 | } | |
|
||||||||||||