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

How to use
IndirectMap
in
org.eclipse.persistence.indirection

Best Java code snippets using org.eclipse.persistence.indirection.IndirectMap (Showing top 20 results out of 315)

origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * Raise the add change event and relationship maintainence.
 */
protected void raiseAddChangeEvent(Object key, Object value) {
  if (hasTrackedPropertyChangeListener()) {
    _persistence_getPropertyChangeListener().propertyChange(new MapChangeEvent(this, getTrackedAttributeName(), this, key, value, CollectionChangeEvent.ADD, true));
  }
  // this is where relationship maintenance would go
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Check whether the contents have been read from the database.
 * If they have not, read them and set the delegate.
 * This method used to be synchronized, which caused deadlock.
 */
protected Hashtable getDelegate() {
  if (delegate == null) {
    synchronized(this){
      if (delegate == null) {
        delegate = this.buildDelegate();
      }
    }
  }
  return delegate;
}
 
origin: org.eclipse.persistence/org.eclipse.persistence.core

@Override
public void clear(){
  IndirectMap.this.clear();
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

@Override
public boolean retainAll(Collection<?> c){
  boolean result = false;
  Iterator objects = delegateSet.iterator();
  while (objects.hasNext()) {
    Object object = objects.next();
    if (!c.contains(object)) {
      objects.remove();
      IndirectMap.this.raiseRemoveChangeEvent(object, IndirectMap.this.getDelegate().get(object));
      result = true;
    }
  }
  return result;
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * @see java.util.Hashtable#put(java.lang.Object, java.lang.Object)
 */
@Override
public synchronized V put(K key, V value) {
  V oldValue = this.getDelegate().put(key, value);
  if (oldValue != null){
    raiseRemoveChangeEvent(key, oldValue);
  }
  raiseAddChangeEvent(key, value);
  return oldValue;
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

@Override
public synchronized V replace(K key, V value) {
  // Must trigger add events if tracked or uow.
  if (hasTrackedPropertyChangeListener()) {
    Map<K, V> del = getDelegate();
    if (del.containsKey(key)) {
      return put(key, value);
    }
    return null;
  }
  return getDelegate().replace(key, value);
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

@Override
public synchronized V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction) {
  // Must trigger add events if tracked or uow.
  if (hasTrackedPropertyChangeListener()) {
    V oldValue = get(key);
    V newValue = (oldValue == null) ? value : remappingFunction.apply(oldValue, value);
    if (newValue == null) {
      remove(key);
    } else {
      put(key, newValue);
    }
    return newValue;
  }
  return getDelegate().merge(key, value, remappingFunction);
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * @see java.util.Hashtable#clear()
 */
public synchronized void clear() {
  if (hasTrackedPropertyChangeListener()) {
    Iterator objects = this.keySet().iterator();
    while (objects.hasNext()) {
      Object o = objects.next();
      objects.remove();
      this.raiseRemoveChangeEvent(o, this.get(o));
    }
  } else {
    this.getDelegate().clear();
  }
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * INTERNAL:
 * Return the real collection object.
 * This will force instantiation.
 */
@Override
public Object getDelegateObject() {
  return getDelegate();
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

@Override
public synchronized void replaceAll(BiFunction<? super K,? super V,? extends V> function) {
  // Must trigger add events if tracked or uow.
  if (hasTrackedPropertyChangeListener()) {
    getDelegate().entrySet().stream().forEach((entry) -> {
      K key = entry.getKey();
      V oldValue = entry.getValue();
      entry.setValue(function.apply(key, entry.getValue()));
      raiseRemoveChangeEvent(key, oldValue);
      raiseAddChangeEvent(key, entry.getValue());
    });
    return;
  }
  getDelegate().replaceAll(function);
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

@Override
public synchronized V putIfAbsent(K key, V value) {
  // Must trigger add events if tracked or uow.
  if (hasTrackedPropertyChangeListener()) {
    V current = getDelegate().get(key);
    if (current == null) {
      V v = getDelegate().put(key, value);
      raiseAddChangeEvent(key, value);
      return v;
    }
    return current;
  }
  return getDelegate().putIfAbsent(key, value);
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

@Override
public synchronized boolean remove(Object key, Object value) {
  // Must trigger add events if tracked or uow.
  if (hasTrackedPropertyChangeListener()) {
    Map<K, V> del = getDelegate();
    if (del.containsKey(key) && Objects.equals(del.get(key), value)) {
      del.remove(key);
      raiseRemoveChangeEvent(key, value);
      return true;
    }
    return false;
  }
  return getDelegate().remove(key, value);
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

/**
 * @see java.util.Hashtable#clear()
 */
@Override
public synchronized void clear() {
  if (hasTrackedPropertyChangeListener()) {
    Iterator<K> objects = this.keySet().iterator();
    while (objects.hasNext()) {
      K o = objects.next();
      objects.remove();
    }
  } else {
    this.getDelegate().clear();
  }
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * PUBLIC:
 * Use the Hashtable.toString(); but wrap it with braces to indicate
 * there is a bit of indirection.
 * Don't allow this method to trigger a database read.
 * @see java.util.Hashtable#toString()
 */
public String toString() {
  if (ValueHolderInterface.shouldToStringInstantiate) {
    return this.getDelegate().toString();
  }
  if (this.isInstantiated()) {
    return "{" + this.getDelegate().toString() + "}";
  } else {
    return "{" + org.eclipse.persistence.internal.helper.Helper.getShortClassName(this.getClass()) + ": not instantiated}";
  }
}
origin: com.haulmont.thirdparty/eclipselink

/**
 * Return the freshly-built delegate.
 */
protected Hashtable<K, V> buildDelegate() {
  Hashtable<K, V> value = (Hashtable<K, V>)getValueHolder().getValue();
  if (value == null) {
    value = new Hashtable<>(this.initialCapacity, this.loadFactor);
  }
  return value;
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * PUBLIC:
 * Construct a new IndirectMap with the same mappings as the given Map.
 * The IndirectMap is created with a capacity of twice the number of entries
 * in the given Map or 11 (whichever is greater), and a default load factor, which is 0.75.
 * @param m a map containing the mappings to use
 */
public IndirectMap(Map m) {
  super(0);
  this.initialize(m);
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

@Override
public synchronized V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction) {
  // Must trigger add events if tracked or uow.
  if (hasTrackedPropertyChangeListener()) {
    if (get(key) != null) {
      V oldValue = get(key);
      V newValue = remappingFunction.apply(key, oldValue);
      if (newValue != null) {
        put(key, newValue);
        return newValue;
      }
      remove(key);
    }
    return null;
  }
  return getDelegate().computeIfPresent(key, remappingFunction);
}
origin: com.haulmont.thirdparty/eclipselink

/**
 * @see java.util.Hashtable#clear()
 */
@Override
public synchronized void clear() {
  if (hasTrackedPropertyChangeListener()) {
    Iterator<K> objects = this.keySet().iterator();
    while (objects.hasNext()) {
      K o = objects.next();
      objects.remove();
      // should remove this to not fire same event twice
      this.raiseRemoveChangeEvent(o, this.get(o));
    }
  } else {
    this.getDelegate().clear();
  }
}
origin: org.eclipse.persistence/org.eclipse.persistence.core

@Override
public synchronized boolean replace(K key, V oldValue, V newValue) {
  // Must trigger add events if tracked or uow.
  if (hasTrackedPropertyChangeListener()) {
    Map<K, V> del = getDelegate();
    if (del.containsKey(key) && Objects.equals(del.get(key), oldValue)) {
      put(key, newValue);
      return true;
    }
    return false;
  }
  return getDelegate().replace(key, oldValue, newValue);
}
origin: org.eclipse.persistence/com.springsource.org.eclipse.persistence

/**
 * INTERNAL:
 * Return the real collection object.
 * This will force instantiation.
 */
public Object getDelegateObject() {
  return getDelegate();
}
org.eclipse.persistence.indirectionIndirectMap

Javadoc

IndirectMap allows a domain class to take advantage of TopLink indirection without having to declare its instance variable as a ValueHolderInterface.

To use an IndirectMap:

  • Declare the appropriate instance variable with type Hashtable (jdk1.1) or Map (jdk1.2).
  • Send the message #useTransparentMap(String) to the appropriate CollectionMapping.
TopLink will place an IndirectMap in the instance variable when the containing domain object is read from the datatabase. With the first message sent to the IndirectMap, the contents are fetched from the database and normal Hashtable/Map behavior is resumed.

Most used methods

  • _persistence_getPropertyChangeListener
    Return the property change listener for change tracking.
  • buildDelegate
    Return the freshly-built delegate.
  • clear
  • get
  • getDelegate
    INTERNAL: Check whether the contents have been read from the database. If they have not, read them a
  • getTrackedAttributeName
    INTERNAL: Return the mapping attribute name, used to raise change events.
  • getValueHolder
    PUBLIC: Return the valueHolder. This method used to be synchronized, which caused deadlock.
  • hasTrackedPropertyChangeListener
    INTERNAL: Return if the collection has a property change listener for change tracking.
  • initialize
    Initialize the instance.
  • isInstantiated
    PUBLIC: Return whether the contents have been read from the database.
  • keySet
  • put
  • keySet,
  • put,
  • raiseAddChangeEvent,
  • raiseRemoveChangeEvent,
  • <init>,
  • remove,
  • entrySet

Popular in Java

  • Updating database using SQL prepared statement
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • setContentView (Activity)
  • getSharedPreferences (Context)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top PhpStorm plugins
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