Example usage for org.apache.commons.collections.set MapBackedSet decorate

List of usage examples for org.apache.commons.collections.set MapBackedSet decorate

Introduction

In this page you can find the example usage for org.apache.commons.collections.set MapBackedSet decorate.

Prototype

public static Set decorate(Map map) 

Source Link

Document

Factory method to create a set from a map.

Usage

From source file:org.apache.openjpa.kernel.BrokerImpl.java

@SuppressWarnings("unchecked")
private void initializeOperatingSet() {
    if (_operatingDirty) {
        _operatingDirty = false;/*from   w ww . jav a  2 s  .  c  o m*/
        _operating = MapBackedSet.decorate(new IdentityHashMap<Object, Object>());
    }
}

From source file:org.apache.openjpa.util.AbstractChangeTracker.java

/**
 * Create a new set for storing adds/removes/changes. Takes into account
 * whether we need to use an identity set or standard set.
 *///from  w ww. ja  v a  2 s  .  co m
protected Set newSet() {
    if (_identity == Boolean.TRUE)
        return MapBackedSet.decorate(new IdentityHashMap());
    return new HashSet();
}

From source file:org.apache.openjpa.util.AbstractChangeTracker.java

/**
 * Switch from an identity structure to a standard one, or vice versa.
 *///  w ww.  j  a  va2 s . com
private static Collection switchStructure(Collection cur, boolean identity) {
    if (cur == null)
        return null;
    if (identity && cur instanceof HashSet) {
        if (cur.isEmpty())
            return null;
        Set replace = MapBackedSet.decorate(new IdentityHashMap());
        replace.addAll(cur);
        return replace;
    }
    if (!identity && !(cur instanceof HashSet) && cur instanceof Set) {
        if (cur.isEmpty())
            return null;
        return new HashSet(cur);
    }
    return cur;
}

From source file:org.talend.commons.ui.runtime.swt.tableviewer.tableeditor.TableEditorManager.java

private void handleSwapedEvent(ListenableListEvent event) {

    if (tableViewerCreator.getTable().isDisposed()) {
        return;/*from  w w w  .j  ava 2  s .co  m*/
    }

    Table table = tableViewerCreator.getTable();
    TableItem[] items = table.getItems();

    // //////////////////////////////////
    // Warning: using identity comparison
    // //////////////////////////////////
    Set dataHash = MapBackedSet.decorate(new IdentityHashMap());
    dataHash.addAll(Arrays.asList(event.swapedObjects));
    ;
    for (TableItem tableItem : items) {
        Object data = tableItem.getData();
        if (dataHash.contains(data)) {
            Collection<TableEditor> tableEditorCollection = dataToMultipleDataEditor.getCollection(data);
            for (TableEditor tableEditor : tableEditorCollection) {
                tableEditor.setItem(tableItem);
            }
        }
    }

}