001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.type.scope;
020
021import java.io.Serializable;
022
023import lucee.runtime.type.Collection;
024
025public final class ClusterEntryImpl  implements ClusterEntry {
026
027        private Collection.Key key;
028        private long time;
029        private Serializable value;
030
031        public ClusterEntryImpl(Collection.Key key,Serializable value, int offset) {
032                this.key=key;
033                this.time=System.currentTimeMillis()+offset;
034                this.value=value;
035        }
036        public ClusterEntryImpl(Collection.Key key,Serializable value, long time) {
037                this.key=key;
038                this.time=time;
039                this.value=value;
040        }
041        
042        /**
043         * Constructor of the class for Webservice Bean Deserializer
044         */
045        public ClusterEntryImpl() {}
046
047        /**
048         * @param key the key to set
049         */
050        public void setKey(Collection.Key key) {
051                this.key = key;
052        }
053        /**
054         * @param time the time to set
055         */
056        public void setTime(long time) {
057                this.time = time;
058        }
059        /**
060         * @param value the value to set
061         */
062        public void setValue(Serializable value) {
063                this.value = value;
064        }
065        /**
066         * @return the key
067         */
068        public Collection.Key getKey() {
069                return key;
070        }
071
072        /**
073         * @return the time
074         */
075        public Long getTimeRef() {
076                return Long.valueOf(time);
077        }
078        
079        public long getTime() {
080                return time;
081        }
082
083        /**
084         * @return the value
085         */
086        public Serializable getValue() {
087                return value;
088        }
089        
090        @Override
091        public boolean equals(Object obj) {
092                if(obj instanceof ClusterEntry) {
093                        ClusterEntry other = (ClusterEntry)obj;
094                        return key.equalsIgnoreCase(other.getKey());
095                }
096                return false;
097        }
098}