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

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

package com.reprezen.genflow.openapi3.doc;

import com.reprezen.genflow.openapi3.doc.BadReferenceException;
import com.reprezen.genflow.openapi3.doc.Helper;
import com.reprezen.kaizen.oasparser.model3.Parameter;
import com.reprezen.kaizen.oasparser.model3.Response;
import com.reprezen.kaizen.oasparser.model3.Schema;
import java.util.Arrays;
import org.eclipse.xtext.xbase.lib.Exceptions;

@SuppressWarnings("all")
public class RefHelper implements Helper {
  @Override
  public void init() {
  }
  
  protected Object _resolve(final Object obj) {
    Object _switchResult = null;
    boolean _matched = false;
    if (!_matched) {
      _switchResult = obj;
    }
    return _switchResult;
  }
  
  protected Object _safeResolve(final Object obj) {
    Object _xtrycatchfinallyexpression = null;
    try {
      _xtrycatchfinallyexpression = this.resolve(obj);
    } catch (final Throwable _t) {
      if (_t instanceof BadReferenceException) {
        _xtrycatchfinallyexpression = obj;
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
    return _xtrycatchfinallyexpression;
  }
  
  protected Object _resolve(final Parameter param) {
    return param;
  }
  
  protected Object _safeResolve(final Parameter param) {
    return param;
  }
  
  protected Object _resolve(final Schema model) {
    return model;
  }
  
  protected Object _safeResolve(final Schema model) {
    return model;
  }
  
  protected Object _resolve(final Response response) {
    return response;
  }
  
  protected Object _safeResolve(final Response response) {
    return response;
  }
  
  public Object resolve(final Object param) {
    if (param instanceof Parameter) {
      return _resolve((Parameter)param);
    } else if (param instanceof Response) {
      return _resolve((Response)param);
    } else if (param instanceof Schema) {
      return _resolve((Schema)param);
    } else if (param != null) {
      return _resolve(param);
    } else {
      throw new IllegalArgumentException("Unhandled parameter types: " +
        Arrays.asList(param).toString());
    }
  }
  
  public Object safeResolve(final Object param) {
    if (param instanceof Parameter) {
      return _safeResolve((Parameter)param);
    } else if (param instanceof Response) {
      return _safeResolve((Response)param);
    } else if (param instanceof Schema) {
      return _safeResolve((Schema)param);
    } else if (param != null) {
      return _safeResolve(param);
    } else {
      throw new IllegalArgumentException("Unhandled parameter types: " +
        Arrays.asList(param).toString());
    }
  }
}