Java 8 CopyOnWriteArrayList - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 CopyOnWriteArrayList class.

This code example shows how to use the following methods:
 */ 
public class IndexSettingsService extends AbstractIndexComponent { 
 
    private volatile Settings settings; 
 
    private final CopyOnWriteArrayList<Listener> listeners = new CopyOnWriteArrayList<Listener>();
 
    @Inject 
    public IndexSettingsService(Index index, Settings settings) {
        super(index, settings);
        this.settings = settings;
    } 
 
    public synchronized void refreshSettings(Settings settings) { 
        // this.settings include also the node settings 
        if (this.settings.getByPrefix("index.").getAsMap().equals(settings.getByPrefix("index.").getAsMap())) {
            // nothing to update, same settings 
            return; 
        } 
        this.settings = ImmutableSettings.settingsBuilder().put(this.settings).put(settings).build();
9
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    public static interface Filter { 
 
        void filter(ImmutableSettings.Builder settings);
    } 
 
    private final CopyOnWriteArrayList<Filter> filters = new CopyOnWriteArrayList<>();
 
    @Inject 
    public SettingsFilter(Settings settings) { 
        super(settings); 
    } 
 
    public void addFilter(Filter filter) {
        filters.add(filter);
    } 
 
    public void removeFilter(Filter filter) {
        filters.remove(filter);
    } 
 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addAll, set, subList
     * The sub list throws on non-structural changes, even though that disagrees 
     * with the subList() documentation which suggests that only size-changing 
     * operations will trigger ConcurrentModificationException. 
     */ 
    public void testSubListAndNonStructuralChanges() { 
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>();
        list.addAll(Arrays.asList("a", "b", "c", "d", "e"));
        List<String> bcd = list.subList(1, 4);
        list.set(2, "C");
        try { 
            bcd.get(1);
            fail();
        } catch (ConcurrentModificationException expected) {
        } 
    } 
 
    public void testSubListAndStructuralChanges() { 
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>();
        list.addAll(Arrays.asList("a", "b", "c", "d", "e"));
        List<String> bcd = list.subList(1, 4);
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
/** 
 * Abstract resource watcher framework, which handles adding and removing listeners 
 * and calling resource observer. 
 */ 
public abstract class AbstractResourceWatcher<Listener> implements ResourceWatcher { 
    private final List<Listener> listeners = new CopyOnWriteArrayList<Listener>();
    private boolean initialized = false;
 
    @Override 
    public void init() { 
        if (!initialized) {
            doInit(); 
            initialized = true;
        } 
    } 
 
    @Override 
    public void checkAndNotify() { 
        init(); 
        doCheckAndNotify(); 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 */ 
public class IndexSettingsService extends AbstractIndexComponent { 
 
    private volatile Settings settings; 
 
    private final CopyOnWriteArrayList<Listener> listeners = new CopyOnWriteArrayList<>();
 
    @Inject 
    public IndexSettingsService(Index index, Settings settings) {
        super(index, settings);
        this.settings = settings;
    } 
 
    public synchronized void refreshSettings(Settings settings) { 
        // this.settings include also the node settings 
        if (this.settings.getByPrefix("index.").getAsMap().equals(settings.getByPrefix("index.").getAsMap())) {
            // nothing to update, same settings 
            return; 
        } 
        this.settings = ImmutableSettings.settingsBuilder().put(this.settings).put(settings).build();
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addAll, set, subList
     * The sub list throws on non-structural changes, even though that disagrees 
     * with the subList() documentation which suggests that only size-changing 
     * operations will trigger ConcurrentModificationException. 
     */ 
    public void testSubListAndNonStructuralChanges() { 
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>();
        list.addAll(Arrays.asList("a", "b", "c", "d", "e"));
        List<String> bcd = list.subList(1, 4);
        list.set(2, "C");
        try { 
            bcd.get(1);
            fail();
        } catch (ConcurrentModificationException expected) {
        } 
    } 
 
    public void testSubListAndStructuralChanges() { 
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<String>();
        list.addAll(Arrays.asList("a", "b", "c", "d", "e"));
        List<String> bcd = list.subList(1, 4);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:remove
    public void addListener(Listener listener) {
        listeners.add(listener);
    } 
 
    public void removeListener(Listener listener) {
        listeners.remove(listener);
    } 
 
    protected void failedMerge(final MergePolicy.MergeException e) {
        if (!notifyOnMergeFailure) {
            return; 
        } 
        for (final FailureListener failureListener : failureListeners) {
            threadPool.generic().execute(new Runnable() {
                @Override 
                public void run() { 
                    failureListener.onFailedMerge(e);
                } 
            }); 
        } 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
/** 
 */ 
public class DiscoveryNodeService extends AbstractComponent { 
 
    private final List<CustomAttributesProvider> customAttributesProviders = new CopyOnWriteArrayList<CustomAttributesProvider>();
 
    @Inject 
    public DiscoveryNodeService(Settings settings) { 
        super(settings); 
    } 
 
    public DiscoveryNodeService addCustomAttributeProvider(CustomAttributesProvider customAttributesProvider) {
        customAttributesProviders.add(customAttributesProvider);
        return this;
    } 
 
    public Map<String, String> buildAttributes() {
        Map<String, String> attributes = Maps.newHashMap(settings.getByPrefix("node.").getAsMap());
        attributes.remove("name"); // name is extracted in other places
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
/** 
 * Abstract resource watcher framework, which handles adding and removing listeners 
 * and calling resource observer. 
 */ 
public abstract class AbstractResourceWatcher<Listener> implements ResourceWatcher { 
    private final List<Listener> listeners = new CopyOnWriteArrayList<>();
    private boolean initialized = false;
 
    @Override 
    public void init() { 
        if (!initialized) {
            doInit(); 
            initialized = true;
        } 
    } 
 
    @Override 
    public void checkAndNotify() { 
        init(); 
        doCheckAndNotify(); 
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
 
/** 
 */ 
public class DiscoveryNodeService extends AbstractComponent { 
 
    private final List<CustomAttributesProvider> customAttributesProviders = new CopyOnWriteArrayList<>();
 
    @Inject 
    public DiscoveryNodeService(Settings settings) { 
        super(settings); 
    } 
 
    public DiscoveryNodeService addCustomAttributeProvider(CustomAttributesProvider customAttributesProvider) {
        customAttributesProviders.add(customAttributesProvider);
        return this;
    } 
 
    public Map<String, String> buildAttributes() {
        Map<String, String> attributes = Maps.newHashMap(settings.getByPrefix("node.").getAsMap());
        attributes.remove("name"); // name is extracted in other places
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 CopyOnWriteArrayList Methods: