All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Alachisoft.NCache.Common.Monitoring.Counter Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
package Alachisoft.NCache.Common.Monitoring;

import Alachisoft.NCache.Common.Common;
import Alachisoft.NCache.Common.Configuration.ConfigurationAttributeAnnotation;
import Alachisoft.NCache.Common.ICloneable;
import com.alachisoft.ncache.serialization.core.io.ICompactSerializable;
import com.alachisoft.ncache.serialization.core.io.InternalCompactSerializable;
import com.alachisoft.ncache.serialization.core.io.NCacheObjectInput;
import com.alachisoft.ncache.serialization.core.io.NCacheObjectOutput;
import com.alachisoft.ncache.serialization.standard.io.CompactReader;
import com.alachisoft.ncache.serialization.standard.io.CompactWriter;

import java.io.IOException;

public class Counter implements ICloneable , InternalCompactSerializable
{
    private String _name = "";
    private boolean _publish = false;

    public Counter() { }
    public Counter(String name,boolean publish)
    {
        setName(name);
        setPublish(publish);

    }
    @ConfigurationAttributeAnnotation(value = "name", appendText = "")
    public void setName(String name){ _name=name; }
    @ConfigurationAttributeAnnotation(value = "name", appendText = "")
    public String getName(){ return _name;}
    @ConfigurationAttributeAnnotation(value = "publish", appendText = "")
    public void setPublish(boolean publish){ _publish=publish;}
    @ConfigurationAttributeAnnotation(value = "publish", appendText = "")
    public boolean getPublish() { return _publish;}


    @Override
    public Object clone()
    {
        Counter counter = new Counter();
        counter.setPublish(_publish);
        counter.setName(_name);
        return counter;
    }

    @Override
    public void Deserialize(CompactReader reader) throws IOException, ClassNotFoundException {
        setPublish(reader.ReadBoolean());
        setName(Common.as(reader.ReadObject(),String.class));
    }

    @Override
    public void Serialize(CompactWriter writer) throws IOException
    {
        writer.Write(getPublish());
        writer.WriteObject(getName());

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy