title: Scala | How can this code be put into a macro annotation?
body: <p>I have many wrapper classes which all they do is add type safety plus formatting. Besides the ClassName, each wrapper class is essentially the same.</p>
  <pre><code>import com.helpers.buildFormatter
  import spray.json.JsonFormat
  
  final case class ClassName(value: String)
  
  object ClassName {
    implicit val jsonFormatter: JsonFormat[ClassName] =
      buildFormatter[ClassName](&quot;ClassName&quot;, _.value, this.apply)
  }
  </code></pre>
  <p>Is there a way to shorten this further? I'm wondering if an annotation, macro, or inheritance might work.</p>
  <p>EDIT: <code>buildFormatter</code> provides custom json parsing which is why I'd like to keep it in the resulting answer</p>
  <pre class="lang-scala prettyprint-override"><code>def buildStringFormatter[A](className: String, serializer: A =&gt; String, deserializer: String =&gt; A): JsonFormat[A]
  </code></pre>
  <p><em>From comments:</em>
  Q: Will wrapper case classes always be single-parameter, will parameter type always be <code>String</code>, will parameter name always be <code>value</code>?
  A: You are correct, there would only be 1 parameter and the parameter name be <code>value</code>. I'm fine with restricting those restrictions</p>