001package fi.jyu.mit.fxgui;
002
003/**
004 * Packeting class to hold the name alongside the actual object
005 * @author Tero Paavolainen
006 * @version 9.1.2017
007 * @param <T> mitä luokkaa tallennetaan
008 */
009public class StringAndObject<T> {
010        private String name;
011        private T object;
012        
013        /**
014         * Creates a string and object -object for storing data
015         * @param name the displayed object name
016         * @param obj the object that is stored
017         */
018        public StringAndObject(String name,T obj){
019                this.setName(name);
020                this.setObject(obj);
021        }
022        
023        
024        @Override
025        public String toString(){
026                return getName() != null ? getName() : getObject().toString();
027        }
028
029
030        /**
031         * Returns the name of the pair
032         * @return name
033         */
034        public String getName() {
035                return name;
036        }
037
038
039        /**
040         * Sets the name of the pair
041         * @param name name for pair
042         */
043        public void setName(String name) {
044                this.name = name;
045        }
046
047
048        /**
049         * Returns the object of the pair
050         * @return object
051         */
052        public T getObject() {
053                return object;
054        }
055
056
057        /**
058         * Sets the object of the pair
059         * @param object the new object
060         */
061        public void setObject(T object) {
062                this.object = object;
063        }
064}