<commit_before>package com.opengamma.financial.securities;

import java.util.HashMap;
import java.util.Map;

import com.opengamma.util.CompareUtils;

// REVIEW kirk 2009-09-15 -- This REALLY needs to be renamed.

public class Currency {
  private String _isoCode;

  private Currency(String isoCode) {
    _isoCode = isoCode;
  }
  
  public String getISOCode() {
    return _isoCode;
  }
  
  public static Map<String, Currency> s_instanceMap = new HashMap<String, Currency>();
  // is this even necessary or a good idea?  Probably should 
  public static Currency getInstance(String isoCode) {
    CompareUtils.checkForNull(isoCode);
    if (s_instanceMap.containsKey(isoCode)) {
      return s_instanceMap.get(isoCode);
    } else {
      Currency curr = new Currency(isoCode);
      s_instanceMap.put(isoCode, curr);
      return curr;
    }
  }
  
  // NOTE: This relies on the above getInstance pattern being used.  If that is ditched, get rid.
  public boolean equals(Object o) {
    if (!(o instanceof Currency)) {
      return false;
    }
    Currency curr = (Currency) o;
    return (curr == this); 
  }
  
  public int hashCode() {
    return _isoCode.hashCode();<commit_msg>A whole bunch of small changes to Currency, which I'm not happy with.<commit_after>package com.opengamma.financial.securities;

import java.util.HashMap;
import java.util.Map;

import com.opengamma.util.CompareUtils;

// REVIEW kirk 2009-09-15 -- This REALLY needs to be renamed.

// REVIEW kirk 2009-09-16 -- This needs to be worked out better for serialization.
// It's really not serialization clean, and everything at this level needs to be
// serialization friendly.

public class Currency {
  private String _isoCode;

  private Currency(String isoCode) {
    _isoCode = isoCode;
  }
  
  public String getISOCode() {
    return _isoCode;
  }
  
  public static Map<String, Currency> s_instanceMap = new HashMap<String, Currency>();
  // is this even necessary or a good idea?  Probably should 
  public static Currency getInstance(String isoCode) {
    // REVIEW kirk 2009-09-16 -- This is really not matching good practice:
    // - Will allow lower-case ISO codes
    // - Will allow ISO codes outside normal rules (e.g. 3-letter)
    // - Isn't even concurrency safe
    CompareUtils.checkForNull(isoCode);
    if (s_instanceMap.containsKey(isoCode)) {
      return s_instanceMap.get(isoCode);
    } else {
      Currency curr = new Currency(isoCode);
      s_instanceMap.put(isoCode, curr);
      return curr;
    }
  }
  
  // NOTE: This relies on the above getInstance pattern being used.  If that is ditched, get rid.
  public boolean equals(Object o) {
    return (this == o);
  }
  
  public int hashCode() {
    return _isoCode.hashCode();
{'fraction_non_alphanumeric': 0.0940576011666059, 'fraction_numerical': 0.012030623405030989, 'mean_word_length': 3.163884673748103, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '930895', 'n_tokens_mistral': 882, 'n_tokens_neox': 844, 'n_words': 272}