All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.distkv.core.concepts.DistkvSetsImpl Maven / Gradle / Ivy

The newest version!
package com.distkv.core.concepts;

import com.distkv.common.exception.KeyNotFoundException;
import com.distkv.common.utils.Status;
import java.util.Set;

public class DistkvSetsImpl extends DistkvConcepts> implements DistkvSets {

  public DistkvSetsImpl() {
  }

  @Override
  public void putItem(String key, String itemValue) {
    if (!distkvKeyValueMap.containsKey(key)) {
      throw new KeyNotFoundException(key);
    }

    distkvKeyValueMap.get(key).add(itemValue);
  }

  @Override
  public Status removeItem(String key, String itemValue) {
    if (!distkvKeyValueMap.containsKey(key)) {
      return Status.KEY_NOT_FOUND;
    }

    distkvKeyValueMap.get(key).remove(itemValue);
    return Status.OK;
  }

  @Override
  public boolean exists(String key, String value) throws KeyNotFoundException {
    if (!distkvKeyValueMap.containsKey(key)) {
      throw new KeyNotFoundException(key);
    }

    return distkvKeyValueMap.get(key).contains(value);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy