// Path: src/main/java/ch/hevs/jscada/io/AbstractConnection.java
// public abstract class AbstractConnection implements Connection {
//     private final List<ConnectionListener> listeners = new LinkedList<>();
//     private ConnectionState state = ConnectionState.IDLE;
// 
//     @Override
//     public final ConnectionState getConnectionState() {
//         return state;
//     }
// 
//     @Override
//     public final void addConnectionListener(final ConnectionListener listener) {
//         listeners.add(listener);
//     }
// 
//     @Override
//     public final void removeConnectionListener(final ConnectionListener listener) {
//         listeners.remove(listener);
//     }
// 
//     /**
//      * Sets the state to the given value and notifies all listeners if the state has changed.
//      *
//      * @param state New state.
//      */
//     protected final void setState(final ConnectionState state) {
//         final boolean changed = this.state != state;
//         this.state = state;
//         if (changed) {
//             for (final ConnectionListener listener : listeners) {
//                 listener.connectionStateChanged(this, this.state);
//             }
//         }
//     }
// 
//     /**
//      * Notifies all connection listeners about the exception thrown by the connection.
//      *
//      * @param exception The exception thrown.
//      */
//     protected final void notifyAboutException(final Exception exception) {
//         for (final ConnectionListener listener : listeners) {
//             listener.connectionThrownException(this, exception);
//         }
//     }
// }
// 
// Path: src/main/java/ch/hevs/jscada/io/SynchronizableListener.java
// public interface SynchronizableListener {
//     /**
//      * This method will be called by the Synchronizable just before synchronizing.
//      *
//      * @param synchronizable The Synchronizable that will be synchronized.
//      */
//     void willSynchronize(Synchronizable synchronizable);
// 
//     /**
//      * This method will be called by the Synchronizable just after synchronizing took place.
//      *
//      * @param synchronizable The Synchronizable that was synchronized.
//      */
//     void didSynchronize(Synchronizable synchronizable);
// }


import ch.hevs.jscada.io.AbstractConnection;
import ch.hevs.jscada.io.SynchronizableListener;
import java.util.ArrayList;
import java.util.List;
package ch.hevs.jscada.io.field;



public abstract class AbstractFieldConnection extends AbstractConnection implements FieldConnection {
    private final List<SynchronizableListener> synchronizableListeners = new ArrayList<>();

    @Override
    public final void addSynchronizableListener(final SynchronizableListener listener) {
        synchronizableListeners.add(listener);
    }

    @Override
    public final void removeSynchronizableListener(final SynchronizableListener listener) {
        synchronizableListeners.remove(listener);
    }

    protected void willSynchronize() {
        for (final SynchronizableListener listener: synchronizableListeners) {
            listener.willSynchronize(this);
        }
    }

// Path: src/main/java/ch/hevs/jscada/io/AbstractConnection.java
// public abstract class AbstractConnection implements Connection {
//     private final List<ConnectionListener> listeners = new LinkedList<>();
//     private ConnectionState state = ConnectionState.IDLE;
// 
//     @Override
//     public final ConnectionState getConnectionState() {
//         return state;
//     }
// 
//     @Override
//     public final void addConnectionListener(final ConnectionListener listener) {
//         listeners.add(listener);
//     }
// 
//     @Override
//     public final void removeConnectionListener(final ConnectionListener listener) {
//         listeners.remove(listener);
//     }
// 
//     /**
//      * Sets the state to the given value and notifies all listeners if the state has changed.
//      *
//      * @param state New state.
//      */
//     protected final void setState(final ConnectionState state) {
//         final boolean changed = this.state != state;
//         this.state = state;
//         if (changed) {
//             for (final ConnectionListener listener : listeners) {
//                 listener.connectionStateChanged(this, this.state);
//             }
//         }
//     }
// 
//     /**
//      * Notifies all connection listeners about the exception thrown by the connection.
//      *
//      * @param exception The exception thrown.
//      */
//     protected final void notifyAboutException(final Exception exception) {
//         for (final ConnectionListener listener : listeners) {
//             listener.connectionThrownException(this, exception);
//         }
//     }
// }
// 
// Path: src/main/java/ch/hevs/jscada/io/SynchronizableListener.java
// public interface SynchronizableListener {
//     /**
//      * This method will be called by the Synchronizable just before synchronizing.
//      *
//      * @param synchronizable The Synchronizable that will be synchronized.
//      */
//     void willSynchronize(Synchronizable synchronizable);
// 
//     /**
//      * This method will be called by the Synchronizable just after synchronizing took place.
//      *
//      * @param synchronizable The Synchronizable that was synchronized.
//      */
//     void didSynchronize(Synchronizable synchronizable);
// }


// Path: src/main/java/ch/hevs/jscada/io/field/AbstractFieldConnection.java
import ch.hevs.jscada.io.AbstractConnection;
import ch.hevs.jscada.io.SynchronizableListener;
import java.util.ArrayList;
import java.util.List;

package ch.hevs.jscada.io.field;



public abstract class AbstractFieldConnection extends AbstractConnection implements FieldConnection {
    private final List<SynchronizableListener> synchronizableListeners = new ArrayList<>();

    @Override
    public final void addSynchronizableListener(final SynchronizableListener listener) {
        synchronizableListeners.add(listener);
    }

    @Override
    public final void removeSynchronizableListener(final SynchronizableListener listener) {
        synchronizableListeners.remove(listener);
    }

    protected void willSynchronize() {
        for (final SynchronizableListener listener: synchronizableListeners) {
            listener.willSynchronize(this);
        }
    }

    protected final void didSynchronize() {