All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.reprezen.genflow.openapi3.doc.OptionHelper Maven / Gradle / Ivy

package com.reprezen.genflow.openapi3.doc;

import com.reprezen.genflow.api.target.ParameterUtils;
import com.reprezen.genflow.api.template.IGenTemplateContext;
import com.reprezen.genflow.openapi3.doc.Helper;
import com.reprezen.genflow.openapi3.doc.HelperHelper;
import com.reprezen.genflow.openapi3.doc.XOpenApi3DocGenTemplate;
import java.util.function.Function;
import org.eclipse.xtext.xbase.lib.Extension;

@SuppressWarnings("all")
public class OptionHelper implements Helper {
  @Extension
  private ParameterUtils paramUtils;
  
  @Override
  public void init() {
    IGenTemplateContext _context = HelperHelper.getContext();
    ParameterUtils _parameterUtils = new ParameterUtils(_context);
    this.paramUtils = _parameterUtils;
  }
  
  public final static String URL_PREFIX_PARAM = "urlPrefix";
  
  public final static String ANCHOR_NAME_PARAM = "anchorName";
  
  public final static String PREVIEW_PARAM = "preview";
  
  public final static String HTML_INJECTIONS_PARAM = "htmlInjections";
  
  public String getUrlPrefix() {
    final Function _function = (ParameterUtils.Parameter it) -> {
      return it.asString();
    };
    return this.paramUtils.getParameter(OptionHelper.URL_PREFIX_PARAM).map(_function).orElse(null);
  }
  
  public String getAnchorName() {
    final Function _function = (ParameterUtils.Parameter it) -> {
      return it.asString();
    };
    return this.paramUtils.getParameter(OptionHelper.ANCHOR_NAME_PARAM).map(_function).orElse(null);
  }
  
  public Boolean isPreview() {
    Boolean _elvis = null;
    final Function _function = (ParameterUtils.Parameter it) -> {
      return it.asBoolean();
    };
    Boolean _orElse = this.paramUtils.getParameter(OptionHelper.PREVIEW_PARAM).map(_function).orElse(null);
    if (_orElse != null) {
      _elvis = _orElse;
    } else {
      _elvis = Boolean.valueOf(false);
    }
    return _elvis;
  }
  
  public Boolean isShowComponentModels() {
    Boolean _elvis = null;
    final Function _function = (ParameterUtils.Parameter it) -> {
      return it.asBoolean();
    };
    Boolean _orElse = this.paramUtils.getParameter(XOpenApi3DocGenTemplate.SHOW_ALL_OF_COMPONENTS_OPTION).map(_function).orElse(null);
    if (_orElse != null) {
      _elvis = _orElse;
    } else {
      _elvis = Boolean.valueOf(true);
    }
    return _elvis;
  }
  
  public Boolean isIncludeTOC() {
    Boolean _elvis = null;
    final Function _function = (ParameterUtils.Parameter it) -> {
      return it.asBoolean();
    };
    Boolean _orElse = this.paramUtils.getParameter(XOpenApi3DocGenTemplate.INCLUDE_TABLE_OF_CONTENTS_OPTION).map(_function).orElse(null);
    if (_orElse != null) {
      _elvis = _orElse;
    } else {
      _elvis = Boolean.valueOf(true);
    }
    return _elvis;
  }
  
  public Object getHtmlInjections() {
    final Function _function = (ParameterUtils.Parameter it) -> {
      return it.asObject();
    };
    return this.paramUtils.getParameter(OptionHelper.HTML_INJECTIONS_PARAM).map(_function).orElse(null);
  }
}