001package jmri.jmrit.roster;
002
003/**
004 * An object to store all decoder function informations in one place.
005 * 
006 * <hr>
007 * This file is part of JMRI.
008 * <p>
009 * JMRI is free software; you can redistribute it and/or modify it under the
010 * terms of version 2 of the GNU General Public License as published by the Free
011 * Software Foundation. See the "COPYING" file for a copy of this license.
012 * <p>
013 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
014 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
015 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
016 *
017 * @author Lionel Jeanson Copyright (C) 2026
018 * 
019 */
020public class RosterFunctionEntry {
021
022    private int fn;
023    private String label; 
024    private String image;
025    private String selectedImage;
026    private boolean lockable;
027    private boolean visible;
028
029    public RosterFunctionEntry(int n) {
030        fn = n;
031        label = null;
032        image = null;
033        selectedImage = null;
034        lockable = true;
035        visible = true;
036    }
037
038    public RosterFunctionEntry(int n, String lab, String im, String sim, boolean lock, boolean vis) {
039        fn = n;
040        label = lab;
041        image = im;
042        selectedImage = sim;
043        lockable = lock;
044        visible = vis;
045    }
046
047    public RosterFunctionEntry(RosterFunctionEntry pEntry) {
048        this( pEntry.fn, pEntry.label, pEntry.image, pEntry.selectedImage, pEntry.lockable, pEntry.visible);
049    }
050
051    public RosterFunctionEntry(int fn, RosterFunctionEntry pEntry) {
052        this( fn, pEntry.label, pEntry.image, pEntry.selectedImage, pEntry.lockable, pEntry.visible);
053    }
054
055    public int getFunctionNumber() {
056        return fn;
057    }
058    
059    public String getLabel() {
060        return label;
061    }
062
063    public void setLabel(String label) {
064        this.label = label;
065    }
066
067    public String getImage() {
068        return image;
069    }
070
071    public void setImage(String image) {
072        this.image = image;
073    }
074
075    public String getSelectedImage() {
076        return selectedImage;
077    }
078
079    public void setSelectedImage(String selectedImage) {
080        this.selectedImage = selectedImage;
081    }
082
083    public boolean isLockable() {
084        return lockable;
085    }
086
087    public void setLockable(boolean lockable) {
088        this.lockable = lockable;
089    }
090
091    public boolean isVisible() {
092        return visible; 
093    }
094
095    public void setVisible(boolean visible) {
096        this.visible = visible;
097    }
098
099    @Override
100    public boolean equals(Object o) {
101        if (this == o) {
102            return true;
103        }
104        if ((o == null || o.getClass()!= this.getClass())) {
105            return false;
106        }
107        RosterFunctionEntry r = (RosterFunctionEntry) o;
108        return (            
109            (fn == r.fn) &&
110            (label == null ? r.label == null : label.equals(r.label)) &&
111            (image == null ? r.image == null : image.equals(r.image)) &&
112            (selectedImage == null ? r.selectedImage == null : selectedImage.equals(r.selectedImage)) &&
113            (lockable == r.lockable) &&
114            (visible == r.visible)
115        );
116    }
117
118    @Override
119    public int hashCode() {
120        int hash = 7;
121        hash = 31 * hash + fn;
122        hash = 31 * hash + (label == null ? 0 : label.hashCode());
123        hash = 31 * hash + (image == null ? 0 : image.hashCode());
124        hash = 31 * hash + (selectedImage == null ? 0 : selectedImage.hashCode());
125        hash = 31 * hash + (lockable ? 1 : 0);
126        hash = 31 * hash + (visible ? 1 : 0);
127        return hash;
128    }
129
130}