Example usage for java.util Collections EMPTY_LIST

List of usage examples for java.util Collections EMPTY_LIST

Introduction

In this page you can find the example usage for java.util Collections EMPTY_LIST.

Prototype

List EMPTY_LIST

To view the source code for java.util Collections EMPTY_LIST.

Click Source Link

Document

The empty list (immutable).

Usage

From source file:co.kademi.kdom.KParser.java

public KDocument parse(InputStream in) throws IOException {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    IOUtils.copy(in, bout);/*from   w w w  . java 2 s  .c om*/
    String s = bout.toString("UTF8");
    final KDocument doc = new KDocument();
    List<String> beginTagTextStack = new ArrayList<>();
    List<List<KDocument.KDomNode>> stack = new ArrayList();

    RegexTokenizer.TokenHandler handler = new RegexTokenizer.TokenHandler() {
        List<KDocument.KDomNode> currentChildren;

        @Override
        public void onToken(RegexTokenizer.TokenType type, String text) {
            KDocument.KDomElement newEl;
            String beginTagText;
            switch (type) {
            case DECLARATION:
                // ignore for now
                break;
            case OPEN_TAG:
                beginTagTextStack.add(0, text);
                currentChildren = new ArrayList<>();
                stack.add(0, currentChildren);
                break;
            case CLOSE_TAG:
                text = text.substring(2, text.length() - 1);
                if (beginTagTextStack.isEmpty()) {
                    throw new RuntimeException("Unbalanced tags: " + text);
                }
                beginTagText = beginTagTextStack.remove(0);
                beginTagText = beginTagText.substring(1, beginTagText.length() - 1);
                if (!beginTagText.startsWith(text)) {
                    throw new RuntimeException("Unbalanced tags. Start=" + beginTagText + " finished: " + text);
                }
                newEl = createAndAddElement(beginTagText, currentChildren, doc);
                stack.remove(0);
                if (!stack.isEmpty()) {
                    currentChildren = stack.get(0);
                    currentChildren.add(newEl);
                } else {
                    doc.setRoot(newEl);
                }
                break;
            case SELF_CLOSE_TAG:
                text = text.substring(1, text.length() - 2);
                newEl = createAndAddElement(text, Collections.EMPTY_LIST, doc);
                currentChildren.add(newEl);
                break;
            case MUSTACHE:
                String s = text.substring(2, text.length() - 2);
                Expression expr = jexl.createExpression(s);
                try {
                    KDocument.KDomExpressionNode n = doc.createExpressionNode(text, expr);
                    currentChildren.add(n);
                } catch (Exception e) {
                    throw new RuntimeException("Couldnt parse: " + text, e);
                }

                break;
            case MUSTACHE_OPEN:
                beginTagTextStack.add(0, text);
                currentChildren = new ArrayList<>();
                stack.add(0, currentChildren);
                break;
            case MUSTACHE_CLOSE:
                beginTagText = beginTagTextStack.remove(0);

                String startTag = beginTagText.substring(3, beginTagText.length() - 2);
                int i = startTag.indexOf(" ");
                String helper = null;
                String exprText = startTag;
                if (i > 0) {
                    helper = startTag.substring(0, i);
                    exprText = startTag.substring(i);
                    if (!text.startsWith("{{/" + helper)) {
                        throw new RuntimeException(
                                "Unbalanced tags. Start=" + beginTagText + " finished: " + text);
                    }

                } else {
                    helper = null;
                    exprText = startTag;
                    if (!text.startsWith("{{/" + exprText)) {
                        throw new RuntimeException(
                                "Unbalanced tags. Start=" + beginTagText + " finished: " + text);
                    }

                }

                try {
                    expr = jexl.createExpression(exprText);
                } catch (Exception e) {
                    throw new RuntimeException("Couldnt parse: " + exprText, e);
                }
                KDocument.KDomExpressionSection section;
                if (helper != null) {
                    section = doc.createHelperExpressionSection(helper, exprText, expr, currentChildren);
                } else {
                    section = doc.createExpressionSection(startTag, expr, currentChildren);
                }
                stack.remove(0);
                if (stack.isEmpty()) {
                    throw new RuntimeException("Unclosed tag: " + text);
                }
                currentChildren = stack.get(0);
                currentChildren.add(section);
                break;

            case TEXT:
                KDocument.KDomTextNode tn = doc.createTextNode(text);
                currentChildren.add(tn);
                break;

            }

        }
    };

    tokenizer.tokenize(s, handler);
    if (doc.getRoot() == null) {
        throw new RuntimeException("Did not get a root element");
    }
    return doc;
}

From source file:com.cloudbees.jenkins.plugins.amazonecr.AmazonECSRegistryCredential.java

public @CheckForNull AmazonWebServicesCredentials getCredentials() {
    List<AmazonWebServicesCredentials> credentials = CredentialsProvider.lookupCredentials(
            AmazonWebServicesCredentials.class, itemGroup, ACL.SYSTEM, Collections.EMPTY_LIST);

    if (credentials.isEmpty()) {
        return null;
    }//from w w  w .  java  2s  .  com

    for (AmazonWebServicesCredentials awsCredentials : credentials) {
        if (awsCredentials.getId().equals(this.credentialsId)) {
            return awsCredentials;
        }
    }
    return null;
}

From source file:jnetention.Core.java

public Iterable<NObject> netValues() {
    return Collections.EMPTY_LIST;
    //        /*from  w ww.  j a  v a2  s . co  m*/
    //        //dht.storageLayer().checkTimeout();
    //        return Iterables.filter(Iterables.transform(dht.storageLayer().get().values(), 
    //            new Function<Data,NObject>() {
    //                @Override public NObject apply(final Data f) {
    //                    try {
    //                        final Object o = f.object();
    //                        if (o instanceof NObject) {
    //                            NObject n = (NObject)o;
    //                            
    //                            if (data.containsKey(n.id))
    //                                return null;                                
    //                            
    //                            /*System.out.println("net value: " + f.object() + " " + f.object().getClass() + " " + data.containsKey(n.id));*/
    //                            return n;
    //                        }
    //                        /*else {
    //                            System.out.println("p: " + o + " " + o.getClass());
    //                        }*/
    //                        /*else if (o instanceof String) {
    //                            Object p = dht.get(Number160.createHash((String)o));
    //                            System.out.println("p: " + p + " " + p.getClass());
    //                        }*/
    //                        return null;
    //                    } catch (Exception ex) {
    //                        ex.printStackTrace();
    //                        return null;
    //                    }
    //                }                
    //        }), Predicates.notNull());        
}

From source file:com.groupon.jenkins.buildtype.plugins.DotCiPluginAdapter.java

public Collection<String> getValidationErrors() {
    return Collections.EMPTY_LIST;
}

From source file:com.googlecode.jtiger.modules.ecside.core.RetrievalUtils.java

static Collection retrieveCollectionFromScope(WebContext context, String collection, String scope)
        throws Exception {
    Collection results = null;/*from   w w w  .  j ava  2s.  c o m*/

    if (StringUtils.isBlank(collection) || "null".equals(collection)) {
        if (logger.isDebugEnabled()) {
            logger.debug("The collection is not defined.");
        }

        return Collections.EMPTY_LIST;
    }

    if (StringUtils.contains(collection, ".")) {
        results = retrieveNestedCollection(context, collection, scope);
    } else {
        results = retrieveCollectionAsObject(context, collection, scope);
    }

    if (results == null) {
        if (logger.isDebugEnabled()) {
            logger.debug("Could not find the Collection.");
        }

        return Collections.EMPTY_LIST;
    }

    return results;
}

From source file:architecture.ee.web.community.struts2.action.ajax.MyImageAction.java

public List<Image> getTargetImages() {
    if (getUser().getUserId() < 1)
        return Collections.EMPTY_LIST;
    if (pageSize > 0) {
        return getImageManager().getImages(USER_OBJEDT_TYPE, getUser().getUserId(), startIndex, pageSize);
    } else {/*from   www.ja va2s .  com*/
        return getImageManager().getImages(USER_OBJEDT_TYPE, getUser().getUserId());
    }
}

From source file:com.michelin.cio.hudson.plugins.wasbuilder.WASInstallation.java

@DataBoundConstructor
public WASInstallation(String name, String home, String wsadminCommand) {
    super(name, removeTrailingBackslash(home), Collections.EMPTY_LIST);
    if (StringUtils.isBlank(wsadminCommand)) {
        this.wsadminCommand = "${WSADMIN}";
    } else {/*from   w  w w. j  av a  2  s .  c  o m*/
        this.wsadminCommand = wsadminCommand;
    }
}

From source file:ca.polymtl.dorsal.libdelorean.statedump.Statedump.java

/**
 * "Online" constructor. Builds a statedump from a given state system and
 * timestamp.//from   w  w w.j a v  a 2s .  c  o m
 *
 * @param ss
 *            The state system for which to build the state dump
 * @param timestamp
 *            The timestamp at which to query the state to dump
 * @param version
 *            Version of the statedump
 */
public Statedump(IStateSystemReader ss, long timestamp, int version) {
    List<StateInterval> fullQuery;
    try {
        fullQuery = ss.queryFullState(timestamp);
    } catch (StateSystemDisposedException e1) {
        fAttributes = Collections.EMPTY_LIST;
        fStates = Collections.EMPTY_LIST;
        fStatedumpVersion = -1;
        return;
    }

    ImmutableList.Builder<String[]> attributesBuilder = ImmutableList.builder();
    for (int quark = 0; quark < ss.getNbAttributes(); quark++) {
        attributesBuilder.add(ss.getFullAttributePathArray(quark));
    }
    fAttributes = attributesBuilder.build();

    List<StateValue> states = fullQuery.stream().map(StateInterval::getStateValue).collect(Collectors.toList());
    fStates = ImmutableList.copyOf(states);

    fStatedumpVersion = version;
}

From source file:com.haulmont.cuba.core.global.filter.QueryFilter.java

@Nullable
protected Condition refine(Condition src, Set<String> params) {
    Condition copy = src.copy();//from  ww  w. j a v a 2  s  .c  o m
    List<Condition> list = new ArrayList<>();
    for (Condition condition : src.getConditions()) {
        if (isActual(condition, params)) {
            Condition refined = refine(condition, params);
            if (refined != null && !(refined instanceof LogicalCondition && refined.getConditions().isEmpty()))
                list.add(refined);
        }
    }
    if (copy instanceof LogicalCondition && list.isEmpty()) {
        return null;
    }
    copy.setConditions(list.isEmpty() ? Collections.EMPTY_LIST : list);
    return copy;
}