io.tracee.contextlogger.outputgenerator.InstanceToOutputElementPool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of contextlogger-core Show documentation
Show all versions of contextlogger-core Show documentation
Please refer to https://github.com/tracee/contextlogger.
package io.tracee.contextlogger.outputgenerator;
import java.util.HashMap;
import java.util.Map;
import io.tracee.contextlogger.outputgenerator.outputelements.OutputElement;
/**
* Class to handle deserialization state of instances. This is used to prevent cycles.
*/
public class InstanceToOutputElementPool {
class ProxyOutput {
}
private Map instanceIdToOutputElementMap = new HashMap();
public void add(OutputElement outputElement) {
if (outputElement.getEncapsulatedInstance() != null) {
instanceIdToOutputElementMap.put(outputElement.getIdentityHashCode(), outputElement);
}
}
public boolean isInstanceMarkedAsProcessed(OutputElement outputElement) {
if (outputElement != null && outputElement.getEncapsulatedInstance() != null) {
return instanceIdToOutputElementMap.containsKey(outputElement.getIdentityHashCode());
}
return false;
}
public OutputElement getOutputElement(OutputElement outputElement) {
if (outputElement != null && outputElement.getEncapsulatedInstance() != null) {
return instanceIdToOutputElementMap.get(outputElement.getIdentityHashCode());
}
return null;
}
}