All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.snapscript.tree.variable.VariableKey Maven / Gradle / Ivy

There is a newer version: 1.4.6
Show newest version
package org.snapscript.tree.variable;

import org.snapscript.core.Type;

public class VariableKey {

   private final String name;
   private final Type type;
   
   public VariableKey(String name, Type type) {
      this.name = name;
      this.type = type;
   }
   
   @Override
   public boolean equals(Object key) {
      if(key instanceof VariableKey) {
         return equals((VariableKey)key);
      }
      return false;
   }
   
   public boolean equals(VariableKey key) {
      if(key.type != type) {
         return false;
      }
      return key.name.equals(name);
   }
   
   @Override
   public int hashCode() {
      int hash = name.hashCode();
      
      if(type != null) {
         return 31 * hash+type.hashCode();
      }
      return hash;
   }
   
   @Override
   public String toString() {
      return name;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy