Example usage for org.apache.commons.lang3.tuple MutableTriple MutableTriple

List of usage examples for org.apache.commons.lang3.tuple MutableTriple MutableTriple

Introduction

In this page you can find the example usage for org.apache.commons.lang3.tuple MutableTriple MutableTriple.

Prototype

public MutableTriple(final L left, final M middle, final R right) 

Source Link

Document

Create a new triple instance.

Usage

From source file:com.artistech.tuio.mouse.MouseDriver.java

/**
 * Add Cursor Event./* w ww .  j  a v  a2  s.  co  m*/
 *
 * @param tcur
 */
@Override
public void addTuioCursor(TuioCursor tcur) {
    logger.trace(MessageFormat.format("add tuio cursor id: {0}", tcur.getCursorID()));

    int width = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
    int height = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();

    boolean found = false;
    for (MutableTriple<Long, Integer, Integer> trip : curs) {
        if (trip.getLeft() == tcur.getSessionID()) {
            found = true;
            break;
        }
    }
    if (!found) {
        curs.add(new MutableTriple<>(tcur.getSessionID(), tcur.getScreenX(width), tcur.getScreenY(height)));
    }

    if (curs.size() == 1) {
        logger.debug(MessageFormat.format("add mouse move: ({0}, {1})",
                new Object[] { tcur.getScreenX(width), tcur.getScreenY(height) }));
        robot.mouseMove(tcur.getScreenX(width), tcur.getScreenY(height));
    } else {
        logger.debug(MessageFormat.format("add mouse press: {0}", tcur.getCursorID()));
        if (curs.size() == 2) {
            robot.mousePress(InputEvent.BUTTON1_MASK);
        } else {
            robot.mousePress(InputEvent.BUTTON3_MASK);
            robot.mouseRelease(InputEvent.BUTTON3_MASK);
        }
    }
}

From source file:edu.nyu.tandon.tool.BinnedRawHits.java

private static void dumpPosthits(BinnedRawHits query, long numDocs, boolean endRun) {

    Collections.sort(query.postHits);
    ImmutableTriple<Integer, Integer, Integer> t;
    Triple<Integer, Integer, Integer> lastT = new MutableTriple<>(-1, -1, -1);
    int hits = 0;
    for (int i = 0; i < query.postHits.size(); i++) {
        t = query.postHits.get(i);//from  w w  w  .  ja v  a 2  s.c o  m
        if (t.compareTo(lastT) != 0) {
            if (hits > 0) {
                // format: doc, term, , rank, #hits
                query.outputPH.printf("%d,%d,%d,%d\n", lastT.getLeft(), lastT.getMiddle(), lastT.getRight(),
                        hits);
            }
            hits = 0;
            lastT = t;
        }
        hits++;
    }
    query.postHits.clear();
    if (query.outputDH != System.out) {
        query.outputPH.close();
    }
    if (!endRun) {
        try {
            query.outputPH = new PrintStream(new FastBufferedOutputStream(
                    new FileOutputStream(outputName + "-" + phBatch++ + ".ph.txt")));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.pearson.eidetic.driver.threads.subthreads.SnapshotVolumeSyncValidator.java

@Override
public void run() {
    isFinished_ = false;/*from   ww w . j  a  v  a2  s  .  c om*/
    AmazonEC2Client ec2Client = connect(region_, awsAccessKeyId_, awsSecretKey_);

    for (Volume vol : VolumeSyncValidate_) {
        try {

            JSONParser parser = new JSONParser();

            String inttagvalue = getIntTagValue(vol);
            if (inttagvalue == null) {
                continue;
            }

            JSONObject eideticParameters;
            try {
                Object obj = parser.parse(inttagvalue);
                eideticParameters = (JSONObject) obj;
            } catch (Exception e) {
                logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_
                        + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId()
                        + "\", stacktrace=\"" + e.toString() + System.lineSeparator()
                        + StackTrace.getStringFromStackTrace(e) + "\"");
                continue;
            }
            if (eideticParameters == null) {
                continue;
            }

            //Same
            Integer keep = getKeep(eideticParameters, vol);
            if (keep == null) {
                continue;
            }

            JSONObject syncSnapshot = null;
            if (eideticParameters.containsKey("SyncSnapshot")) {
                syncSnapshot = (JSONObject) eideticParameters.get("SyncSnapshot");
            }
            if (syncSnapshot == null) {
                logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_
                        + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId()
                        + "\"");
                continue;
            }

            JSONObject validateParameters;
            try {
                validateParameters = (JSONObject) syncSnapshot.get("Validate");
            } catch (Exception e) {
                logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_
                        + "\",Event=Error, Error=\"Malformed Eidetic Tag\", Volume_id=\"" + vol.getVolumeId()
                        + "\", stacktrace=\"" + e.toString() + System.lineSeparator()
                        + StackTrace.getStringFromStackTrace(e) + "\"");
                continue;
            }

            Integer createAfter = getCreateAfter(validateParameters, vol);

            String cluster = getCluster(validateParameters, vol);

            if (validateCluster_.containsKey(cluster)) {
                validateCluster_.get(cluster).add(new MutableTriple(vol, createAfter, keep));
            } else {
                validateCluster_.put(cluster, new ArrayList<MutableTriple<Volume, Integer, Integer>>());
                validateCluster_.get(cluster).add(new MutableTriple(vol, createAfter, keep));
            }

        } catch (Exception e) {
            logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_
                    + "\",Event=\"Error\", Error=\"error in SnapshotVolumeSync workflow\", stacktrace=\""
                    + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\"");
        }

    }

    for (String cluster : validateCluster_.keySet()) {

        try {
            ArrayList<MutableTriple<Volume, Integer, Integer>> myList = validateCluster_.get(cluster);

            Boolean snapshotCluster = false;
            Integer min = Integer.MAX_VALUE;
            for (MutableTriple trip : myList) {
                if (((Integer) trip.getMiddle()) < min) {
                    min = (Integer) trip.getMiddle();
                }
            }

            for (MutableTriple trip : myList) {
                if (snapshotDecision(ec2Client, (Volume) trip.getLeft(), min)) {
                    snapshotCluster = true;
                }
            }

            if (snapshotCluster) {
                ArrayList<Volume> vols = new ArrayList<>();
                for (MutableTriple trip : myList) {
                    vols.add((Volume) trip.getLeft());
                }

                SnapshotVolumeSync thread = new SnapshotVolumeSync(awsAccessKeyId_, awsSecretKey_,
                        uniqueAwsAccountIdentifier_, maxApiRequestsPerSecond_,
                        ApplicationConfiguration.getAwsCallRetryAttempts(), region_, vols, true);

                try {
                    thread.run();
                } catch (Exception e) {
                    String responseMessage = "Error running cluster validator thread for cluster " + cluster;
                    logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_ + "\",Error=\""
                            + responseMessage + "\"" + e.toString() + System.lineSeparator()
                            + StackTrace.getStringFromStackTrace(e) + "\"");
                }

                Integer wait = 0;
                while (!(thread.isFinished()) && (wait <= 200)) {
                    Threads.sleepMilliseconds(250);
                    //break after 50 seconds
                    wait = wait + 1;
                }

            }

        } catch (Exception e) {
            logger.error("awsAccountId=\"" + uniqueAwsAccountIdentifier_
                    + "\",Event=\"Error\", Error=\"error in SnapshotVolumeSync workflow\", stacktrace=\""
                    + e.toString() + System.lineSeparator() + StackTrace.getStringFromStackTrace(e) + "\"");
        }

    }

    ec2Client.shutdown();
    isFinished_ = true;
}

From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplateLibrariesPanel.java

private void initComponents(Channel channel) {
    setBackground(UIConstants.BACKGROUND_COLOR);

    selectAllLabel = new JLabel("<html><u>Select All</u></html>");
    selectAllLabel.setForeground(Color.BLUE);
    selectAllLabel.addMouseListener(new MouseAdapter() {
        @Override/*from   w w w . ja  v  a 2 s .c  o  m*/
        public void mouseReleased(MouseEvent evt) {
            for (Enumeration<? extends MutableTreeTableNode> libraryNodes = ((MutableTreeTableNode) libraryTreeTable
                    .getTreeTableModel().getRoot()).children(); libraryNodes.hasMoreElements();) {
                MutableTreeTableNode libraryNode = libraryNodes.nextElement();
                Triple<String, String, Boolean> triple = (Triple<String, String, Boolean>) libraryNode
                        .getUserObject();
                libraryTreeTable.getTreeTableModel().setValueAt(
                        new MutableTriple<String, String, Boolean>(triple.getLeft(), triple.getMiddle(), true),
                        libraryNode, libraryTreeTable.getHierarchicalColumn());
            }
            libraryTreeTable.updateUI();
        }
    });

    selectSeparatorLabel = new JLabel("|");

    deselectAllLabel = new JLabel("<html><u>Deselect All</u></html>");
    deselectAllLabel.setForeground(Color.BLUE);
    deselectAllLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent evt) {
            for (Enumeration<? extends MutableTreeTableNode> libraryNodes = ((MutableTreeTableNode) libraryTreeTable
                    .getTreeTableModel().getRoot()).children(); libraryNodes.hasMoreElements();) {
                MutableTreeTableNode libraryNode = libraryNodes.nextElement();
                Triple<String, String, Boolean> triple = (Triple<String, String, Boolean>) libraryNode
                        .getUserObject();
                libraryTreeTable.getTreeTableModel().setValueAt(
                        new MutableTriple<String, String, Boolean>(triple.getLeft(), triple.getMiddle(), false),
                        libraryNode, libraryTreeTable.getHierarchicalColumn());
            }
            libraryTreeTable.updateUI();
        }
    });

    expandAllLabel = new JLabel("<html><u>Expand All</u></html>");
    expandAllLabel.setForeground(Color.BLUE);
    expandAllLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent evt) {
            libraryTreeTable.expandAll();
        }
    });

    expandSeparatorLabel = new JLabel("|");

    collapseAllLabel = new JLabel("<html><u>Collapse All</u></html>");
    collapseAllLabel.setForeground(Color.BLUE);
    collapseAllLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent evt) {
            libraryTreeTable.collapseAll();
        }
    });

    final TableCellEditor libraryCellEditor = new LibraryTreeCellEditor();

    libraryTreeTable = new MirthTreeTable() {
        @Override
        public TableCellEditor getCellEditor(int row, int column) {
            if (isHierarchical(column)) {
                return libraryCellEditor;
            } else {
                return super.getCellEditor(row, column);
            }
        }
    };

    DefaultTreeTableModel model = new SortableTreeTableModel();
    DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode();
    model.setRoot(rootNode);

    libraryTreeTable.setLargeModel(true);
    libraryTreeTable.setTreeTableModel(model);
    libraryTreeTable.setOpenIcon(null);
    libraryTreeTable.setClosedIcon(null);
    libraryTreeTable.setLeafIcon(null);
    libraryTreeTable.setRootVisible(false);
    libraryTreeTable.setDoubleBuffered(true);
    libraryTreeTable.setDragEnabled(false);
    libraryTreeTable.setRowSelectionAllowed(true);
    libraryTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    libraryTreeTable.setRowHeight(UIConstants.ROW_HEIGHT);
    libraryTreeTable.setFocusable(true);
    libraryTreeTable.setOpaque(true);
    libraryTreeTable.setEditable(true);
    libraryTreeTable.setSortable(false);
    libraryTreeTable.setAutoCreateColumnsFromModel(false);
    libraryTreeTable.setShowGrid(true, true);
    libraryTreeTable.setTableHeader(null);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        libraryTreeTable.setHighlighters(HighlighterFactory
                .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR));
    }

    libraryTreeTable.setTreeCellRenderer(new LibraryTreeCellRenderer());

    libraryTreeTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent evt) {
            checkSelection(evt);
        }

        @Override
        public void mouseReleased(MouseEvent evt) {
            checkSelection(evt);
        }

        private void checkSelection(MouseEvent evt) {
            if (libraryTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) {
                libraryTreeTable.clearSelection();
            }
        }
    });

    libraryTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                boolean visible = false;
                int selectedRow = libraryTreeTable.getSelectedRow();

                if (selectedRow >= 0) {
                    TreePath selectedPath = libraryTreeTable.getPathForRow(selectedRow);
                    if (selectedPath != null) {
                        visible = true;
                        Triple<String, String, Boolean> triple = (Triple<String, String, Boolean>) ((MutableTreeTableNode) selectedPath
                                .getLastPathComponent()).getUserObject();
                        String description = "";

                        if (selectedPath.getPathCount() == 2) {
                            description = libraryMap.get(triple.getLeft()).getDescription();
                        } else if (selectedPath.getPathCount() == 3) {
                            description = PlatformUI.MIRTH_FRAME.codeTemplatePanel.getCachedCodeTemplates()
                                    .get(triple.getLeft()).getDescription();
                        }

                        if (StringUtils.isBlank(description) || StringUtils.equals(description, CodeTemplateUtil
                                .getDocumentation(CodeTemplate.DEFAULT_CODE).getDescription())) {
                            descriptionTextPane.setText(
                                    "<html><body class=\"code-template-libraries-panel\"><i>No description.</i></body></html>");
                        } else {
                            descriptionTextPane.setText("<html><body class=\"code-template-libraries-panel\">"
                                    + MirthXmlUtil.encode(description) + "</body></html>");
                        }
                    }
                }

                descriptionScrollPane.setVisible(visible);
                updateUI();
            }
        }
    });

    libraryTreeTableScrollPane = new JScrollPane(libraryTreeTable);

    descriptionTextPane = new JTextPane();
    descriptionTextPane.setContentType("text/html");
    HTMLEditorKit editorKit = new HTMLEditorKit();
    StyleSheet styleSheet = editorKit.getStyleSheet();
    styleSheet.addRule(".code-template-libraries-panel {font-family:\"Tahoma\";font-size:11;text-align:top}");
    descriptionTextPane.setEditorKit(editorKit);
    descriptionTextPane.setEditable(false);
    descriptionScrollPane = new JScrollPane(descriptionTextPane);
    descriptionScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    descriptionScrollPane.setVisible(false);
}

From source file:com.acmutv.ontoqa.core.parser.SimpleSltagParserNew.java

private static void processSubstitutions(ParserStateNew state) throws LTAGException {
    Integer idxPrev = state.getIdxPrev();
    Sltag curr = state.getCurr();/*from w  w w.ja v a 2 s . c  o  m*/

    Iterator<LtagNode> substitutionTargets = curr.getNodesDFS(LtagNodeMarker.SUB).iterator();
    while (substitutionTargets.hasNext()) {
        LtagNode substitutionTarget = substitutionTargets.next();
        Iterator<Candidate> waitingSubstitutionCandidates = state.getWaitSubstitutions().iterator();
        while (waitingSubstitutionCandidates.hasNext()) {
            Candidate waitingSubstitutionCandidate = waitingSubstitutionCandidates.next();
            Sltag substitutionCandidate = waitingSubstitutionCandidate.getSltag();
            if (substitutionTarget.getCategory()
                    .equals(substitutionCandidate.getRoot().getCategory())) { /* CAN MAKE SUBSTITUTION */
                if (curr.getSemantics().getMainVariable() == null && substitutionCandidate.getSemantics()
                        .getMainVariable() != null) { /* RECORD A MAIN VARIABLE MISS */
                    int pos = (idxPrev != null) ? idxPrev + 1 : 0;
                    Variable mainVar = substitutionCandidate.getSemantics().getMainVariable();
                    Set<Statement> statements = substitutionCandidate.getSemantics().getStatements(mainVar);
                    curr.substitution(substitutionCandidate, substitutionTarget);
                    Variable renamedVar = curr.getSemantics().findRenaming(mainVar, statements);
                    if (renamedVar != null) {
                        Triple<Variable, Variable, Set<Statement>> missedRecord = new MutableTriple<>(mainVar,
                                renamedVar, statements);
                        state.getMissedMainVariables().put(pos, missedRecord);
                        LOGGER.info(
                                "Recorded main variable: pos: {} | mainVar: {} renamed to {} | statements: {} ",
                                pos, mainVar, renamedVar, statements);
                    }
                } else {
                    curr.substitution(substitutionCandidate, substitutionTarget);
                }
                LOGGER.debug("Substituted {} with:\n{}", substitutionTarget,
                        substitutionCandidate.toPrettyString());
                waitingSubstitutionCandidates.remove();
                substitutionTargets = curr.getNodesDFS(LtagNodeMarker.SUB).iterator();
                break;
            }
        }
    }
}

From source file:com.acmutv.ontoqa.core.parser.SimpleSltagParser.java

private static void processSubstitutions(ParserState dashboard) throws LTAGException {
    Integer idxPrev = dashboard.getIdxPrev();
    Sltag curr = dashboard.getCurr();//from  w  ww. j a va 2 s  .  c om

    Iterator<LtagNode> localSubstitutions = curr.getNodesDFS(LtagNodeMarker.SUB).iterator();
    while (localSubstitutions.hasNext()) {
        LtagNode localTarget = localSubstitutions.next();
        Iterator<Pair<Sltag, Integer>> waitingSubstitutions = dashboard.getSubstitutions().iterator();
        while (waitingSubstitutions.hasNext()) {
            Pair<Sltag, Integer> entry = waitingSubstitutions.next();
            Sltag waitingSubstitution = entry.getKey();
            if (localTarget.getCategory()
                    .equals(waitingSubstitution.getRoot().getCategory())) { /* CAN MAKE SUBSTITUTION */
                if (curr.getSemantics().getMainVariable() == null && waitingSubstitution.getSemantics()
                        .getMainVariable() != null) { /* RECORD A MAIN VARIABLE MISS */
                    int pos = (idxPrev != null) ? idxPrev + 1 : 0;
                    Variable mainVar = waitingSubstitution.getSemantics().getMainVariable();
                    Set<Statement> statements = waitingSubstitution.getSemantics().getStatements(mainVar);
                    curr.substitution(waitingSubstitution, localTarget);
                    Variable renamedVar = curr.getSemantics().findRenaming(mainVar, statements);
                    if (renamedVar != null) {
                        Triple<Variable, Variable, Set<Statement>> missedRecord = new MutableTriple<>(mainVar,
                                renamedVar, statements);
                        dashboard.getMissedMainVariables().put(pos, missedRecord);
                        LOGGER.info(
                                "Recorded main variable: pos: {} | mainVar: {} renamed to {} | statements: {} ",
                                pos, mainVar, renamedVar, statements);
                    }
                } else {
                    curr.substitution(waitingSubstitution, localTarget);
                }
                LOGGER.debug("Substituted {} with:\n{}", localTarget, waitingSubstitution.toPrettyString());
                waitingSubstitutions.remove();
                localSubstitutions = curr.getNodesDFS(LtagNodeMarker.SUB).iterator();
                break;
            }
        }
    }
}

From source file:com.acmutv.ontoqa.core.parser.AdvancedSltagParser.java

/**
 * Consumes waiting substitutions./*from   w ww. ja  v  a  2  s.co  m*/
 * @param state the parser state.
 */
private static void consumeWaitingSubstitutions(ParserStateNew state) throws LTAGException {
    if (state.getWaitSubstitutions().isEmpty()) {
        LOGGER.debug("[QUEUE CONSUMPTION] :: no waiting substitutions to consume");
        return;
    }

    Integer idxPrev = state.getIdxPrev();
    Sltag curr = state.getCurr();

    Iterator<LtagNode> substitutionTargets = curr.getNodesDFS(LtagNodeMarker.SUB).iterator();
    while (substitutionTargets.hasNext()) {
        LtagNode substitutionTarget = substitutionTargets.next();
        Iterator<Candidate> waitingSubstitutionCandidates = state.getWaitSubstitutions().iterator();
        while (waitingSubstitutionCandidates.hasNext()) {
            Candidate waitingSubstitutionCandidate = waitingSubstitutionCandidates.next();
            Sltag substitutionCandidate = waitingSubstitutionCandidate.getSltag();
            if (substitutionTarget.getCategory()
                    .equals(substitutionCandidate.getRoot().getCategory())) { /* CAN MAKE SUBSTITUTION */
                if (curr.getSemantics().getMainVariable() == null && substitutionCandidate.getSemantics()
                        .getMainVariable() != null) { /* RECORD A MAIN VARIABLE MISS */
                    int pos = (idxPrev != null) ? idxPrev + 1 : 0;
                    Variable mainVar = substitutionCandidate.getSemantics().getMainVariable();
                    Set<Statement> statements = substitutionCandidate.getSemantics().getStatements(mainVar);
                    curr.substitution(substitutionCandidate, substitutionTarget);
                    Variable renamedVar = curr.getSemantics().findRenaming(mainVar, statements);
                    if (renamedVar != null) {
                        Triple<Variable, Variable, Set<Statement>> missedRecord = new MutableTriple<>(mainVar,
                                renamedVar, statements);
                        state.getMissedMainVariables().put(pos, missedRecord);
                        LOGGER.debug(
                                "[QUEUE CONSUMPTION] :: recorded main variable: pos: {} | mainVar: {} renamed to {} | statements: {} ",
                                pos, mainVar, renamedVar, statements);
                    }
                } else {
                    curr.substitution(substitutionCandidate, substitutionTarget);
                }
                LOGGER.debug("[QUEUE CONSUMPTION] :: substituted {} with:\n{}", substitutionTarget,
                        substitutionCandidate.toPrettyString());
                waitingSubstitutionCandidates.remove();
                substitutionTargets = curr.getNodesDFS(LtagNodeMarker.SUB).iterator();
                break;
            }
        }
    }
}

From source file:com.drisoftie.action.async.BaseAsyncAction.java

/**
 * Like {@link #BaseAsyncAction(ViewT, Class, String, String[], Object, Object, Object...)},
 * but with multiple callback interface implementations.
 *
 * @param view              the <b>optional</b> {@link android.view.View} this {@link com.drisoftie.action.async.BaseAsyncAction} is
 *                          bound to; if {@code null}, {@code regMethodName} is ignored
 * @param actionTypes       an {@link java.lang.reflect.Array} of Java Interfaces this
 *                          {@link com.drisoftie.action.async.BaseAsyncAction} implements
 * @param regMethodName     the name of the registration {@link java.lang.reflect.Method} used to bind this
 *                          {@link com.drisoftie.action.async.BaseAsyncAction} to the given {@link android.view.View}; case
 *                          sensitive;//from  w  ww  . java  2  s  .co  m
 *                          <b>MUST</b> be of the signature regMethodName(ActionType actionType); tries to bind every given
 *                          {@code actionType} to the given {@link android.view.View}
 * @param actionMethodNames can be {@code null}; the names of the {@link java.lang.reflect.Method}s that should be invoked,
 *                          all others will be ignored
 * @param tag1              optional tag
 * @param tag2              optional tag
 * @param additionalTags    optional tags
 */
public BaseAsyncAction(ViewT view, Class<?>[] actionTypes, String regMethodName, String[] actionMethodNames,
        Tag1T tag1, Tag2T tag2, Object... additionalTags) {
    List<BaseAsyncAction.ActionBinding<ViewT>> bindings = new ArrayList<>();

    ActionBinding<ViewT> binding = new ActionBinding<>();
    binding.view = view;
    for (Class<?> actionType : actionTypes) {
        binding.registrations.add(
                new MutableTriple<Class<?>, String, String[]>(actionType, regMethodName, actionMethodNames));
    }

    bindings.add(binding);

    this.tag1 = tag1;
    this.tag2 = tag2;
    this.tags = additionalTags;

    this.bindings = bindings;

    registerAction();
}

From source file:com.drisoftie.action.async.BaseAsyncAction.java

/**
 * Like {@link #BaseAsyncAction(ViewT, Class, String, String[], Object, Object, Object...)},
 * but with multiple target views and callback interface implementations.
 *
 * @param views             the <b>optional</b> {@link android.view.View}s this {@link com.drisoftie.action.async.BaseAsyncAction} is
 *                          bound to; if {@code null}, {@code regMethodName} is ignored
 * @param actionTypes       an {@link java.lang.reflect.Array} of Java Interfaces this
 *                          {@link com.drisoftie.action.async.BaseAsyncAction} implements
 * @param regMethodName     the name of the registration {@link java.lang.reflect.Method} used to bind this
 *                          {@link com.drisoftie.action.async.BaseAsyncAction} to the given {@link android.view.View}; case
 *                          sensitive;/*from   w w  w .j  a  v a 2 s  . c om*/
 *                          <b>MUST</b> be of the signature regMethodName(ActionType actionType); tries to bind every given
 *                          {@code actionType} to the given {@link android.view.View}
 * @param actionMethodNames can be {@code null}; the names of the {@link java.lang.reflect.Method}s that should be invoked,
 *                          all others will be ignored
 * @param tag1              optional tag
 * @param tag2              optional tag
 * @param additionalTags    optional tags
 */
public BaseAsyncAction(ViewT[] views, Class<?>[] actionTypes, String regMethodName, String[] actionMethodNames,
        Tag1T tag1, Tag2T tag2, Object... additionalTags) {
    List<BaseAsyncAction.ActionBinding<ViewT>> bindings = new ArrayList<>();

    if (ArrayUtils.isNotEmpty(views)) {
        for (ViewT view : views) {
            ActionBinding<ViewT> binding = new ActionBinding<>();
            binding.view = view;
            for (Class<?> actionType : actionTypes) {
                binding.registrations.add(new MutableTriple<Class<?>, String, String[]>(actionType,
                        regMethodName, actionMethodNames));
            }

            bindings.add(binding);
        }
    } else {
        ActionBinding<ViewT> binding = new ActionBinding<>();
        for (Class<?> actionType : actionTypes) {
            binding.registrations.add(new MutableTriple<Class<?>, String, String[]>(actionType, regMethodName,
                    actionMethodNames));
        }
        bindings.add(binding);
    }

    this.tag1 = tag1;
    this.tag2 = tag2;
    this.tags = additionalTags;

    this.bindings = bindings;

    registerAction();
}

From source file:storm.lrb.bolt.LastAverageSpeedBolt.java

@Override
public void execute(Tuple tuple) {

    int minuteOfTuple = tuple.getIntegerByField(TopologyControl.MINUTE_FIELD_NAME);
    int xway = tuple.getIntegerByField(TopologyControl.XWAY_FIELD_NAME);
    int seg = tuple.getIntegerByField(TopologyControl.SEGMENT_FIELD_NAME);
    int dir = tuple.getIntegerByField(TopologyControl.DIRECTION_FIELD_NAME);
    int carcnt = tuple.getIntegerByField(TopologyControl.CAR_COUNT_FIELD_NAME);
    double avgs = tuple.getDoubleByField(TopologyControl.AVERAGE_SPEED_FIELD_NAME);

    Triple<Integer, Integer, Integer> segmentKey = new MutableTriple<Integer, Integer, Integer>(xway, seg, dir);
    List<Double> latestAvgSpeeds = this.listOfavgs.get(segmentKey);
    List<Integer> latestCarCnt = this.listOfVehicleCounts.get(segmentKey);

    if (latestAvgSpeeds == null) {
        // initialize the list for the full time so we can use the indices to keep track of time/speed
        latestAvgSpeeds = new ArrayList<Double>(Collections.nCopies(TOTAL_MINS, 0.0));// new ArrayList<Double>();
        this.listOfavgs.put(segmentKey, latestAvgSpeeds);
    }/*from   w w w.j  a v  a 2s. com*/

    latestAvgSpeeds.add(minuteOfTuple, avgs);

    if (latestCarCnt == null) {
        latestCarCnt = new ArrayList<Integer>(Collections.nCopies(TOTAL_MINS, 0));
        this.listOfVehicleCounts.put(segmentKey, latestCarCnt);

    }

    latestCarCnt.add(minuteOfTuple, carcnt);
    this.emitLav(segmentKey, latestCarCnt, latestAvgSpeeds, minuteOfTuple);

    this.collector.ack(tuple);

}