ElementOutputMapperExpander

Expands:


    $componentRoot.directory$/$artifactSubFolders$/$dataElement.packageName;format="toPath"$/mapper/$dataElement.name;format="firstToLower"$
  /$dataElement.name$OutputMapper.java

if:

dataElement.component.getOption('enableJaxrs').defined and
    dataElement.getOption('includeJaxrsConnector').defined and
    (dataElement.getOption('exposeGetEndpoint').defined or dataElement.getOption('exposeGetListEndpoint').defined)
property value
element type DataElement
qualified name net.democritus.expander.rest.control.mapper.ElementOutputMapperExpander
layer CONTROL_LAYER
technology JAXRS
sourceType JAVA
phase expansion
features  

Example

Some example of the content generated by the expander:

// expanded with nsx-expanders:4.16.3, expansionResource net.democritus:rest-expanders:2.4.2
package net.animals.mapper.cat;

import net.animals.CatDetails;
import net.animals.model.cat.CatOutputModel;

import net.animals.mapper.owner.OwnerReferenceMapper;

import net.democritus.sys.Context;
import net.democritus.sys.ParameterContext;

// @anchor:imports:start
// @anchor:imports:end
// anchor:custom-imports:start
import net.animals.mapper.catBreed.CatBreedOutputMapper;
import net.animals.url.CatBreedUrlBuilder;
// anchor:custom-imports:end

public class CatOutputMapper {

  // @anchor:fields:start
  // @anchor:fields:end
  // anchor:custom-fields:start
  // anchor:custom-fields:end

  public CatOutputModel toExternal(ParameterContext<CatDetails> inputModelParameter) {
    final Context context = inputModelParameter.getContext();
    final CatDetails inputModel = inputModelParameter.getValue();

    if (inputModel == null) {
      return null;
    }

    CatOutputModel model = new CatOutputModel();
    model.setName(inputModel.getName());
    model.setUuid(inputModel.getUuid());
    model.setOwner(new OwnerReferenceMapper().refToExternal(
        context.withParameter(inputModel.getOwner())));
    // @anchor:mapping:start
    // @anchor:mapping:end
    // anchor:custom-mapping:start
    model.setBreed(new CatBreedOutputMapper().toExternal(inputModelParameter.construct(inputModel.getBreedDetails())));
    if (inputModel.getBreedDetails() != null) {
      model.getBreed().setResourceUri(CatBreedUrlBuilder.resource(context)
          .setCatBreedId(inputModel.getBreedDetails().getName()).build());
    }
    // anchor:custom-mapping:end

    return model;
  }

  // @anchor:methods:start
  // @anchor:methods:end
  // anchor:custom-methods:start
  // anchor:custom-methods:end

}