/* ----------------------------------------------------------------------------
* 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 MetadataMap extends java.util.AbstractMap<String, Metadata> {
private transient long swigCPtr;
protected transient boolean swigCMemOwn;
protected MetadataMap(long cPtr, boolean cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = cPtr;
}
protected static long getCPtr(MetadataMap obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
protected static long swigRelease(MetadataMap 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_MetadataMap(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 Metadata 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 Metadata put(String key, Metadata value) {
Iterator itr = find(key);
if (itr.isNot(end())) {
Metadata oldValue = itr.getValue();
itr.setValue(value);
return oldValue;
} else {
putUnchecked(key, value);
return null;
}
}
@Override
public Metadata remove(java.lang.Object key) {
if (!(key instanceof String)) {
return null;
}
Iterator itr = find((String) key);
if (itr.isNot(end())) {
Metadata oldValue = itr.getValue();
removeUnchecked(itr);
return oldValue;
} else {
return null;
}
}
@Override
public java.util.Set<Entry<String, Metadata>> entrySet() {
java.util.Set<Entry<String, Metadata>> setToReturn =
new java.util.HashSet<>();
Iterator itr = begin();
final Iterator end = end();
while (itr.isNot(end)) {
setToReturn.add(new Entry<String, Metadata>() {
private Iterator iterator;
private Entry<String, Metadata> init(Iterator iterator) {
this.iterator = iterator;
return this;
}
@Override
public String getKey() {
return iterator.getKey();
}
@Override
public Metadata getValue() {
return iterator.getValue();
}
@Override
public Metadata setValue(Metadata newValue) {
Metadata oldValue = iterator.getValue();
iterator.setValue(newValue);
return oldValue;
}
}.init(itr));
itr = itr.getNextUnchecked();
}
return setToReturn;
}
public MetadataMap() {
this(InscoperJNI.new_MetadataMap__SWIG_0(), true);
}
public MetadataMap(MetadataMap other) {
this(InscoperJNI.new_MetadataMap__SWIG_1(MetadataMap.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_MetadataMap_Iterator(swigCPtr);
}
swigCPtr = 0;
}
}
private MetadataMap.Iterator getNextUnchecked() {
return new MetadataMap.Iterator(InscoperJNI.MetadataMap_Iterator_getNextUnchecked(swigCPtr, this), true);
}
private boolean isNot(MetadataMap.Iterator other) {
return InscoperJNI.MetadataMap_Iterator_isNot(swigCPtr, this, MetadataMap.Iterator.getCPtr(other), other);
}
private String getKey() {
return InscoperJNI.MetadataMap_Iterator_getKey(swigCPtr, this);
}
private Metadata getValue() {
return new Metadata(InscoperJNI.MetadataMap_Iterator_getValue(swigCPtr, this), true);
}
private void setValue(Metadata newValue) {
InscoperJNI.MetadataMap_Iterator_setValue(swigCPtr, this, Metadata.getCPtr(newValue), newValue);
}
}
private boolean empty() {
return InscoperJNI.MetadataMap_empty(swigCPtr, this);
}
private void doClear() {
InscoperJNI.MetadataMap_doClear(swigCPtr, this);
}
private MetadataMap.Iterator find(String key) {
return new MetadataMap.Iterator(InscoperJNI.MetadataMap_find(swigCPtr, this, key), true);
}
private MetadataMap.Iterator begin() {
return new MetadataMap.Iterator(InscoperJNI.MetadataMap_begin(swigCPtr, this), true);
}
private MetadataMap.Iterator end() {
return new MetadataMap.Iterator(InscoperJNI.MetadataMap_end(swigCPtr, this), true);
}
private int sizeImpl() {
return InscoperJNI.MetadataMap_sizeImpl(swigCPtr, this);
}
private boolean containsImpl(String key) {
return InscoperJNI.MetadataMap_containsImpl(swigCPtr, this, key);
}
private void putUnchecked(String key, Metadata value) {
InscoperJNI.MetadataMap_putUnchecked(swigCPtr, this, key, Metadata.getCPtr(value), value);
}
private void removeUnchecked(MetadataMap.Iterator itr) {
InscoperJNI.MetadataMap_removeUnchecked(swigCPtr, this, MetadataMap.Iterator.getCPtr(itr), itr);
}
public void putBoolean(String key, boolean value) {
InscoperJNI.MetadataMap_putBoolean(swigCPtr, this, key, value);
}
public void putShort(String key, short value) {
InscoperJNI.MetadataMap_putShort(swigCPtr, this, key, value);
}
public void putInt(String key, int value) {
InscoperJNI.MetadataMap_putInt(swigCPtr, this, key, value);
}
public void putLong(String key, long value) {
InscoperJNI.MetadataMap_putLong(swigCPtr, this, key, value);
}
public void putFloat(String key, float value) {
InscoperJNI.MetadataMap_putFloat(swigCPtr, this, key, value);
}
public void putDouble(String key, double value) {
InscoperJNI.MetadataMap_putDouble(swigCPtr, this, key, value);
}
public void putString(String key, String value) {
InscoperJNI.MetadataMap_putString(swigCPtr, this, key, value);
}
public void putList(String key, MetadataList value) {
InscoperJNI.MetadataMap_putList(swigCPtr, this, key, MetadataList.getCPtr(value), value);
}
public void putMap(String key, MetadataMap value) {
InscoperJNI.MetadataMap_putMap(swigCPtr, this, key, MetadataMap.getCPtr(value), value);
}
public void putInstance(String key, Metadata value) {
InscoperJNI.MetadataMap_putInstance(swigCPtr, this, key, Metadata.getCPtr(value), value);
}
}