title: Two constructors that do different things but take the same data type
body: <p>I have recently ran into this problem with my <code>MorseString</code> class. I have two different constructors that do different things, but take the same data type:</p>
  
  <pre><code>/*
   * Constructor that takes the Morse Code as a String as a parameter
   */
  
  public MorseString(String s) {
      if(!isValidMorse(s)) {
          throw new IllegalArgumentException("s is not a valid Morse Code");
      }
      // ...
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>/*
   * Constructor that takes the String as a parameter and converts it to Morse Code
   */
  
  public MorseString(String s) {
      // ...
  }
  </code></pre>
  
  <p>I came up with this solution:</p>
  
  <pre><code>public MorseString(String s, ParameterType type) {
      if(type == ParameterType.CODE) {
          if(!isValidMorse(s)) {
              throw new IllegalArgumentException("s is not a valid Morse Code");
          }
          // Constructor that takes Morse
      } else {
          // Constructor that takes String
      }
  }
  </code></pre>
  
  <p>But it looks ugly. Any other solutions?</p>