Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Refactored reporter addReportListener method parameter order and upda…
Browse files Browse the repository at this point in the history
…ted JavaDocs.
  • Loading branch information
tlaukkan committed Mar 8, 2015
1 parent 01909c0 commit 927660c
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

/**
* ZigBee Application Interface.
*
* @author <a href="mailto:tommi.s.e.laukkanen@gmail.com">Tommi S.E. Laukkanen</a>
* @author <a href="mailto:christopherhattonuk@gmail.com">Chris Hatton</a>
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ public interface Reporter {

/**
* Adds report listener and optionally adds ZigBee subscription.
* @param subscribe ZigBee level subscription should be added
* @param listener the listener
* @param subscribe ZigBee level subscription should be added
* @return true if operation was successful.
*/
public boolean addReportListener(boolean subscribe, ReportListener listener);
public boolean addReportListener(ReportListener listener, boolean subscribe);

/**
* Removes report listener and optionally removes ZigBee subscription.
* @param unsubscribe whether ZigBee level subscription should be removed
* @param listener the listener
* @param unsubscribe whether ZigBee level subscription should be removed
* @return true if operation was successful.
*/
public boolean removeReportListener(boolean unsubscribe, ReportListener listener);
public boolean removeReportListener(ReportListener listener, boolean unsubscribe);

public int getMinimumReportingInterval();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private boolean doUnbindToDevice() {

protected abstract boolean doConfigureServer() throws ZigBeeClusterException;

public boolean addReportListener(boolean subscribe, ReportListener listener) {
public boolean addReportListener(ReportListener listener, boolean subscribe) {
synchronized (listeners) {
if (subscribe) {
if (!doBindToDevice()) {
Expand Down Expand Up @@ -173,7 +173,7 @@ public int getMinimumReportingInterval() {
return 0;
}

public boolean removeReportListener(boolean unsubscribe, ReportListener listener) {
public boolean removeReportListener(ReportListener listener, boolean unsubscribe) {
synchronized (listeners) {
if (unsubscribe) {
if (!doUnbindToDevice()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public boolean subscribe(CurrentLevelListener listener) {
reporter.setReportableChange(configuration.getReportingChange());
reporter.updateConfiguration();
}
if (reporter.addReportListener(true, this) == false) {
if (reporter.addReportListener(this, true) == false) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public boolean subscribe(MeasuredValueListener listener) {
reporter.setReportableChange(configuration.getReportingChange());
reporter.updateConfiguration();
}
if (reporter.addReportListener(true, this) == false) {
if (reporter.addReportListener(this, true) == false) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public boolean subscribe(OccupancyListener listener) {
reporter.setMinimumReportingInterval(configuration.getReportingMinimum());
reporter.updateConfiguration();
}
if (reporter.addReportListener(true, this) == false) {
if (reporter.addReportListener(this, true) == false) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public boolean subscribe(OnOffListener listener) {
reporter.setMinimumReportingInterval(configuration.getReportingMinimum());
reporter.updateConfiguration();
}
if (reporter.addReportListener(true, this) == false) {
if (reporter.addReportListener(this, true) == false) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public boolean subscribe(PresentValueListener listener) {
reporter.setMinimumReportingInterval(configuration.getReportingMinimum());
reporter.updateConfiguration();
}
if (reporter.addReportListener(true, this) == false) {
if (reporter.addReportListener(this, true) == false) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public boolean subscribe(ToleranceListener listener) {
reporter.setReportableChange(configuration.getReportingChange());
reporter.updateConfiguration();
}
if (reporter.addReportListener(true, this) == false) {
if (reporter.addReportListener(this, true) == false) {
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright 2013 Tommi S.E. Laukkanen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bubblecloud.zigbee.network.impl;

import org.bubblecloud.zigbee.network.ZigBeeEndpoint;
Expand All @@ -12,6 +27,7 @@

/**
* NetworkStateSerializer serializes and deserializes the ZigBeeNetworkState.
* @author <a href="mailto:tommi.s.e.laukkanen@gmail.com">Tommi S.E. Laukkanen</a>
*/
public class NetworkStateSerializer {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
/**
* Copyright 2013 Tommi S.E. Laukkanen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bubblecloud.zigbee.network.impl;

import org.junit.Assert;
import org.bubblecloud.zigbee.network.ZigBeeEndpoint;
import org.junit.Test;

/**
* Test for network state serialization.
* @author <a href="mailto:tommi.s.e.laukkanen@gmail.com">Tommi S.E. Laukkanen</a>
*/
public class NetworkStateSerializerTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.bubblecloud.zigbee;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.bubblecloud.zigbee.api.Device;
import org.bubblecloud.zigbee.api.DeviceListener;
import org.bubblecloud.zigbee.api.ZigBeeApiConstants;
Expand Down Expand Up @@ -823,7 +822,7 @@ public boolean process(final ZigBeeApi zigbeeApi, final String[] args) {
return true;
}

reporter.addReportListener(false, consoleReportListener);
reporter.addReportListener(consoleReportListener, false);

return true;
}
Expand Down Expand Up @@ -873,7 +872,7 @@ public boolean process(final ZigBeeApi zigbeeApi, final String[] args) {
print("Attribute does not provide reports.");
}

reporter.removeReportListener(false, consoleReportListener);
reporter.removeReportListener(consoleReportListener, false);

return true;
}
Expand Down Expand Up @@ -925,7 +924,7 @@ public boolean process(final ZigBeeApi zigbeeApi, final String[] args) {
return true;
}

reporter.addReportListener(true, consoleReportListener);
reporter.addReportListener(consoleReportListener, true);

return true;
}
Expand Down Expand Up @@ -975,7 +974,7 @@ public boolean process(final ZigBeeApi zigbeeApi, final String[] args) {
print("Attribute does not provide reports.");
}

reporter.removeReportListener(true, consoleReportListener);
reporter.removeReportListener(consoleReportListener, true);

return true;
}
Expand Down

0 comments on commit 927660c

Please sign in to comment.