Tabnine Logo
KeyValueEvent
Code IndexAdd Tabnine to your IDE (free)

How to use
KeyValueEvent
in
org.springframework.data.keyvalue.core.event

Best Java code snippets using org.springframework.data.keyvalue.core.event.KeyValueEvent (Showing top 15 results out of 315)

origin: spring-projects/spring-data-keyvalue

@Override
public <T> T delete(Object id, Class<T> type) {
  Assert.notNull(id, "Id for object to be deleted must not be null!");
  Assert.notNull(type, "Type to delete must not be null!");
  String keyspace = resolveKeySpace(type);
  potentiallyPublishEvent(KeyValueEvent.beforeDelete(id, keyspace, type));
  T result = execute(adapter -> adapter.delete(id, keyspace, type));
  potentiallyPublishEvent(KeyValueEvent.afterDelete(id, keyspace, type, result));
  return result;
}
origin: apache/servicemix-bundles

@Override
public void delete(Class<?> type) {
  Assert.notNull(type, "Type to delete must not be null!");
  String keyspace = resolveKeySpace(type);
  potentiallyPublishEvent(KeyValueEvent.beforeDropKeySpace(keyspace, type));
  execute((KeyValueCallback<Void>) adapter -> {
    adapter.deleteAllOf(keyspace);
    return null;
  });
  potentiallyPublishEvent(KeyValueEvent.afterDropKeySpace(keyspace, type));
}
origin: spring-projects/spring-data-keyvalue

@Override
public <T> T update(Object id, T objectToUpdate) {
  Assert.notNull(id, "Id for object to be inserted must not be null!");
  Assert.notNull(objectToUpdate, "Object to be updated must not be null!");
  String keyspace = resolveKeySpace(objectToUpdate.getClass());
  potentiallyPublishEvent(KeyValueEvent.beforeUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate));
  Object existing = execute(adapter -> adapter.put(id, objectToUpdate, keyspace));
  potentiallyPublishEvent(
      KeyValueEvent.afterUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate, existing));
  return objectToUpdate;
}
origin: org.springframework.data/spring-data-keyvalue

@Override
public <T> Optional<T> findById(Object id, Class<T> type) {
  Assert.notNull(id, "Id for object to be inserted must not be null!");
  Assert.notNull(type, "Type to fetch must not be null!");
  String keyspace = resolveKeySpace(type);
  potentiallyPublishEvent(KeyValueEvent.beforeGet(id, keyspace, type));
  T result = execute(adapter -> {
    Object value = adapter.get(id, keyspace, type);
    if (value == null || typeCheck(type, value)) {
      return type.cast(value);
    }
    return null;
  });
  potentiallyPublishEvent(KeyValueEvent.afterGet(id, keyspace, type, result));
  return Optional.ofNullable(result);
}
origin: apache/servicemix-bundles

@Override
public <T> T insert(Object id, T objectToInsert) {
  Assert.notNull(id, "Id for object to be inserted must not be null!");
  Assert.notNull(objectToInsert, "Object to be inserted must not be null!");
  String keyspace = resolveKeySpace(objectToInsert.getClass());
  potentiallyPublishEvent(KeyValueEvent.beforeInsert(id, keyspace, objectToInsert.getClass(), objectToInsert));
  execute((KeyValueCallback<Void>) adapter -> {
    if (adapter.contains(id, keyspace)) {
      throw new DuplicateKeyException(
          String.format("Cannot insert existing object with id %s!. Please use update.", id));
    }
    adapter.put(id, objectToInsert, keyspace);
    return null;
  });
  potentiallyPublishEvent(KeyValueEvent.afterInsert(id, keyspace, objectToInsert.getClass(), objectToInsert));
  return objectToInsert;
}
origin: spring-projects/spring-data-keyvalue

@Override
public <T> Optional<T> findById(Object id, Class<T> type) {
  Assert.notNull(id, "Id for object to be inserted must not be null!");
  Assert.notNull(type, "Type to fetch must not be null!");
  String keyspace = resolveKeySpace(type);
  potentiallyPublishEvent(KeyValueEvent.beforeGet(id, keyspace, type));
  T result = execute(adapter -> {
    Object value = adapter.get(id, keyspace, type);
    if (value == null || typeCheck(type, value)) {
      return type.cast(value);
    }
    return null;
  });
  potentiallyPublishEvent(KeyValueEvent.afterGet(id, keyspace, type, result));
  return Optional.ofNullable(result);
}
origin: spring-projects/spring-data-keyvalue

@Override
public <T> T insert(Object id, T objectToInsert) {
  Assert.notNull(id, "Id for object to be inserted must not be null!");
  Assert.notNull(objectToInsert, "Object to be inserted must not be null!");
  String keyspace = resolveKeySpace(objectToInsert.getClass());
  potentiallyPublishEvent(KeyValueEvent.beforeInsert(id, keyspace, objectToInsert.getClass(), objectToInsert));
  execute((KeyValueCallback<Void>) adapter -> {
    if (adapter.contains(id, keyspace)) {
      throw new DuplicateKeyException(
          String.format("Cannot insert existing object with id %s!. Please use update.", id));
    }
    adapter.put(id, objectToInsert, keyspace);
    return null;
  });
  potentiallyPublishEvent(KeyValueEvent.afterInsert(id, keyspace, objectToInsert.getClass(), objectToInsert));
  return objectToInsert;
}
origin: spring-projects/spring-data-keyvalue

@Override
public void delete(Class<?> type) {
  Assert.notNull(type, "Type to delete must not be null!");
  String keyspace = resolveKeySpace(type);
  potentiallyPublishEvent(KeyValueEvent.beforeDropKeySpace(keyspace, type));
  execute((KeyValueCallback<Void>) adapter -> {
    adapter.deleteAllOf(keyspace);
    return null;
  });
  potentiallyPublishEvent(KeyValueEvent.afterDropKeySpace(keyspace, type));
}
origin: apache/servicemix-bundles

@Override
public <T> T update(Object id, T objectToUpdate) {
  Assert.notNull(id, "Id for object to be inserted must not be null!");
  Assert.notNull(objectToUpdate, "Object to be updated must not be null!");
  String keyspace = resolveKeySpace(objectToUpdate.getClass());
  potentiallyPublishEvent(KeyValueEvent.beforeUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate));
  Object existing = execute(adapter -> adapter.put(id, objectToUpdate, keyspace));
  potentiallyPublishEvent(
      KeyValueEvent.afterUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate, existing));
  return objectToUpdate;
}
origin: org.springframework.data/spring-data-keyvalue

@Override
public <T> T delete(Object id, Class<T> type) {
  Assert.notNull(id, "Id for object to be deleted must not be null!");
  Assert.notNull(type, "Type to delete must not be null!");
  String keyspace = resolveKeySpace(type);
  potentiallyPublishEvent(KeyValueEvent.beforeDelete(id, keyspace, type));
  T result = execute(adapter -> adapter.delete(id, keyspace, type));
  potentiallyPublishEvent(KeyValueEvent.afterDelete(id, keyspace, type, result));
  return result;
}
origin: apache/servicemix-bundles

@Override
public <T> Optional<T> findById(Object id, Class<T> type) {
  Assert.notNull(id, "Id for object to be inserted must not be null!");
  Assert.notNull(type, "Type to fetch must not be null!");
  String keyspace = resolveKeySpace(type);
  potentiallyPublishEvent(KeyValueEvent.beforeGet(id, keyspace, type));
  T result = execute(adapter -> {
    Object value = adapter.get(id, keyspace, type);
    if (value == null || typeCheck(type, value)) {
      return type.cast(value);
    }
    return null;
  });
  potentiallyPublishEvent(KeyValueEvent.afterGet(id, keyspace, type, result));
  return Optional.ofNullable(result);
}
origin: org.springframework.data/spring-data-keyvalue

@Override
public <T> T insert(Object id, T objectToInsert) {
  Assert.notNull(id, "Id for object to be inserted must not be null!");
  Assert.notNull(objectToInsert, "Object to be inserted must not be null!");
  String keyspace = resolveKeySpace(objectToInsert.getClass());
  potentiallyPublishEvent(KeyValueEvent.beforeInsert(id, keyspace, objectToInsert.getClass(), objectToInsert));
  execute((KeyValueCallback<Void>) adapter -> {
    if (adapter.contains(id, keyspace)) {
      throw new DuplicateKeyException(
          String.format("Cannot insert existing object with id %s!. Please use update.", id));
    }
    adapter.put(id, objectToInsert, keyspace);
    return null;
  });
  potentiallyPublishEvent(KeyValueEvent.afterInsert(id, keyspace, objectToInsert.getClass(), objectToInsert));
  return objectToInsert;
}
origin: org.springframework.data/spring-data-keyvalue

@Override
public void delete(Class<?> type) {
  Assert.notNull(type, "Type to delete must not be null!");
  String keyspace = resolveKeySpace(type);
  potentiallyPublishEvent(KeyValueEvent.beforeDropKeySpace(keyspace, type));
  execute((KeyValueCallback<Void>) adapter -> {
    adapter.deleteAllOf(keyspace);
    return null;
  });
  potentiallyPublishEvent(KeyValueEvent.afterDropKeySpace(keyspace, type));
}
origin: org.springframework.data/spring-data-keyvalue

@Override
public <T> T update(Object id, T objectToUpdate) {
  Assert.notNull(id, "Id for object to be inserted must not be null!");
  Assert.notNull(objectToUpdate, "Object to be updated must not be null!");
  String keyspace = resolveKeySpace(objectToUpdate.getClass());
  potentiallyPublishEvent(KeyValueEvent.beforeUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate));
  Object existing = execute(adapter -> adapter.put(id, objectToUpdate, keyspace));
  potentiallyPublishEvent(
      KeyValueEvent.afterUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate, existing));
  return objectToUpdate;
}
origin: apache/servicemix-bundles

@Override
public <T> T delete(Object id, Class<T> type) {
  Assert.notNull(id, "Id for object to be deleted must not be null!");
  Assert.notNull(type, "Type to delete must not be null!");
  String keyspace = resolveKeySpace(type);
  potentiallyPublishEvent(KeyValueEvent.beforeDelete(id, keyspace, type));
  T result = execute(adapter -> adapter.delete(id, keyspace, type));
  potentiallyPublishEvent(KeyValueEvent.afterDelete(id, keyspace, type, result));
  return result;
}
org.springframework.data.keyvalue.core.eventKeyValueEvent

Javadoc

KeyValueEvent gets published for operations executed by eg. org.springframework.data.keyvalue.core.KeyValueTemplate. Use the #getType() to determine which event has been emitted.

Most used methods

  • afterDelete
    Create new AfterDeleteEvent.
  • afterDropKeySpace
    Create new AfterDropKeySpaceEvent.
  • afterGet
    Create new AfterGetEvent.
  • afterInsert
    Create new AfterInsertEvent.
  • afterUpdate
    Create new AfterUpdateEvent.
  • beforeDelete
    Create new BeforeDeleteEvent.
  • beforeDropKeySpace
    Create new BeforeDropKeySpaceEvent.
  • beforeGet
    Create new BeforeGetEvent.
  • beforeInsert
    Create new BeforeInsertEvent.
  • beforeUpdate
    Create new BeforeUpdateEvent.
  • getSource
  • getSource

Popular in Java

  • Finding current android device location
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • startActivity (Activity)
  • getSystemService (Context)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now