![JAR search and dependency download from the Maven repository](/logo.png)
com.nutanix.dp1.aio.models.AioAbstractBoundedMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aiops-java-client Show documentation
Show all versions of aiops-java-client Show documentation
Manage infrastructure on-premises and in the cloud seamlessly through AIOps features such as Analysis, Reporting, Capacity Planning, What if Analysis, VM Rightsizing, Troubleshooting, App Discovery, Broad Observability, and Ops Automation through Playbooks.
The newest version!
package com.nutanix.dp1.aio.models;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@SuppressWarnings({"unused", "SameParameterValue"})
@Slf4j
@Data
public abstract class AioAbstractBoundedMap {
@Setter(AccessLevel.NONE)
@Getter(AccessLevel.NONE)
protected Map boundedMap;
@JsonIgnore
protected final Class valueClass;
@JsonIgnore
@Setter(AccessLevel.NONE)
@Getter(AccessLevel.NONE)
protected Map unknownKeysMap = new LinkedHashMap<>();
protected AioAbstractBoundedMap(Class valueClass) {
this.valueClass = valueClass;
}
public T get(String key) {
if(key == null || boundedMap == null || !boundedMap.containsKey(key)) {
log.debug("Null or invalid key {} ", key);
throw new IllegalArgumentException("key:" + key + " not recognized");
}
return boundedMap.get(key);
}
public void put(String key, T value) {
if(boundedMap == null) {
throw new IllegalStateException("BoundedMap is not initialized");
}
if(key == null) {
throw new IllegalArgumentException("Null key is not supported");
}
if(!boundedMap.containsKey(key)) {
log.debug("Putting unrecognized key {} into unknown map", key);
unknownKeysMap.put(key, value);
return;
}
boundedMap.replace(key, value);
}
@JsonIgnore
public Set getKeys() {
return boundedMap.keySet();
}
protected final void init(List allowedKeys, T defaultValue) {
if(boundedMap == null) {
boundedMap = new LinkedHashMap<>();
allowedKeys.forEach(k -> boundedMap.put(k, defaultValue));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy