001/*******************************************************************************
002 * Copyright (c) 2016 Diamond Light Source Ltd. and others.
003 * All rights reserved. This program and the accompanying materials
004 * are made available under the terms of the Eclipse Public License v1.0
005 * which accompanies this distribution, and is available at
006 * http://www.eclipse.org/legal/epl-v10.html
007 *
008 * Contributors:
009 *     Diamond Light Source Ltd - initial API and implementation
010 *******************************************************************************/
011package org.eclipse.january.metadata;
012
013/**
014 * This metadata is set by a remote dataset.
015 * 
016 * It provides information about dropped data and
017 * received data while the dataset is connected.
018 * 
019 * Not all remote datasets are forced to provide this information.
020 * 
021 * This class is set in bundle org.eclipse.dawnsci.remotedataset.client 
022 * as metadata on RemoteDatasets returned from the Data Server
023 * 
024 */
025public class DynamicConnectionInfo implements MetadataType {
026
027        /**
028         * 
029         */
030        private static final long serialVersionUID = -3982740822246879131L;
031        
032        private long receivedCount;
033        private long droppedCount;
034        private boolean connected;
035        
036        
037        public boolean isConnected() {
038                return connected;
039        }
040
041        public void setConnected(boolean connected) {
042                this.connected = connected;
043        }
044
045        @Override
046        public int hashCode() {
047                final int prime = 31;
048                int result = 1;
049                result = prime * result + (connected ? 1231 : 1237);
050                result = prime * result + (int) (droppedCount ^ (droppedCount >>> 32));
051                result = prime * result + (int) (receivedCount ^ (receivedCount >>> 32));
052                return result;
053        }
054
055        @Override
056        public boolean equals(Object obj) {
057                if (this == obj)
058                        return true;
059                if (obj == null)
060                        return false;
061                if (getClass() != obj.getClass())
062                        return false;
063                DynamicConnectionInfo other = (DynamicConnectionInfo) obj;
064                if (connected != other.connected)
065                        return false;
066                if (droppedCount != other.droppedCount)
067                        return false;
068                if (receivedCount != other.receivedCount)
069                        return false;
070                return true;
071        }
072
073        public long getReceivedCount() {
074                return receivedCount;
075        }
076
077        public void setReceivedCount(int receivedCount) {
078                this.receivedCount = receivedCount;
079        }
080
081        public long getDroppedCount() {
082                return droppedCount;
083        }
084
085        public void setDroppedCount(int droppedCount) {
086                this.droppedCount = droppedCount;
087        }
088
089        /**
090         * Make a deep copy of metadata
091         * @return clone
092         */
093        @Override
094        public MetadataType clone() {
095                DynamicConnectionInfo info = new DynamicConnectionInfo();
096                info.receivedCount = this.receivedCount;
097                info.droppedCount  = this.droppedCount;
098                return info;
099        }
100
101}