Skip to content

Regex Mapping

avurro edited this page Apr 14, 2016 · 8 revisions

under construction

class Source1{

   List<String> customersIds;

   // getter and setter...
}

class Source2{

   Set<Integer> companyIds;

   // getter and setter...
}

class Source3{

   TreeSet<String> supplierIds;

   // getter and setter...
}

As you can see the fields have different structures, JMapper handles all implicitly.

class Destination{

   @JMap(".*ids$")
   List<Integer> ids;

   // getter and setter...
}

Xml configuration:

<jmapper>
  <class name="package.Destination">
    <attribute name="ids">
      <value name=".*ids$"/>
    </attribute>
  </class>
</jmapper>

API configuration:

...
import static com.googlecode.jmapper.api.JMapperAPI.*;
...

JMapperAPI jmapperAPI = new JMapperAPI()
    .add(mappedClass(Destination.class)
             .add(attribute("ids")
                     .value(".*ids$")));
Clone this wiki locally