001package jmri.implementation;
002
003import javax.annotation.CheckReturnValue;
004import javax.annotation.Nonnull;
005import jmri.Memory;
006import jmri.NamedBean;
007
008/**
009 * Base for the Memory interface.
010 * <p>
011 * Implements the parameter binding support.
012 *
013 * @author Bob Jacobsen Copyright (C) 2004
014 */
015public abstract class AbstractMemory extends AbstractNamedBean implements Memory {
016
017    public AbstractMemory(String systemName) {
018        super(systemName);
019    }
020
021    public AbstractMemory(String systemName, String userName) {
022        super(systemName, userName);
023    }
024
025    @Override
026    public String getBeanType() {
027        return Bundle.getMessage("BeanNameMemory");
028    }
029
030    @Override
031    public Object getValue() {
032        return _current;
033    }
034
035    /**
036     * Provide a general method for updating the report.
037     */
038    @Override
039    public void setValue(Object v) {
040        Object old = _current;
041        _current = v;
042        // notify
043        firePropertyChange("value", old, _current);
044    }
045    
046    /**
047     * {@inheritDoc} 
048     * 
049     * Do a string comparison.
050     */
051    @CheckReturnValue
052    @Override
053    public int compareSystemNameSuffix(@Nonnull String suffix1, @Nonnull String suffix2, @Nonnull NamedBean n) {
054        return suffix1.compareTo(suffix2);
055    }
056
057    // internal data members
058    private Object _current = null;
059
060}