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

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

package com.reprezen.genflow.openapi3.doc;

import com.reprezen.genflow.openapi3.doc.Activation;
import com.reprezen.genflow.openapi3.doc.Helper;
import com.reprezen.genflow.openapi3.doc.RecursiveRenderException;
import java.util.IdentityHashMap;
import java.util.Map;
import org.eclipse.xtext.xbase.lib.Exceptions;

@SuppressWarnings("all")
public class RecursionHelper implements Helper {
  @Override
  public void init() {
  }
  
  private final Map activeObjects = new IdentityHashMap();
  
  public Activation use(final Object obj) {
    try {
      Activation _xifexpression = null;
      boolean _containsKey = this.activeObjects.containsKey(obj);
      if (_containsKey) {
        throw new RecursiveRenderException(obj);
      } else {
        _xifexpression = new Activation(obj, this);
      }
      return _xifexpression;
    } catch (Throwable _e) {
      throw Exceptions.sneakyThrow(_e);
    }
  }
  
  public Void activate(final Object obj) {
    return this.activeObjects.put(obj, null);
  }
  
  public Void deactivate(final Object obj) {
    return this.activeObjects.remove(obj);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy