3

When using the cxf-xjc-ts plugin during xsdtojava, one can add the property <extensionArg>-Xts</extensionArg> to let the compiler generate the following method:

import org.apache.commons.lang.builder.ToStringBuilder;

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, JAXBToStringStyle.DEFAULT_STYLE);
    }

Problem: when having apache.commons-lang3 on classpath only, the package should be: org.apache.commons.lang3.builder.ToStringBuilder and using org.apache.commons.lang3.builder.DEFAULT_STYLE.

Question: how can I tell the -ts plugin to actually use the builder from lang3 during generation?

membersound
  • 81,582
  • 193
  • 585
  • 1,120

2 Answers2

2

This has been fixed in v3.1.0 @see https://issues.apache.org/jira/browse/CXFXJC-16

So now -Xts option is using lang3.

membersound
  • 81,582
  • 193
  • 585
  • 1,120
1

I'd like to propose to use a bit different approach.

It includes 2 steps to do:

  • omit generating default 'toString' methods by xjc plugin - hence it won't use commons-lang (without 3) 'ToStringBuilder',

  • use commons-lang3 'ToStringBuilder.reflectionToString' directly where 'toString' is needed.

(during development i've faced undesired usage of 'commons-lang' and my approach provides possibility to skip using 'commons-lang' along with 'commons-lang3').

nndru
  • 2,057
  • 21
  • 16