title: In Spring, how do I create a POJO with a default value from configuration?
body: <p>I am using the Spring framework to with a properties file that has the key:</p>
  
  <pre><code>empty.value = -
  </code></pre>
  
  <p>I would like to be able to create a POJO that would have that empty value as its default value for the default constructor of the POJO. Something like this:</p>
  
  <pre><code>public class Dog {
  
      private String name;
  
      public Dog(){
      }
  
      public Dog(String name){
          this.name = name;
      }
  }
  </code></pre>
  
  <p>So that if <code>Dog d = new Dog()</code> is called, <code>d.name</code> will be <code>-</code> from the <code>empty.value</code> key.</p>
  
  <p>Autowiring the <code>name</code> variable will just be <code>null</code> because Spring isn't aware of the POJO as well as using <code>@Value("${empty.value}")</code>.</p>
  
  <p>What would be the best way of achieving this?</p>
  
  <p><strong>Edit</strong>: To clarify, there are meant to be many <code>Dog</code>s throughout the system and I need to be able to initialize them on request.</p>
  
  <p><strong>Edit 2</strong>: Consider the following use case- I have an interface containing a method:</p>
  
  <pre><code>Dog transform(List&lt;String&gt; animals);
  </code></pre>
  
  <p>I would like to be able to know that whatever <code>Dog</code> is returned from the transform method has either <code>-</code> (configurable) as a <code>name</code> or a different value passed in to the constructor when created (or setter, later). I would like to ensure that for whatever <code>transform</code> does in any implementation, even if it fails, I will have a valid <code>Dog</code> with a <code>name</code> as mentioned.</p>