com.legstar.jaxb.generator.jaxb.wrappers.factory.class.hbs Maven / Gradle / Ivy
{{#if target_package_name}}package {{target_package_name}};{{/if}}
import com.legstar.base.type.composite.CobolComplexType;
{{~#each choice_types}}
{{~#if @first}}
import com.legstar.base.visitor.InvalidChoiceAlternativeException;
import com.legstar.base.visitor.NoAlternativeForChoiceException;
{{~/if}}
{{~/each}}{{!-- choice_types --}}
import com.legstar.base.visitor.InvalidComplexTypeFieldIndexException;
import com.legstar.base.visitor.InvalidComplexTypeNameException;
import com.legstar.jaxb.converter.JaxbWrapper;
import com.legstar.jaxb.converter.JaxbWrapperFactory;
public class {{class_name}} implements JaxbWrapperFactory {
public JaxbWrapper> create(CobolComplexType type) {
{{~#each complex_types}}
if ("{{@key}}".equals(type.getName())) {
return new {{@key}}JaxbWrapper();
}
{{~/each}}{{!-- complex_types --}}
throw new InvalidComplexTypeNameException(type.getName());
}
public JaxbWrapper < ? > create(CobolComplexType type, Object jaxb) {
{{~#each complex_types}}
if ("{{@key}}".equals(type.getName())) {
return new {{@key}}JaxbWrapper(({{#if jaxb_package_name}}{{jaxb_package_name}}.{{/if}}{{@key}}) jaxb);
}
{{~/each}}{{!-- complex_types --}}
throw new InvalidComplexTypeNameException(type.getName());
}
{{#each complex_types}}
public class {{@key}}JaxbWrapper extends JaxbWrapper<{{#if jaxb_package_name}}{{jaxb_package_name}}.{{/if}}{{@key}}> {
public {{@key}}JaxbWrapper() {
this(new {{#if jaxb_package_name}}{{jaxb_package_name}}.{{/if}}{{@key}}());
}
public {{@key}}JaxbWrapper({{#if jaxb_package_name}}{{jaxb_package_name}}.{{/if}}{{@key}} jaxb) {
super(jaxb);
}
public void set(int index, Object value, int alternativeIndex) {
switch (index) {
{{~#each this}}
{{> com/legstar/jaxb/generator/jaxb.wrappers.factory.field.set}}
{{~/each}}{{!-- this: fields in complex type --}}
default:
throw new InvalidComplexTypeFieldIndexException("{{@key}}", index);
}
}
public Object get(int index) {
switch (index) {
{{~#each this}}
{{> com/legstar/jaxb/generator/jaxb.wrappers.factory.field.get}}
{{~/each}}{{!-- this: fields in complex type --}}
default:
throw new InvalidComplexTypeFieldIndexException("{{@key}}", index);
}
}
@Override
public String toString() {
if (getJaxb() == null) {
return "{}";
}
StringBuilder builder = new StringBuilder();
builder.append("{");
{{~#each this}}
{{> com/legstar/jaxb/generator/jaxb.wrappers.factory.field.tostring}}
{{~/each}}{{!-- this: fields in complex type --}}
builder.append("}");
return builder.toString();
}
}
{{/each}}{{!-- complex_types --}}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy