|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NullHandler | Line # 35 | 2 | 23.1% | 8 | 0 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (4) | |||
| Result | |||
|
0.6
|
org.perfectjpattern.core.behavioral.chainofresponsibility.TestNullHandler.testExceptions
org.perfectjpattern.core.behavioral.chainofresponsibility.TestNullHandler.testExceptions
|
1 PASS | |
|
0.4
|
org.perfectjpattern.core.behavioral.chainofresponsibility.TestExample.testChainOfResponsibility
org.perfectjpattern.core.behavioral.chainofresponsibility.TestExample.testChainOfResponsibility
|
1 PASS | |
|
0.4
|
org.perfectjpattern.core.behavioral.chainofresponsibility.TestNullHandler.testCanHandle
org.perfectjpattern.core.behavioral.chainofresponsibility.TestNullHandler.testCanHandle
|
1 PASS | |
|
0.2
|
org.perfectjpattern.core.behavioral.chainofresponsibility.TestNullHandler.testSingleton
org.perfectjpattern.core.behavioral.chainofresponsibility.TestNullHandler.testSingleton
|
1 PASS | |
| 1 | //---------------------------------------------------------------------- | |
| 2 | // | |
| 3 | // PerfectJPattern: "Design patterns are good but components are better!" | |
| 4 | // NullHandler.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.behavioral.chainofresponsibility; | |
| 22 | ||
| 23 | import org.perfectjpattern.core.api.creational.singleton.ISingleton; | |
| 24 | ||
| 25 | /** | |
| 26 | * Null Object Pattern implementation of <code>IHandler</code>. | |
| 27 | * <br/><br/> | |
| 28 | * <code>NullHandler</code> is a Singleton therefore it may not be directly | |
| 29 | * instantiated, neither it may be extended. | |
| 30 | * | |
| 31 | * @author <a href="mailto:bravegag@hotmail.com">Giovanni Azua</a> | |
| 32 | * @version $Revision: 1.0 $ $Date: Jun 23, 2007 1:40:23 PM $ | |
| 33 | */ | |
| 34 | public final | |
| 35 | class NullHandler | |
| 36 | implements IHandler<Object>, ISingleton | |
| 37 | { | |
| 38 | //------------------------------------------------------------------------ | |
| 39 | // public | |
| 40 | //------------------------------------------------------------------------ | |
| 41 | /** | |
| 42 | * Returns Singleton instance of <code>NullHandler</code>. | |
| 43 | * | |
| 44 | * @return Singleton instance of <code>NullHandler</code>. | |
| 45 | */ | |
| 46 | 26 |
public static NullHandler |
| 47 | getInstance() | |
| 48 | { | |
| 49 | 26 | return INSTANCE; |
| 50 | } | |
| 51 | ||
| 52 | //------------------------------------------------------------------------ | |
| 53 | /** | |
| 54 | * {@inheritDoc} | |
| 55 | */ | |
| 56 | 1 |
public IHandler<Object> |
| 57 | getSuccessor() | |
| 58 | throws UnsupportedOperationException | |
| 59 | { | |
| 60 | throw new UnsupportedOperationException("'NullHandler' does not " + | |
| 61 | "support method getSuccessor()."); | |
| 62 | } | |
| 63 | ||
| 64 | //------------------------------------------------------------------------ | |
| 65 | /** | |
| 66 | * {@inheritDoc} | |
| 67 | */ | |
| 68 | 2 |
public void |
| 69 | start(Object aRequest) | |
| 70 | throws IllegalArgumentException | |
| 71 | { | |
| 72 | // do nothing | |
| 73 | } | |
| 74 | ||
| 75 | //------------------------------------------------------------------------ | |
| 76 | /** | |
| 77 | * {@inheritDoc} | |
| 78 | */ | |
| 79 | 1 |
public boolean |
| 80 | canHandle(Object aRequest) | |
| 81 | throws IllegalArgumentException | |
| 82 | { | |
| 83 | 1 | return true; |
| 84 | } | |
| 85 | ||
| 86 | //------------------------------------------------------------------------ | |
| 87 | /** | |
| 88 | * {@inheritDoc} | |
| 89 | */ | |
| 90 | 1 |
public void |
| 91 | handle(Object aRequest) | |
| 92 | { | |
| 93 | // do nothing | |
| 94 | } | |
| 95 | ||
| 96 | //------------------------------------------------------------------------ | |
| 97 | /** | |
| 98 | * {@inheritDoc} | |
| 99 | */ | |
| 100 | 1 |
public void |
| 101 | setSuccessor(IHandler<Object> aSuccessor) | |
| 102 | throws UnsupportedOperationException | |
| 103 | { | |
| 104 | throw new UnsupportedOperationException("'NullHandler' does not " + | |
| 105 | "support method setSuccessor()."); | |
| 106 | } | |
| 107 | ||
| 108 | //------------------------------------------------------------------------ | |
| 109 | /** | |
| 110 | * {@inheritDoc} | |
| 111 | */ | |
| 112 | 1 |
public void |
| 113 | setChainStrategy(IChainStrategy aStrategy) | |
| 114 | throws IllegalArgumentException | |
| 115 | { | |
| 116 | throw new UnsupportedOperationException("'NullHandler' does not " + | |
| 117 | "support method setChainStrategy()."); | |
| 118 | } | |
| 119 | ||
| 120 | //------------------------------------------------------------------------ | |
| 121 | // private | |
| 122 | //------------------------------------------------------------------------ | |
| 123 | 2 |
private |
| 124 | NullHandler() | |
| 125 | { | |
| 126 | // do nothing | |
| 127 | } | |
| 128 | ||
| 129 | //------------------------------------------------------------------------ | |
| 130 | // members | |
| 131 | //------------------------------------------------------------------------ | |
| 132 | /** | |
| 133 | * Singleton instance of <code>NullHandler</code> | |
| 134 | */ | |
| 135 | private static final NullHandler INSTANCE = new NullHandler(); | |
| 136 | } | |
|
||||||||||||