EMMA Coverage Report (generated Tue Apr 17 08:51:20 BST 2007)
[all classes][org.jtoolkit.essence.data.impl]

COVERAGE SUMMARY FOR SOURCE FILE [StoreEvent.java]

nameclass, %method, %block, %line, %
StoreEvent.java100% (1/1)75%  (3/4)65%  (40/62)74%  (14/19)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StoreEvent100% (1/1)75%  (3/4)65%  (40/62)74%  (14/19)
notifyListener (Event$Listener): void 0%   (0/1)0%   (0/22)0%   (0/5)
StoreEvent (DataInput): void 100% (1/1)100% (15/15)100% (5/5)
StoreEvent (boolean, Object, Object): void 100% (1/1)100% (12/12)100% (5/5)
writeData (DataOutput): void 100% (1/1)100% (13/13)100% (4/4)

1package org.jtoolkit.essence.data.impl;
2 
3import org.jetbrains.annotations.NotNull;
4import org.jetbrains.annotations.Nullable;
5import org.jtoolkit.essence.app.pojo.DataValue;
6import org.jtoolkit.essence.app.pojo.Datable;
7import static org.jtoolkit.essence.app.pojo.DatableUtils.readObject;
8import static org.jtoolkit.essence.app.pojo.DatableUtils.writeObject;
9import org.jtoolkit.essence.data.Event;
10import org.jtoolkit.essence.data.Store;
11 
12import java.io.DataInput;
13import java.io.DataOutput;
14import java.io.IOException;
15 
16/*
17   Copyright 2006 Peter Lawrey
18 
19   Licensed under the Apache License, Version 2.0 (the "License");
20   you may not use this file except in compliance with the License.
21   You may obtain a copy of the License at
22 
23       http://www.apache.org/licenses/LICENSE-2.0
24 
25   Unless required by applicable law or agreed to in writing, software
26   distributed under the License is distributed on an "AS IS" BASIS,
27   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28   See the License for the specific language governing permissions and
29   limitations under the License.
30*/
31 
32/**
33 * @author Peter Lawrey
34 * @noinspection unchecked
35 */
36public class StoreEvent<K, V> extends DataValue implements Event, Datable {
37    private final boolean updated;
38    private final K key;
39    private final V value;
40 
41    public StoreEvent(boolean updated, @NotNull K key, @Nullable V value) {
42        this.updated = updated;
43        this.key = key;
44        this.value = value;
45    }
46 
47    public void notifyListener(@NotNull Listener l) {
48        if (l instanceof Store.StoreListener) {
49            if (updated)
50                ((Store.StoreListener) l).onUpdate(key, value);
51            else
52                ((Store.StoreListener) l).onRemoved(key, value);
53        }
54    }
55 
56    // used to deserialize.
57    @SuppressWarnings({"UnusedDeclaration"}) StoreEvent(@NotNull DataInput in) throws IOException {
58        updated = in.readBoolean();
59        key = (K) readObject(in);
60        value = (V) readObject(in);
61    }
62 
63    public void writeData(@NotNull DataOutput out) throws IOException {
64        out.writeBoolean(updated);
65        writeObject(out, key);
66        writeObject(out, value);
67    }
68}

[all classes][org.jtoolkit.essence.data.impl]
EMMA 2.0.5312 (C) Vladimir Roubtsov