create changelog entry
[debian/openrocket] / core / src / de / congrace / exp4j / VariableSet.java
1 package de.congrace.exp4j;
2
3 import java.util.HashSet;
4
5 public class VariableSet extends HashSet<Variable> {
6
7         /**
8          * 
9          */
10         private static final long serialVersionUID = -4212803364398351279L;
11
12         public boolean add(Variable v){
13                 Variable previous = getVariableNamed(v.getName());
14                 if ( previous != null ){
15                         this.remove( previous );
16                 }
17                         
18                 return super.add(v);
19         }
20         
21         public Variable getVariableNamed(String name){
22                 for (Variable var : this){
23                         if (var.getName().equals(name) ){
24                                 return var;
25                         }
26                 }
27                 return null;
28         }
29         
30         public String[] getVariableNames(){
31                 if (this.size() == 0){
32                         return null;
33                 }
34                 String names[] = new String[this.size()];
35                 int i = 0;
36                 for (Variable var : this){
37                         names[i] = var.getName();
38                         i++;
39                 }
40                 return names;
41         }       
42 }