class ContainerAttribute {

  public boolean insert(T key, ContainerID value) throws SCMException {
    Preconditions.checkNotNull(key);
    Preconditions.checkNotNull(value);

    if (attributeMap.containsKey(key)) {
      if (attributeMap.get(key).add(value)) {
        return true; //we inserted the value as it doesn’t exist in the set.
      } else { // Failure indicates that this ContainerID exists in the Set
        if (!attributeMap.get(key).remove(value)) {
          LOG.error("Failure to remove the object from the Map.Key:{}, " +
              "ContainerID: {}", key, value);
          throw new SCMException("Failure to remove the object from the Map",
              FAILED_TO_CHANGE_CONTAINER_STATE);
        }
        attributeMap.get(key).add(value);
        return true;
      }
    } else {
      // This key does not exist, we need to allocate this key in the map.
      // TODO: Replace TreeSet with FoldedTreeSet from HDFS Utils.
      // Skipping for now, since FoldedTreeSet does not have implementations
      // for headSet and TailSet. We need those calls.
      this.attributeMap.put(key, new TreeSet<>());
      // This should not fail, we just allocated this object.
      attributeMap.get(key).add(value);
      return true;
    }
  }

  public  ContainerAttribute(Map<T, NavigableSet<ContainerID>> attributeMap);
  public  ContainerAttribute();

}