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     * {@inheritDoc}
038     */
039    @Override
040    public void setValue(Object v) {
041        Object old = _current;
042        _current = v;
043        // notify
044        firePropertyChange(PROPERTY_VALUE, old, _current);
045    }
046
047    /**
048     * {@inheritDoc} 
049     * 
050     * Do a string comparison.
051     */
052    @CheckReturnValue
053    @Override
054    public int compareSystemNameSuffix(@Nonnull String suffix1, @Nonnull String suffix2, @Nonnull NamedBean n) {
055        return suffix1.compareTo(suffix2);
056    }
057
058    // internal data members
059    private Object _current = null;
060
061}