| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| NotificationEventCallback |
|
| 2.5;2.5 |
| 1 | // Copyright 2006, 2008 The Apache Software Foundation | |
| 2 | // | |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 | // you may not use this file except in compliance with the License. | |
| 5 | // You may obtain a copy of the License at | |
| 6 | // | |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 | // | |
| 9 | // Unless required by applicable law or agreed to in writing, software | |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 | // See the License for the specific language governing permissions and | |
| 13 | // limitations under the License. | |
| 14 | ||
| 15 | package org.apache.tapestry5.internal.util; | |
| 16 | ||
| 17 | import org.apache.tapestry5.ComponentEventCallback; | |
| 18 | ||
| 19 | /** | |
| 20 | * A {@link org.apache.tapestry5.ComponentEventCallback} used for notification events. Event handler methods may return | |
| 21 | * true (to abort the event) or false (to allow the event to continue bubbling up), but all other values are forbidden. | |
| 22 | */ | |
| 23 | public class NotificationEventCallback implements ComponentEventCallback | |
| 24 | { | |
| 25 | private final String eventType; | |
| 26 | ||
| 27 | private final String completeId; | |
| 28 | ||
| 29 | public NotificationEventCallback(String eventType, String completeId) | |
| 30 | 1142 | { |
| 31 | 1142 | this.eventType = eventType; |
| 32 | 1142 | this.completeId = completeId; |
| 33 | 1142 | } |
| 34 | ||
| 35 | public boolean handleResult(Object result) | |
| 36 | { | |
| 37 | 6 | if (result instanceof Boolean) return ((Boolean) result); |
| 38 | ||
| 39 | 2 | throw new IllegalArgumentException( |
| 40 | UtilMessages.noReturnValueAccepted(eventType, completeId, result)); | |
| 41 | } | |
| 42 | ||
| 43 | } |