Skip to content

InscoperAPI/Build/Java/com.inscoper.api/com/inscoper/api/StringBoolMap.java

Packages

Name
com.inscoper.api

Classes

Name
class com.inscoper.api.StringBoolMap

Source code

/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (https://www.swig.org).
 * Version 4.3.1
 *
 * Do not make changes to this file unless you know what you are doing - modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- */

package com.inscoper.api;
import com.inscoper.api.logging.*;

public class StringBoolMap extends java.util.AbstractMap<String, Boolean> {
  private transient long swigCPtr;
  protected transient boolean swigCMemOwn;

  protected StringBoolMap(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  protected static long getCPtr(StringBoolMap obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected static long swigRelease(StringBoolMap obj) {
    long ptr = 0;
    if (obj != null) {
      if (!obj.swigCMemOwn)
        throw new RuntimeException("Cannot release ownership as memory is not owned");
      ptr = obj.swigCPtr;
      obj.swigCMemOwn = false;
      obj.delete();
    }
    return ptr;
  }

  @SuppressWarnings({"deprecation", "removal"})
  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        InscoperJNI.delete_StringBoolMap(swigCPtr);
      }
      swigCPtr = 0;
    }
  }


  @Override
  public int size() {
    return sizeImpl();
  }

  @Override
  public boolean isEmpty() {
    return empty();
  }

  @Override
  public void clear() {
    doClear();
  }

  @Override
  public boolean containsKey(java.lang.Object key) {
    if (!(key instanceof String)) {
      return false;
    }

    return containsImpl((String)key);
  }

  @Override
  public Boolean get(java.lang.Object key) {
    if (!(key instanceof String)) {
      return null;
    }

    Iterator itr = find((String) key);
    if (itr.isNot(end())) {
      return itr.getValue();
    }

    return null;
  }

  @Override
  public Boolean put(String key, Boolean value) {
    Iterator itr = find(key);
    if (itr.isNot(end())) {
      Boolean oldValue = itr.getValue();
      itr.setValue(value);
      return oldValue;
    } else {
      putUnchecked(key, value);
      return null;
    }
  }

  @Override
  public Boolean remove(java.lang.Object key) {
    if (!(key instanceof String)) {
      return null;
    }

    Iterator itr = find((String) key);
    if (itr.isNot(end())) {
      Boolean oldValue = itr.getValue();
      removeUnchecked(itr);
      return oldValue;
    } else {
      return null;
    }
  }

  @Override
  public java.util.Set<Entry<String, Boolean>> entrySet() {
    java.util.Set<Entry<String, Boolean>> setToReturn =
        new java.util.HashSet<>();

    Iterator itr = begin();
    final Iterator end = end();
    while (itr.isNot(end)) {
      setToReturn.add(new Entry<String, Boolean>() {
        private Iterator iterator;

        private Entry<String, Boolean> init(Iterator iterator) {
          this.iterator = iterator;
          return this;
        }

        @Override
        public String getKey() {
          return iterator.getKey();
        }

        @Override
        public Boolean getValue() {
          return iterator.getValue();
        }

        @Override
        public Boolean setValue(Boolean newValue) {
          Boolean oldValue = iterator.getValue();
          iterator.setValue(newValue);
          return oldValue;
        }
      }.init(itr));
      itr = itr.getNextUnchecked();
    }

    return setToReturn;
  }

  public StringBoolMap() {
    this(InscoperJNI.new_StringBoolMap__SWIG_0(), true);
  }

  public StringBoolMap(StringBoolMap other) {
    this(InscoperJNI.new_StringBoolMap__SWIG_1(StringBoolMap.getCPtr(other), other), true);
  }

  static protected class Iterator {
    private transient long swigCPtr;
    protected transient boolean swigCMemOwn;

    protected Iterator(long cPtr, boolean cMemoryOwn) {
      swigCMemOwn = cMemoryOwn;
      swigCPtr = cPtr;
    }

    protected static long getCPtr(Iterator obj) {
      return (obj == null) ? 0 : obj.swigCPtr;
    }

    protected static long swigRelease(Iterator obj) {
      long ptr = 0;
      if (obj != null) {
        if (!obj.swigCMemOwn)
          throw new RuntimeException("Cannot release ownership as memory is not owned");
        ptr = obj.swigCPtr;
        obj.swigCMemOwn = false;
        obj.delete();
      }
      return ptr;
    }

    @SuppressWarnings({"deprecation", "removal"})
    protected void finalize() {
      delete();
    }

    public synchronized void delete() {
      if (swigCPtr != 0) {
        if (swigCMemOwn) {
          swigCMemOwn = false;
          InscoperJNI.delete_StringBoolMap_Iterator(swigCPtr);
        }
        swigCPtr = 0;
      }
    }

    private StringBoolMap.Iterator getNextUnchecked() {
      return new StringBoolMap.Iterator(InscoperJNI.StringBoolMap_Iterator_getNextUnchecked(swigCPtr, this), true);
    }

    private boolean isNot(StringBoolMap.Iterator other) {
      return InscoperJNI.StringBoolMap_Iterator_isNot(swigCPtr, this, StringBoolMap.Iterator.getCPtr(other), other);
    }

    private String getKey() {
      return InscoperJNI.StringBoolMap_Iterator_getKey(swigCPtr, this);
    }

    private boolean getValue() {
      return InscoperJNI.StringBoolMap_Iterator_getValue(swigCPtr, this);
    }

    private void setValue(boolean newValue) {
      InscoperJNI.StringBoolMap_Iterator_setValue(swigCPtr, this, newValue);
    }

  }

  private boolean empty() {
    return InscoperJNI.StringBoolMap_empty(swigCPtr, this);
  }

  private void doClear() {
    InscoperJNI.StringBoolMap_doClear(swigCPtr, this);
  }

  private StringBoolMap.Iterator find(String key) {
    return new StringBoolMap.Iterator(InscoperJNI.StringBoolMap_find(swigCPtr, this, key), true);
  }

  private StringBoolMap.Iterator begin() {
    return new StringBoolMap.Iterator(InscoperJNI.StringBoolMap_begin(swigCPtr, this), true);
  }

  private StringBoolMap.Iterator end() {
    return new StringBoolMap.Iterator(InscoperJNI.StringBoolMap_end(swigCPtr, this), true);
  }

  private int sizeImpl() {
    return InscoperJNI.StringBoolMap_sizeImpl(swigCPtr, this);
  }

  private boolean containsImpl(String key) {
    return InscoperJNI.StringBoolMap_containsImpl(swigCPtr, this, key);
  }

  private void putUnchecked(String key, boolean value) {
    InscoperJNI.StringBoolMap_putUnchecked(swigCPtr, this, key, value);
  }

  private void removeUnchecked(StringBoolMap.Iterator itr) {
    InscoperJNI.StringBoolMap_removeUnchecked(swigCPtr, this, StringBoolMap.Iterator.getCPtr(itr), itr);
  }

}

Updated on 2026-09-03 at 12:14:19 +0200