Example usage for java.util LinkedList getLast

List of usage examples for java.util LinkedList getLast

Introduction

In this page you can find the example usage for java.util LinkedList getLast.

Prototype

public E getLast() 

Source Link

Document

Returns the last element in this list.

Usage

From source file:org.apache.fop.layoutmgr.table.TableContentLayoutManager.java

/**
 * Get a sequence of KnuthElements representing the content
 * of the node assigned to the LM.//from  w ww .j a v a  2 s  . com
 *
 * @param context   the LayoutContext used to store layout information
 * @param alignment the desired text alignment
 * @return          the list of KnuthElements
 * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int)
 */
public List getNextKnuthElements(LayoutContext context, int alignment) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> Columns: " + getTableLM().getColumns());
    }
    KnuthBox headerAsFirst = null;
    KnuthBox headerAsSecondToLast = null;
    KnuthBox footerAsLast = null;
    if (headerIter != null && headerList == null) {
        this.headerList = getKnuthElementsForRowIterator(headerIter, context, alignment,
                TableRowIterator.HEADER);
        this.headerNetHeight = ElementListUtils.calcContentLength(this.headerList);
        if (LOG.isDebugEnabled()) {
            LOG.debug("==> Header: " + headerNetHeight + " - " + this.headerList);
        }
        TableHeaderFooterPosition pos = new TableHeaderFooterPosition(getTableLM(), true, this.headerList);
        KnuthBox box = new KnuthBox(headerNetHeight, pos, false);
        if (getTableLM().getTable().omitHeaderAtBreak()) {
            //We can simply add the table header at the start
            //of the whole list
            headerAsFirst = box;
        } else {
            headerAsSecondToLast = box;
        }
    }
    if (footerIter != null && footerList == null) {
        this.footerList = getKnuthElementsForRowIterator(footerIter, context, alignment,
                TableRowIterator.FOOTER);
        this.footerNetHeight = ElementListUtils.calcContentLength(this.footerList);
        if (LOG.isDebugEnabled()) {
            LOG.debug("==> Footer: " + footerNetHeight + " - " + this.footerList);
        }
        //We can simply add the table footer at the end of the whole list
        TableHeaderFooterPosition pos = new TableHeaderFooterPosition(getTableLM(), false, this.footerList);
        KnuthBox box = new KnuthBox(footerNetHeight, pos, false);
        footerAsLast = box;
    }
    LinkedList returnList = getKnuthElementsForRowIterator(bodyIter, context, alignment, TableRowIterator.BODY);
    if (headerAsFirst != null) {
        int insertionPoint = 0;
        if (returnList.size() > 0 && ((ListElement) returnList.getFirst()).isForcedBreak()) {
            insertionPoint++;
        }
        returnList.add(insertionPoint, headerAsFirst);
    } else if (headerAsSecondToLast != null) {
        int insertionPoint = returnList.size();
        if (returnList.size() > 0 && ((ListElement) returnList.getLast()).isForcedBreak()) {
            insertionPoint--;
        }
        returnList.add(insertionPoint, headerAsSecondToLast);
    }
    if (footerAsLast != null) {
        int insertionPoint = returnList.size();
        if (returnList.size() > 0 && ((ListElement) returnList.getLast()).isForcedBreak()) {
            insertionPoint--;
        }
        returnList.add(insertionPoint, footerAsLast);
    }
    return returnList;
}

From source file:pl.otros.logview.gui.actions.ShowCallHierarchyAction.java

protected void findCallHierarchyEvents(int selected, LogDataTableModel model,
        Collection<Integer> listEntryEvents, Collection<Integer> listOfEvents2) {
    LogData ld = model.getLogData(selected);
    String thread = ld.getThread();
    LinkedList<LogData> stack = new LinkedList<LogData>();
    HashMap<Integer, ArrayList<Integer>> allEventsInCallHierarchyMap = new HashMap<Integer, ArrayList<Integer>>();

    int rowCount = model.getRowCount();
    for (int i = 0; i < rowCount; i++) {
        LogData logData = model.getLogData(i);
        if (!logData.getThread().equals(thread)) {
            continue;
        }/*w w  w  .  j  a  v  a2s .  c o  m*/
        Message m = new Message(logData.getMessage());
        Integer stackSize = stack.size();
        if (!allEventsInCallHierarchyMap.containsKey(stackSize)) {
            allEventsInCallHierarchyMap.put(stackSize, new ArrayList<Integer>());
        }
        ArrayList<Integer> tempListOfEvents = allEventsInCallHierarchyMap.get(stackSize);
        if (m.getType().equals(MessageType.TYPE_ENTRY)) {
            stack.addLast(logData);
        } else if (m.getType().equals(MessageType.TYPE_EXIT) && theSameLogMethod(stack.getLast(), logData)) {
            stack.removeLast();
            tempListOfEvents.clear();
        } else {
            tempListOfEvents.add(logData.getId());
        }
        if (logData.getId() == ld.getId()) {
            break;
        }
    }

    for (ArrayList<Integer> list : allEventsInCallHierarchyMap.values()) {
        listOfEvents2.addAll(list);
    }

    for (LogData aStack : stack) {
        listEntryEvents.add(Integer.valueOf(aStack.getId()));
    }
}

From source file:org.apache.hadoop.hdfs.server.namenode.TestSubtreeLock.java

private long getSubTreeRootID(final String path) throws IOException {
    LinkedList<INode> nodes = new LinkedList<>();
    INodeUtil.resolvePathWithNoTransaction(path, false, nodes);
    return nodes.getLast().getId();
}

From source file:edu.cmu.tetrad.search.SearchGraphUtils.java

public static Graph bestGuessCycleOrientation(Graph graph, IndependenceTest test) {
    while (true) {
        List<Node> cycle = GraphUtils.directedCycle(graph);

        if (cycle == null) {
            break;
        }/*w w w .j  a  v a 2 s.c  om*/

        LinkedList<Node> _cycle = new LinkedList<Node>(cycle);

        Node first = _cycle.getFirst();
        Node last = _cycle.getLast();

        _cycle.addFirst(last);
        _cycle.addLast(first);

        int _j = -1;
        double minP = Double.POSITIVE_INFINITY;

        for (int j = 1; j < _cycle.size() - 1; j++) {
            int i = j - 1;
            int k = j + 1;

            Node x = test.getVariable(_cycle.get(i).getName());
            Node y = test.getVariable(_cycle.get(j).getName());
            Node z = test.getVariable(_cycle.get(k).getName());

            test.isIndependent(x, z, Collections.singletonList(y));

            double p = test.getPValue();

            if (p < minP) {
                _j = j;
                minP = p;
            }
        }

        Node x = _cycle.get(_j - 1);
        Node y = _cycle.get(_j);
        Node z = _cycle.get(_j + 1);

        graph.removeEdge(x, y);
        graph.removeEdge(z, y);
        graph.addDirectedEdge(x, y);
        graph.addDirectedEdge(z, y);
    }

    return graph;
}

From source file:net.dv8tion.jda.MessageHistory.java

/**
 * Queues the next set of Messages and returns them
 * If the end of the chat was already reached, this function returns null
 *
 * @param amount the amount to Messages to queue
 * @return a list of the next [amount] Messages (max), or null if at end of chat
 *//*from  ww  w.j  a v  a 2s  .  co  m*/
public List<Message> retrieve(int amount) {
    if (atEnd) {
        return null;
    }
    int toQueue;
    LinkedList<Message> out = new LinkedList<>();
    EntityBuilder builder = new EntityBuilder(api);
    while (amount > 0) {
        toQueue = Math.min(amount, 100);
        try {
            Requester.Response response = api.getRequester().get(Requester.DISCORD_API_PREFIX + "channels/"
                    + channelId + "/messages?limit=" + toQueue + (lastId != null ? "&before=" + lastId : ""));
            if (!response.isOk())
                throw new RuntimeException("Error fetching message-history for channel with id " + channelId
                        + "... Error: " + response.toString());

            JSONArray array = response.getArray();

            for (int i = 0; i < array.length(); i++) {
                out.add(builder.createMessage(array.getJSONObject(i)));
            }
            if (array.length() < toQueue) {
                atEnd = true;
                break;
            } else {
                lastId = out.getLast().getId();
            }
        } catch (Exception ex) {
            JDAImpl.LOG.log(ex);
            break;
        }
        amount -= toQueue;
    }
    if (out.size() == 0) {
        return null;
    }
    queued.addAll(out);
    return out;
}

From source file:de.schildbach.pte.NegentweeProvider.java

private Trip tripFromJSONObject(JSONObject trip, @Nullable Location from, @Nullable Location to,
        @Nullable Map<String, JSONObject> disturbances) throws JSONException {
    JSONArray legs = trip.getJSONArray("legs");

    Date tripDeparture = realtimeDateFromJSONObject(trip, "departure", "realtimeDeparture");
    /* Date tripArrival = */ realtimeDateFromJSONObject(trip, "arrival", "realtimeArrival");

    // Get journey legs
    LinkedList<Trip.Leg> foundLegs = new LinkedList<>();
    for (int i = 0; i < legs.length(); i++) {
        JSONObject leg = legs.getJSONObject(i);

        JSONArray stops = leg.getJSONArray("stops");
        JSONObject mode = leg.getJSONObject("mode");
        JSONObject operator = leg.optJSONObject("operator");

        LinkedList<Point> foundPoints = new LinkedList<>();

        // First stop
        Stop firstStop = stopFromJSONObject(stops.getJSONObject(0));
        foundPoints.add(pointFromLocation(firstStop.location));

        // Intermediate stops
        LinkedList<Stop> foundStops = new LinkedList<>();
        for (int j = 1; j < stops.length() - 1; j++) {
            foundStops.add(stopFromJSONObject(stops.getJSONObject(j)));
            foundPoints.add(pointFromLocation(foundStops.getLast().location));
        }//from  www .  j  a v a2  s  .c  o  m

        // Last stop
        Stop lastStop = stopFromJSONObject(stops.getJSONObject(stops.length() - 1));
        foundPoints.add(pointFromLocation(lastStop.location));

        switch (leg.getString("type").toLowerCase()) {
        case "scheduled":
            Product lineProduct = productFromMode(mode.getString("type"), mode.getString("name"));

            StringBuilder legMessage = new StringBuilder();

            // Add attributes to leg message
            JSONArray legAttributes = leg.getJSONArray("attributes");
            for (int k = 0; k < legAttributes.length(); k++) {
                JSONObject legAttribute = legAttributes.getJSONObject(k);

                if (legMessage.length() > 0)
                    legMessage.append(", ");
                legMessage.append(WordUtils.capitalizeFirst(legAttribute.getString("title")));
            }

            // Add disturbances to leg message
            if (disturbances != null) {
                JSONArray legDisturbances = leg.getJSONArray("disturbancePlannerIds");
                for (int k = 0; k < legDisturbances.length(); k++) {
                    String legDisturbanceId = legDisturbances.optString(k);

                    if (legDisturbanceId != null && disturbances.containsKey(legDisturbanceId)) {
                        JSONObject legDisturbance = disturbances.get(legDisturbanceId);

                        if (legMessage.length() > 0)
                            legMessage.append("<br>\n<br>\n");
                        legMessage.append(legDisturbance.getString("title"));
                        legMessage.append(":<br>\n");
                        legMessage.append(legDisturbance.getString("effect"));
                        legMessage.append(" ");
                        legMessage.append(legDisturbance.getString("measure"));
                    }
                }
            }

            StringBuilder lineName = new StringBuilder();
            lineName.append(mode.getString("name"));

            // Service codes have no relevant meaning for trains
            if (!leg.isNull("service") && !trainProducts.contains(lineProduct)) {
                lineName.append(" ");
                lineName.append(leg.getString("service"));
            }

            foundLegs.add(new Trip.Public(
                    new Line(leg.getString("service"), (operator != null) ? operator.getString("name") : null,
                            lineProduct, lineName.toString(), leg.optString("service"),
                            Standard.STYLES.get(lineProduct), null, null),
                    new Location(LocationType.STATION, null, null, leg.getString("destination")), firstStop,
                    lastStop, foundStops, foundPoints, legMessage.length() > 0 ? legMessage.toString() : null));
            break;
        case "continuous":
            // Get leg time from trip or previous leg
            Date legDeparture = (i == 0) ? tripDeparture : foundLegs.getLast().getArrivalTime();
            Date legArrival = ParserUtils.addMinutes(legDeparture,
                    ParserUtils.parseMinutesFromTimeString(leg.getString("duration")));

            foundLegs.add(new Trip.Individual(Trip.Individual.Type.WALK, firstStop.location, legDeparture,
                    lastStop.location, legArrival, foundPoints, -1));
            break;
        default:
            throw new JSONException("Unknown leg type: " + leg.getString("type"));
        }
    }

    // Get journey fares
    JSONObject fareInfo = trip.getJSONObject("fareInfo");
    JSONArray fareLegs = fareInfo.getJSONArray("legs");

    Fare[] foundFares = new Fare[fareLegs.length()];
    for (int i = 0; i < fareLegs.length(); i++) {
        foundFares[i] = fareFromJSONObject(fareLegs.getJSONObject(i));
    }

    return new Trip(trip.getString("id"), from, to, foundLegs, Arrays.asList(foundFares), null,
            trip.getInt("numberOfChanges"));
}

From source file:com.multimedia.service.wallpaper.CmsWallpaperService.java

@Override
public List<UploadBean> createPageFolders() {
    OnlyFilesFilter filenameFilter = new OnlyFilesFilter();
    //getting layered pages
    List<Pages> pages = getCategoriesLayered();
    //creating vector for results
    LinkedList<UploadBean> rez = new LinkedList<UploadBean>();
    //creating an upload dir if it doesn't exists
    File upload_dir = new File(wallpaper_service.getUploadPath());
    if (!upload_dir.exists())
        upload_dir.mkdirs();/*w ww.ja  va2  s . co m*/
    //for saving parent catalogues
    Long last_layer = Long.valueOf(-1);
    LinkedList<File> parents = new LinkedList<File>();
    parents.addLast(upload_dir);
    for (Pages p : pages) {
        while (p.getLayer() <= last_layer) {
            //removing last parent
            parents.removeLast();
            last_layer--;
        }
        boolean b = false;
        File cur_dir = new File(parents.getLast(),
                String.valueOf(p.getId()) + "_" + FileUtils.toTranslit(p.getName()));
        if (cur_dir.exists()) {
            if (!cur_dir.isDirectory()) {
                cur_dir.delete();
                b = cur_dir.mkdir();
            }
        } else {
            b = cur_dir.mkdir();
        }
        createDescriptionFile(cur_dir, p.getId(), p.getName(), false);

        UploadBean ub = new UploadBean();
        ub.setId(p.getId());
        ub.setFolder_name(cur_dir.getName());
        ub.setPage_name(p.getName());
        ub.setItem_count(cur_dir.listFiles(filenameFilter).length - 1);
        rez.addLast(ub);

        parents.addLast(cur_dir);
        last_layer = p.getLayer();
    }
    return rez;
}

From source file:org.testmp.datastore.client.DataStoreClient.java

/**
 * Save data in data store into specified file with JSON representation
 * //from w  w  w  .ja  va 2s.c  o m
 * @param filepath
 * @throws DataStoreClientException
 */
public void saveDataToFile(String filepath) throws DataStoreClientException {
    List<Tag> tags = getTags();
    HashSet<Integer> idSet = new HashSet<Integer>();
    for (Tag tag : tags) {
        idSet.addAll(tag.getRelatedDataIds());
    }
    LinkedList<Integer> idList = new LinkedList<Integer>(idSet);
    Collections.sort(idList);
    int maxDataToGetEachTime = 500, i = 0;
    PrintWriter writer = null;
    try {
        writer = new PrintWriter(filepath, "UTF-8");
        writer.print("[");
        boolean isFirst = true;
        while (i < idList.size()) {
            int startId = idList.get(i);
            i = i + maxDataToGetEachTime - 1;
            int endId = (i >= idList.size() ? idList.getLast() : idList.get(i));
            i++;
            List<DataInfo<Object>> dataInfoList = getDataByRange(Object.class, startId, endId);
            for (DataInfo<Object> dataInfo : dataInfoList) {
                if (!isFirst) {
                    writer.println(",");
                } else {
                    isFirst = false;
                }
                writer.print(dataInfo.toString());
            }
        }
        writer.println("]");
    } catch (Exception e) {
        throw new DataStoreClientException("Failed to save data to file", e);
    } finally {
        if (writer != null) {
            writer.close();
        }
    }
}

From source file:edu.umd.cs.guitar.ripper.Ripper.java

/**
 * Rip a component//ww  w .  ja  v  a2  s .c  o  m
 *
 * As of now this method does not propagate exceptions.
 * It needs to be modified to progate exceptions. All callers
 * need to be modified to handle exceptions.
 *
 * <p>
 * 
 * @param component
 * @return
 */
public ComponentType ripComponent(GComponent component, GWindow window) {
    GUITARLog.log.info("");
    GUITARLog.log.info("----------------------------------");
    GUITARLog.log.info("Ripping component: ");
    GUITARLog.log.info("Signature: ");

    printComponentInfo(component, window);

    // 1. Rip special/customized components
    for (GComponentFilter cm : lComponentFilter) {
        if (cm.isProcess(component, window)) {
            GUITARLog.log.info("Filter " + cm.getClass().getSimpleName() + " is applied");

            return cm.ripComponent(component, window);
        }
    }

    // 2. Rip regular components
    ComponentType retComp = null;
    try {
        retComp = component.extractProperties();
        ComponentTypeWrapper compA = new ComponentTypeWrapper(retComp);

        if (useImage) {
            String sUUID = null;
            try {
                sUUID = captureImage(component);
            } catch (AWTException e) {
                // Ignore AWTException. sUUID is null.
            } catch (IOException e) {
                throw e;
            }

            if (sUUID != null) {
                compA.addProperty(GUITARConstants.UUID_TAG_NAME, sUUID);
            }
        }

        GUIType guiType = null;

        if (window != null) {
            guiType = window.extractGUIProperties();
        }

        retComp = compA.getDComponentType();

        // 2.1 Try to perform action on the component
        // to reveal more windows/components

        // clear window opened cache before performing actions
        monitor.resetWindowCache();

        if (monitor.isExpandable(component, window)) {
            monitor.expandGUI(component);
        } else {
            GUITARLog.log.info("Component is Unexpandable");
        }

        // Trigger terminal widget

        LinkedList<GWindow> lClosedWindows = monitor.getClosedWindowCache();

        String sTitle = window.getTitle();

        if (lClosedWindows.size() > 0) {

            GUITARLog.log.debug("!!!!! Window closed");

            for (GWindow closedWin : lClosedWindows) {
                String sClosedWinTitle = closedWin.getTitle();

                // Only consider widget closing the current window
                if (sTitle.equals(sClosedWinTitle)) {

                    GUITARLog.log.debug("\t" + sClosedWinTitle);

                    List<FullComponentType> lCloseComp = lCloseWindowComp.getFullComponent();

                    FullComponentType cCloseComp = factory.createFullComponentType();
                    cCloseComp.setWindow(closedWin.extractWindow().getWindow());
                    cCloseComp.setComponent(retComp);
                    lCloseComp.add(cCloseComp);
                    lCloseWindowComp.setFullComponent(lCloseComp);
                } // if
            } // for
        } // if

        if (monitor.isNewWindowOpened()) {

            List<FullComponentType> lOpenComp = lOpenWindowComps.getFullComponent();
            FullComponentType cOpenComp = factory.createFullComponentType();
            cOpenComp.setWindow(window.extractWindow().getWindow());
            cOpenComp.setComponent(retComp);
            lOpenComp.add(cOpenComp);
            lOpenWindowComps.setFullComponent(lOpenComp);

            LinkedList<GWindow> lNewWindows = monitor.getOpenedWindowCache();
            monitor.resetWindowCache();
            GUITARLog.log.info(lNewWindows.size() + " new window(s) opened!!!");
            for (GWindow newWins : lNewWindows) {
                GUITARLog.log.info("*\t Title:*" + newWins.getTitle() + "*");
            }

            // Process the opened windows in a FIFO order
            while (!lNewWindows.isEmpty()) {

                GWindow gNewWin = lNewWindows.getLast();
                lNewWindows.removeLast();

                GComponent gWinComp = gNewWin.getContainer();

                if (gWinComp != null) {

                    // Add invokelist property for the component
                    String sWindowTitle = gNewWin.getTitle();
                    compA = new ComponentTypeWrapper(retComp);
                    compA.addValueByName(GUITARConstants.INVOKELIST_TAG_NAME, sWindowTitle);

                    GUITARLog.log.debug(sWindowTitle + " recorded");

                    retComp = compA.getDComponentType();

                    // Check ignore window
                    if (!monitor.isIgnoredWindow(gNewWin)) {

                        if (!monitor.isRippedWindow(gNewWin)) {
                            gNewWin.setRoot(false);
                            monitor.addRippedList(gNewWin);

                            GUIType dWindow = ripWindow(gNewWin);

                            if (dWindow != null)
                                dGUIStructure.getGUI().add(dWindow);
                        } else {
                            GUITARLog.log.info("Window is ripped!!!");
                        }

                    } else {
                        GUITARLog.log.info("Window is ignored!!!");
                    }
                }

                monitor.closeWindow(gNewWin);
            }
        }

        // TODO: check if the component is still available after ripping
        // its child window
        List<GComponent> gChildrenList = component.getChildren();
        int nChildren = gChildrenList.size();
        int i = 0;

        // Debug

        String lChildren = "[";
        for (int j = 0; j < nChildren; j++) {
            lChildren += gChildrenList.get(j).getTitle() + " - " + gChildrenList.get(j).getClassVal() + "; ";
        }
        lChildren += "]";
        GUITARLog.log.debug("*" + component.getTitle() + "* in window *" + window.getTitle() + "* has "
                + nChildren + " children: " + lChildren);

        // End debug

        while (i < nChildren) {
            GComponent gChild = gChildrenList.get(i++);
            ComponentType guiChild = ripComponent(gChild, window);

            if (guiChild != null) {
                ((ContainerType) retComp).getContents().getWidgetOrContainer().add(guiChild);
            }

            if (nChildren < gChildrenList.size()) {
                nChildren = gChildrenList.size();
            }
        }

    } catch (Exception e) {
        if (e.getClass().getName().contains("StaleElementReferenceException")) {
            /**
             * This can happen when performing an action causes a page
             * navigation in the current window, for example, when
             * submitting a form.
             */
            GUITARLog.log.warn("Element went away: " + e.getMessage());
        } else {
            // TODO: Must throw exception
            GUITARLog.log.error("ripComponent exception", e);
        }

        /**
         * We'll return the component we calculated anyway so it
         * gets added to the GUI map. I'm not entirely sure this
         * is the right thing to do, but it gets us further anyway.
         */
        return retComp;
    }

    return retComp;
}

From source file:com.healthcit.cacure.businessdelegates.GeneratedModuleDataManager.java

@SuppressWarnings({ "unchecked" })
private JSONObject generateRandomAnswerValueForUniqueKey(Map question, Map uniqueKey,
        Map<String, JSONObject> lastUniqueKey, Map<Object, List<Object>> previousAnswers, Object groupId) {
    JSONObject randomAnswerValueObject;/*from w  w  w . j a  v  a2s  .com*/

    // Get the question's UUID
    String questionUUID = (String) question.get(UUID_VALUE);

    // If a random answer has already been generated for this question
    // (example, if this is a unique-per-all-modules question that is also
    // a unique-per-entity question, and the unique-per-entity question was processed first),
    // then simply copy the previously generated random answer for this unique key

    if (uniqueKey.containsKey(questionUUID)) {
        randomAnswerValueObject = (JSONObject) uniqueKey.get(questionUUID);

        return randomAnswerValueObject;
    }

    // else:
    else {
        // Get the previously generated unique keys as an ordered list
        LinkedList<Map.Entry> previousUniqueKeys = new LinkedList(((LinkedHashMap) previousAnswers).entrySet());

        // Get the value of the field which identifies the last unique group which was processed
        Map.Entry last = (previousUniqueKeys.isEmpty() ? null : previousUniqueKeys.getLast());

        List list = (last == null ? null : (List) last.getValue());

        Object lastGroupId = list == null ? null : Collections.synchronizedList(list).get(list.size() - 1);

        // If the current groupId matches the lastGroupId,
        // then it means that the same answer value should be used for the current unique key
        // ( since uniqueness is determined by the group )
        if (groupId.equals(lastGroupId)) {
            randomAnswerValueObject = new JSONObject();

            randomAnswerValueObject.putAll(lastUniqueKey.get(questionUUID));

            return randomAnswerValueObject;
        }

        // Otherwise, a new group is being processed, so generate a new random answer value
        else {
            // Determine the last generated random value for this question
            JSONObject lastRandomAnswerValueObject = lastUniqueKey.get(questionUUID);

            Object lastRandomAnswerValue = lastRandomAnswerValueObject == null ? null
                    : getAnswerValue(lastRandomAnswerValueObject);

            return generateRandomAnswerValue(question, lastRandomAnswerValue,
                    (lastRandomAnswerValue == null ? Algorithm.PSEUDORANDOM : Algorithm.EVEN));
        }
    }
}