001package jmri.jmrit.display.layoutEditor;
002
003import jmri.ExpectedState;
004import jmri.beans.Bean;
005
006/**
007 * Retain a LayoutTrack and its expected state.
008 *
009 * @author Randall Wood Copyright 2017
010 * @param <T> the supported type of LayoutTrack
011 */
012public class LayoutTrackExpectedState<T extends LayoutTrack> extends Bean implements ExpectedState<T, Integer> {
013
014    private final T layoutTrack;
015    private Integer state;
016
017    public LayoutTrackExpectedState(T layoutTrack, Integer state) {
018        this.layoutTrack = layoutTrack;
019        LayoutTrackExpectedState.this.setExpectedState(state);
020    }
021
022    @Override
023    public Integer getExpectedState() {
024        return state;
025    }
026
027    @Override
028    public void setExpectedState(Integer state) throws UnsupportedOperationException {
029        Integer old = this.state;
030        this.state = state;
031        this.propertyChangeSupport.firePropertyChange(EXPECTED_STATE, old, state);
032    }
033
034    @Override
035    public T getObject() {
036        return this.layoutTrack;
037    }
038
039}