Example usage for com.google.common.collect Lists newLinkedList

List of usage examples for com.google.common.collect Lists newLinkedList

Introduction

In this page you can find the example usage for com.google.common.collect Lists newLinkedList.

Prototype

@GwtCompatible(serializable = true)
public static <E> LinkedList<E> newLinkedList() 

Source Link

Document

Creates a mutable, empty LinkedList instance (for Java 6 and earlier).

Usage

From source file:com.romeikat.datamessie.core.domain.enums.DocumentProcessingState.java

public static DocumentProcessingState[] getWithout(final DocumentProcessingState... excludedStates) {
    final List<DocumentProcessingState> desiredStates = Lists.newLinkedList();
    final Set<DocumentProcessingState> excludedStatesAsSet = Sets.newHashSet(excludedStates);
    for (final DocumentProcessingState state : DocumentProcessingState.values()) {
        if (!excludedStatesAsSet.contains(state)) {
            desiredStates.add(state);/*from   w  ww.j  ava 2s .com*/
        }
    }
    return desiredStates.toArray(new DocumentProcessingState[] {});
}

From source file:com.chessix.vas.service.RdbmsStorage.java

@Override
public List<Integer> accountValues(final String clasId) {
    final List<Integer> result = Lists.newLinkedList();
    int page = 0;
    Page<Account> accounts;// w w  w.ja v  a2 s.  c om
    do {
        accounts = dbService.findAccountsByClas(clasId, new PageRequest(page, PAGE_SIZE));
        result.addAll(Lists.transform(accounts.getContent(), new Function<Account, Integer>() {

            @Override
            public Integer apply(final Account input) {
                return input.getBalance();
            }
        }));

        page += 1;
    } while (accounts.hasNext());

    return result;
}

From source file:org.terasology.inGameHelp.components.ItemHelpComponent.java

/**
 * Gets the description of this help item.
 *
 * @return an iterable of paragraph data about this help item that contains the description.
 *//*from  w ww .ja v  a  2  s .co  m*/
@Override
public Iterable<ParagraphData> getParagraphs() {
    List<ParagraphData> result = Lists.newLinkedList();
    for (String paragraph : paragraphText) {
        result.add(HTMLLikeParser.parseHTMLLikeParagraph(null, paragraph));
    }
    return result;
}

From source file:org.geogit.web.api.commands.BranchWebOp.java

/**
 * Runs the command and builds the appropriate response
 * /*  ww w.ja va  2  s .  c  o  m*/
 * @param context - the context to use for this command
 */
@Override
public void run(CommandContext context) {
    if (list) {
        final CommandLocator geogit = this.getCommandLocator(context);
        final List<Ref> localBranches = geogit.command(BranchListOp.class).call();
        final List<Ref> remoteBranches;
        if (remotes) {
            remoteBranches = geogit.command(BranchListOp.class).setLocal(false).setRemotes(remotes).call();
        } else {
            remoteBranches = Lists.newLinkedList();
        }
        context.setResponseContent(new CommandResponse() {
            @Override
            public void write(ResponseWriter out) throws Exception {
                out.start();
                out.writeBranchListResponse(localBranches, remoteBranches);
                out.finish();
            }
        });
    }
}

From source file:org.terasology.manualLabor.processParts.ProcessingTimeProcessPartCommonSystem.java

@ReceiveEvent
public void getInputDescriptions(ProcessEntityGetInputDescriptionEvent event, EntityRef processEntity,
        ProcessingTimeComponent processingTimeComponent) {
    List<ProcessPartDescription> descriptions = Lists.newLinkedList();
    String time = String.valueOf(processingTimeComponent.duration / 1000);
    UIImage image = new UIImage(Assets.getTextureRegion("ManualLabor:Manuallabor#Time").get());
    OverlapLayout layout = new OverlapLayout();
    layout.addWidget(image);/*from   ww w .j  a va 2s  .  c o  m*/
    layout.setTooltip(time + " sec");
    layout.setTooltipDelay(0);
    event.addInputDescription(new ProcessPartDescription(null, time + " sec", layout));

}

From source file:org.sosy_lab.cpachecker.core.algorithm.testgen.pathanalysis.CFATrackingPathValidator.java

public CFATrackingPathValidator(PathChecker pPathChecker, StartupConfig pConfig) {
    super(pConfig);
    pathChecker = pPathChecker;
    handledDecisions = Lists.newLinkedList();
}

From source file:org.gradle.internal.FileUtils.java

/**
 * Returns the outer most files that encompass the given files inclusively.
 * <p>//  w ww  . j a v a  2 s  .  c  o m
 * This method does not access the file system.
 * It is agnostic to whether a given file object represents a regular file, directory or does not exist.
 * That is, the termfile? is used in the java.io.File sense, not the regular file sense.
 *
 * @param files the site of files to find the encompassing roots of
 * @return the encompassing roots
 */
public static Collection<? extends File> calculateRoots(Iterable<? extends File> files) {
    List<File> roots = Lists.newLinkedList();

    files: for (File file : files) {
        File absoluteFile = file.getAbsoluteFile();
        String path = absoluteFile + File.separator;
        Iterator<File> rootsIterator = roots.iterator();

        while (rootsIterator.hasNext()) {
            File root = rootsIterator.next();
            String rootPath = root.getPath() + File.separator;
            if (path.startsWith(rootPath)) { // is lower than root
                continue files;
            }

            if (rootPath.startsWith(path)) { // is higher than root
                rootsIterator.remove();
            }
        }

        roots.add(absoluteFile);
    }

    return roots;
}

From source file:org.openqa.selenium.android.events.WebViewAction.java

/**
 * Sends key strokes to the given text to the element in focus within the webview.
 * /*from  ww w  . ja  va  2  s .c o m*/
 * Note: This assumes that the focus has been set before on the element at sake.
 * 
 * @param webview
 * @param text
 */
public static void sendKeys(WebView webview, CharSequence... text) {
    LinkedList<KeyEvent> keyEvents = Lists.newLinkedList();
    KeyCharacterMap characterMap = KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD);
    moveCursorToRightMostPosition(text[0].toString(), webview);
    CharSequence[] inputText = getInputText(text);
    for (CharSequence sequence : inputText) {
        for (int i = 0; i < sequence.length(); i++) {
            char c = sequence.charAt(i);
            int code = AndroidKeys.getKeyEventFromUnicodeKey(c);
            if (code != -1) {
                keyEvents.addLast(new KeyEvent(KeyEvent.ACTION_DOWN, code));
                keyEvents.addLast(new KeyEvent(KeyEvent.ACTION_UP, code));
            } else {
                keyEvents.addAll(Arrays.asList(characterMap.getEvents(new char[] { c })));
            }
        }
    }
    dispatchEvents(webview, keyEvents);
}

From source file:org.artifactory.addon.layouts.translate.PathTranslationHelper.java

public String translatePath(RepoLayout sourceRepoLayout, RepoLayout targetRepoLayout, String path,
        BasicStatusHolder multiStatusHolder) {

    LinkedList<Pair<String, TranslatorFilter>> filters = Lists.newLinkedList();

    path = filterPaths(path, filters);//from w w w  . j  a  v a 2s  .  c om

    ModuleInfo moduleInfo = null;
    boolean descriptor = true;

    if (sourceRepoLayout.isDistinctiveDescriptorPathPattern()) {
        moduleInfo = ModuleInfoUtils.moduleInfoFromDescriptorPath(path, sourceRepoLayout);
    }

    if ((moduleInfo == null) || !moduleInfo.isValid()) {
        moduleInfo = ModuleInfoUtils.moduleInfoFromArtifactPath(path, sourceRepoLayout);
        descriptor = false;
    }

    if ((moduleInfo == null) || !moduleInfo.isValid()) {
        if (multiStatusHolder != null) {
            multiStatusHolder.warn("Unable to translate path '" + path
                    + "': does not represent a valid module path within the source.", log);
        }

        return applyFilteredContent(path, filters);
    }

    String result;
    ModuleInfo resultModuleInfo;

    /**
     * If mixing between Maven and non-Maven layouts, treat the source descriptor as a normal artifact. Most chances
     * are that the descriptor won't have any meaning. Currently the best compromise
     */
    if (descriptor && !isExclusivelyOneLayoutM2(sourceRepoLayout, targetRepoLayout)) {
        result = ModuleInfoUtils.constructDescriptorPath(moduleInfo, targetRepoLayout, true);
        resultModuleInfo = ModuleInfoUtils.moduleInfoFromDescriptorPath(result, targetRepoLayout);
    } else {
        result = ModuleInfoUtils.constructArtifactPath(moduleInfo, targetRepoLayout, true);
        resultModuleInfo = ModuleInfoUtils.moduleInfoFromArtifactPath(result, targetRepoLayout);
    }

    if (!resultModuleInfo.isValid() && (multiStatusHolder != null)) {
        multiStatusHolder.warn("Translated path '" + path
                + "', but the result does not represent a valid module path within the target.", log);
    }

    return applyFilteredContent(result, filters);
}

From source file:com.cloudera.api.ApiErrorMessage.java

/**
 * Constructs a new ApiErrorMessage that provides information about
 * the given error. Its message and any underlying causes are saved.
 *
 * @param t The error being wrapped.// w ww . java  2s  . co m
 */
public ApiErrorMessage(Throwable t) {
    this.message = t.getMessage();
    List<String> causeMessages = Lists.newLinkedList();
    if (t.getCause() != null) {
        do {
            t = t.getCause();
            String errorMessage = t.getMessage();
            if (errorMessage != null) {
                causeMessages.add(errorMessage);
            }
        } while (t.getCause() != null);
    }
    if (!causeMessages.isEmpty()) {
        causes = causeMessages;
    } else {
        causes = null;
    }
}