org.bidib.jbidibc.netbidib.client.pairingstates.ProxyBidibLinkData Maven / Gradle / Ivy
package org.bidib.jbidibc.netbidib.client.pairingstates;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.concurrent.atomic.AtomicBoolean;
import org.bidib.jbidibc.messages.ProtocolVersion;
import org.bidib.jbidibc.messages.enums.NetBidibRole;
import org.bidib.jbidibc.messages.message.netbidib.BidibLinkData;
import org.bidib.jbidibc.messages.message.netbidib.NetBidibLinkData.LogonStatus;
import org.bidib.jbidibc.messages.message.netbidib.NetBidibLinkData.PairingStatus;
import org.bidib.jbidibc.messages.message.netbidib.NetBidibLinkData.PartnerType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ProxyBidibLinkData implements BidibLinkData {
private static final Logger LOGGER = LoggerFactory.getLogger(ProxyBidibLinkData.class);
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
public static final String PROPERTY_PAIRINGSTATUS = "pairingStatus";
public static final String PROPERTY_INITIAL_EMITTER_SENT = "initialEmitterSent";
public static final String PROPERTY_ACTIVE_CONNECTION = "activeConnection";
private final BidibLinkData bidibLinkData;
private final AtomicBoolean initialEmitterSent = new AtomicBoolean();
private boolean activeConnection;
protected ProxyBidibLinkData(BidibLinkData bidibLinkData) {
this.bidibLinkData = bidibLinkData;
}
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
this.pcs.addPropertyChangeListener(propertyName, listener);
}
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
this.pcs.removePropertyChangeListener(propertyName, listener);
}
@Override
public PartnerType getPartnerType() {
return this.bidibLinkData.getPartnerType();
}
@Override
public String getRequestorName() {
return this.bidibLinkData.getRequestorName();
}
@Override
public void setRequestorName(String requestorName) {
this.bidibLinkData.setRequestorName(requestorName);
}
@Override
public Long getUniqueId() {
return this.bidibLinkData.getUniqueId();
}
@Override
public void setUniqueId(Long uniqueId) {
this.bidibLinkData.setUniqueId(uniqueId);
}
@Override
public String getProdString() {
return this.bidibLinkData.getProdString();
}
@Override
public void setProdString(String prodString) {
this.bidibLinkData.setProdString(prodString);
}
@Override
public String getUserString() {
return this.bidibLinkData.getUserString();
}
@Override
public void setUserString(String userString) {
this.bidibLinkData.setUserString(userString);
}
@Override
public ProtocolVersion getProtocolVersion() {
return this.bidibLinkData.getProtocolVersion();
}
@Override
public void setProtocolVersion(ProtocolVersion protocolVersion) {
this.bidibLinkData.setProtocolVersion(protocolVersion);
}
@Override
public NetBidibRole getNetBidibRole() {
return this.bidibLinkData.getNetBidibRole();
}
@Override
public void setNetBidibRole(NetBidibRole netBidibRole) {
this.bidibLinkData.setNetBidibRole(netBidibRole);
}
@Override
public PairingStatus getPairingStatus() {
return this.bidibLinkData.getPairingStatus();
}
@Override
public void setPairingStatus(PairingStatus pairingStatus) {
LOGGER.info("Set the pairing status: {}", pairingStatus);
PairingStatus oldValue = this.getPairingStatus();
this.bidibLinkData.setPairingStatus(pairingStatus);
this.pcs.firePropertyChange(PROPERTY_PAIRINGSTATUS, oldValue, pairingStatus);
}
@Override
public LogonStatus getLogonStatus() {
return this.bidibLinkData.getLogonStatus();
}
@Override
public void setLogonStatus(LogonStatus logonStatus) {
this.bidibLinkData.setLogonStatus(logonStatus);
}
@Override
public Integer getRequestedPairingTimeout() {
return this.bidibLinkData.getRequestedPairingTimeout();
}
@Override
public void setRequestedPairingTimeout(Integer requestedPairingTimeout) {
this.bidibLinkData.setRequestedPairingTimeout(requestedPairingTimeout);
}
/**
* @return the initialEmitterSent
*/
public void setInitialEmitterSent(boolean initialEmitterSent) {
this.initialEmitterSent.set(initialEmitterSent);
}
/**
* @return the initialEmitterSent
*/
public boolean getInitialEmitterSent() {
return initialEmitterSent.get();
}
/**
* @return the activeConnection
*/
public boolean isActiveConnection() {
return activeConnection;
}
/**
* @param activeConnection
* the activeConnection to set
*/
public void setActiveConnection(boolean activeConnection) {
boolean oldValue = this.activeConnection;
this.activeConnection = activeConnection;
this.pcs.firePropertyChange(PROPERTY_ACTIVE_CONNECTION, oldValue, activeConnection);
}
@Override
public void clear(boolean clearRequestor) {
this.bidibLinkData.clear(clearRequestor);
}
@Override
public String toString() {
return this.bidibLinkData.toString();
}
@Override
public boolean isLinkDataValid() {
return this.bidibLinkData.isLinkDataValid();
}
}