Example usage for java.util.concurrent CopyOnWriteArrayList isEmpty

List of usage examples for java.util.concurrent CopyOnWriteArrayList isEmpty

Introduction

In this page you can find the example usage for java.util.concurrent CopyOnWriteArrayList isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:edu.temple.cis3238.wiki.vo.TopicVO.java

/**
 *
 * @param tagsCollection/*  w  w  w  . j  av  a 2s  . c  om*/
 */
public void setTagsCollection(CopyOnWriteArrayList<TagsVO> tagsCollection) {
    if (tagsCollection != null && !tagsCollection.isEmpty()) {
        this.tagsCollection = new CopyOnWriteArrayList<TagsVO>();
        tagsCollection.sort(new TagsVO());
        this.tagsCollection.addAll(tagsCollection);
    }
}

From source file:org.jboss.windup.bootstrap.Bootstrap.java

private void run(List<String> args) {
    try {/*from   w ww .  j  av  a  2 s. co m*/
        furnace = FurnaceFactory.getInstance();
        furnace.setServerMode(true);

        CopyOnWriteArrayList<Command> commands = new CopyOnWriteArrayList<>(processArguments(args));

        if (!executePhase(CommandPhase.PRE_CONFIGURATION, commands))
            return;

        if (!executePhase(CommandPhase.CONFIGURATION, commands))
            return;

        if (commands.isEmpty()) {
            // no commands are available, just print the help and exit
            new DisplayHelpCommand().execute();
            return;
        }

        if (!containsMutableRepository(furnace.getRepositories())) {
            furnace.addRepository(AddonRepositoryMode.MUTABLE, getUserAddonsDir());
        }

        if (!executePhase(CommandPhase.POST_CONFIGURATION, commands) || commands.isEmpty())
            return;

        try {
            Future<Furnace> future = furnace.startAsync();
            future.get(); // use future.get() to wait until it is started
        } catch (Exception e) {
            System.out.println("Failed to start " + Util.WINDUP_BRAND_NAME_ACRONYM + "!");
            if (e.getMessage() != null)
                System.out.println("Failure reason: " + e.getMessage());
            e.printStackTrace();
        }

        if (!executePhase(CommandPhase.PRE_EXECUTION, commands) || commands.isEmpty())
            return;

        furnace.addContainerLifecycleListener(new GreetingListener());

        if (!executePhase(CommandPhase.EXECUTION, commands) || commands.isEmpty())
            return;

        if (!executePhase(CommandPhase.POST_EXECUTION, commands) || commands.isEmpty())
            return;
    } catch (Throwable t) {
        System.err.println(Util.WINDUP_BRAND_NAME_ACRONYM + " execution failed due to: " + t.getMessage());
        t.printStackTrace();
    }
}

From source file:android.bus.EventBus.java

private boolean postSingleEventForEventType(Object event, PostingThreadState postingState,
        Class<?> eventClass) {
    CopyOnWriteArrayList<Subscription> subscriptions;
    synchronized (this) {
        subscriptions = subscriptionsByEventType.get(eventClass);
    }/*from  w w  w. j a  va  2s  .c o m*/

    if (subscriptions != null && !subscriptions.isEmpty()) {
        for (Subscription subscription : subscriptions) {
            postingState.event = event;
            postingState.subscription = subscription;
            boolean aborted = false;
            try {
                postToSubscription(subscription, event, postingState.isMainThread);
                aborted = postingState.canceled;
            } finally {
                postingState.event = null;
                postingState.subscription = null;
                postingState.canceled = false;
            }
            if (aborted) {
                break;
            }
        }

        return true;
    }

    return false;
}

From source file:android.bus.EventBus.java

public boolean hasSubscriberForEvent(Class<?> eventClass) {
    List<Class<?>> eventTypes = lookupAllEventTypes(eventClass);
    if (eventTypes != null) {
        int countTypes = eventTypes.size();
        for (int h = 0; h < countTypes; h++) {
            Class<?> clazz = eventTypes.get(h);
            CopyOnWriteArrayList<Subscription> subscriptions;
            synchronized (this) {
                subscriptions = subscriptionsByEventType.get(clazz);
            }/*  ww  w  .ja  va  2  s.c o  m*/
            if (subscriptions != null && !subscriptions.isEmpty()) {
                return true;
            }
        }
    }
    return false;
}