source: tol/TolJava/TOLJava/src/com/hcarralero/toljava/TOLVariable.java @ e946b884

1941-docker-image-to-testdevel
Last change on this file since e946b884 was 9887b93, checked in by Humberto Carralero <hacarralero@…>, 15 years ago

Importing TolJava

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@3900 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 3.5 KB
Line 
1
2package com.hcarralero.toljava;
3
4/**
5 * Representa a una variable de TOL, consta de nombre, descripción y valor
6 *
7 * @author Humberto Andrés Carralero López (hcarralero@gmail.com)
8 * @version 1.0
9 */
10public class TOLVariable {
11
12    /**
13     * Construye un objeto <code>TOLVariable</code>
14     *
15     * @param name nombre
16     * @param value valor
17     * @param desc descripción
18     */
19    public TOLVariable(String name, TOLObject value, String desc) {
20        this.name = name;
21        this.value = value;
22        this.desc = desc;
23    }
24
25    private String name = "NO_NAME";
26
27    /**
28     * Retorna el nombre de la variable
29     *
30     * @return el nombre de la variable
31     */
32    public String getName() {
33        return name;
34    }
35
36    /**
37     * Cambia el nombre de la variable por el nuevo nombre
38     *
39     * @param name el nuevo nombre.
40     */
41    public void setName(String name) {
42        this.name = name;
43    }
44
45    private TOLObject value= null;
46
47    /**
48     * Retorna el valor de la variable
49     *
50     * @return el valor de la variable
51     */
52    public TOLObject getValue() {
53        return value;
54    }
55
56    /**
57     * Cambia el valor de la variable por el nuevo valor
58     *
59     * @param value el nuevo valor
60     */
61    public void setValue(TOLObject value) {
62        this.value = value;
63    }
64
65    private String desc= "Sin descripción";
66
67    /**
68     * Retorna la descripción de la variable
69     *
70     * @return la descripción de la variable
71     */
72    public String getDesc() {
73        return desc;
74    }
75
76    /**
77     * Cambia la descripción de la variable por la nueva descripción
78     *
79     * @param desc la nueva descripción
80     */
81    public void setDesc(String desc) {
82        this.desc = desc;
83    }
84
85    /**
86     * Compara a este objeto con otro
87     *
88     * @param obj el objeto con el que se comparará
89     * @return <code>true</code> si el objeto pasado como parámetroves de tipo
90     * <code>TOLVariable</code>, tiene el mismo nombre, la misma descripción y el
91     * mismo valor
92     */
93    @Override
94    public boolean equals(Object obj) {
95        if (obj == null) {
96            return false;
97        }
98        if (getClass() != obj.getClass()) {
99            return false;
100        }
101        final TOLVariable other = (TOLVariable) obj;
102        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
103            return false;
104        }
105        if (this.value != other.value && (this.value == null || !this.value.equals(other.value))) {
106            return false;
107        }
108        if ((this.desc == null) ? (other.desc != null) : !this.desc.equals(other.desc)) {
109            return false;
110        }
111        return true;
112    }
113
114    /**
115     * Calcula el código hash asignado al objeto
116     *
117     * @return el código hash asignado al objeto
118     */
119    @Override
120    public int hashCode() {
121        int hash = 7;
122        hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0);
123        hash = 37 * hash + (this.value != null ? this.value.hashCode() : 0);
124        hash = 37 * hash + (this.desc != null ? this.desc.hashCode() : 0);
125        return hash;
126    }
127
128    /**
129     * Obtiene una representación como cadena de texto de la variable en el formato
130     * [name: <nombre>], [desc: <descripción>], [value: <value>]
131     *
132     * @return la representación como cadena de texto de la variable
133     */
134    @Override
135    public String toString() {
136        return "[name: "+this.name+"], [desc: "+this.desc+"], [value: "+this.value.toString()+"]";
137    }
138
139}
Note: See TracBrowser for help on using the repository browser.