Example usage for org.apache.commons.lang3.tuple Triple getLeft

List of usage examples for org.apache.commons.lang3.tuple Triple getLeft

Introduction

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

Prototype

public abstract L getLeft();

Source Link

Document

Gets the left element from this triple.

Usage

From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToLongTriFunction.java

/**
 * Applies this function to the given tuple.
 *
 * @param tuple The tuple to be applied to the function
 * @return The return value from the function, which is its result.
 * @throws NullPointerException If given argument is {@code null}
 * @throws X Any throwable from this functions action
 * @see org.apache.commons.lang3.tuple.Triple
 *//* w w  w .  j  a  va2 s.  c om*/
default long applyAsLongThrows(@Nonnull Triple<T, U, V> tuple) throws X {
    Objects.requireNonNull(tuple);
    return applyAsLongThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight());
}

From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToFloatTriFunction.java

/**
 * Applies this function to the given tuple.
 *
 * @param tuple The tuple to be applied to the function
 * @return The return value from the function, which is its result.
 * @throws NullPointerException If given argument is {@code null}
 * @throws X Any throwable from this functions action
 * @see org.apache.commons.lang3.tuple.Triple
 *///  ww  w  .j a  v  a  2 s . c  o m
default float applyAsFloatThrows(@Nonnull Triple<T, U, V> tuple) throws X {
    Objects.requireNonNull(tuple);
    return applyAsFloatThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight());
}

From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToShortTriFunction.java

/**
 * Applies this function to the given tuple.
 *
 * @param tuple The tuple to be applied to the function
 * @return The return value from the function, which is its result.
 * @throws NullPointerException If given argument is {@code null}
 * @throws X Any throwable from this functions action
 * @see org.apache.commons.lang3.tuple.Triple
 *///from  w  w w  . ja va2s.c  om
default short applyAsShortThrows(@Nonnull Triple<T, U, V> tuple) throws X {
    Objects.requireNonNull(tuple);
    return applyAsShortThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight());
}

From source file:at.gridtec.lambda4j.function.tri.to.ThrowableToDoubleTriFunction.java

/**
 * Applies this function to the given tuple.
 *
 * @param tuple The tuple to be applied to the function
 * @return The return value from the function, which is its result.
 * @throws NullPointerException If given argument is {@code null}
 * @throws X Any throwable from this functions action
 * @see org.apache.commons.lang3.tuple.Triple
 *//*  www  .j av a  2  s.c  o m*/
default double applyAsDoubleThrows(@Nonnull Triple<T, U, V> tuple) throws X {
    Objects.requireNonNull(tuple);
    return applyAsDoubleThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight());
}

From source file:blusunrize.immersiveengineering.common.items.ItemDrill.java

@Override
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState state, BlockPos pos,
        EntityLivingBase living) {//from ww w.  j  av  a2  s.  c  o m
    if ((double) state.getBlockHardness(world, pos) != 0.0D) {
        int dmg = ForgeHooks.isToolEffective(world, pos, stack) ? 1 : 3;
        ItemStack head = getHead(stack);
        if (!head.isEmpty()) {
            if (living instanceof EntityPlayer) {
                if (((EntityPlayer) living).capabilities.isCreativeMode)
                    return true;
                ((IDrillHead) head.getItem()).afterBlockbreak(stack, head, (EntityPlayer) living);
            }
            if (!getUpgrades(stack).getBoolean("oiled") || Utils.RAND.nextInt(4) == 0)
                ((IDrillHead) head.getItem()).damageHead(head, dmg);
            this.setHead(stack, head);
            IFluidHandler handler = FluidUtil.getFluidHandler(stack);
            handler.drain(1, true);

            Triple<ItemStack, ShaderRegistryEntry, ShaderCase> shader = ShaderRegistry
                    .getStoredShaderAndCase(stack);
            if (shader != null)
                shader.getMiddle().getEffectFunction().execute(world, shader.getLeft(), stack,
                        shader.getRight().getShaderType(),
                        new Vec3d(pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5), null, .375f);
        }
    }

    return true;
}

From source file:blusunrize.immersiveengineering.common.EventHandler.java

@SubscribeEvent
public void onMinecartUpdate(MinecartUpdateEvent event) {
    if (event.getMinecart().ticksExisted % 3 == 0
            && event.getMinecart().hasCapability(CapabilityShader.SHADER_CAPABILITY, null)) {
        ShaderWrapper wrapper = event.getMinecart().getCapability(CapabilityShader.SHADER_CAPABILITY, null);
        if (wrapper != null) {
            Vec3d prevPosVec = new Vec3d(event.getMinecart().prevPosX, event.getMinecart().prevPosY,
                    event.getMinecart().prevPosZ);
            Vec3d movVec = prevPosVec.subtract(event.getMinecart().posX, event.getMinecart().posY,
                    event.getMinecart().posZ);
            if (movVec.lengthSquared() > 0.0001) {
                movVec = movVec.normalize();
                Triple<ItemStack, ShaderRegistryEntry, ShaderCase> shader = ShaderRegistry
                        .getStoredShaderAndCase(wrapper);
                if (shader != null)
                    shader.getMiddle().getEffectFunction().execute(event.getMinecart().world, shader.getLeft(),
                            null, shader.getRight().getShaderType(), prevPosVec.add(0, .25, 0).add(movVec),
                            movVec.scale(1.5f), .25f);
            }/*  w  w  w . j a v  a 2 s. c o  m*/
        }
    }
}

From source file:blusunrize.immersiveengineering.common.items.ItemRailgun.java

@Override
public void onUsingTick(ItemStack stack, EntityLivingBase user, int count) {
    int inUse = this.getMaxItemUseDuration(stack) - count;
    if (inUse > getChargeTime(stack) && inUse % 20 == user.getRNG().nextInt(20)) {
        user.world.playSound(null, user.posX, user.posY, user.posZ, IESounds.spark, SoundCategory.PLAYERS,
                .8f + (.2f * user.getRNG().nextFloat()), .5f + (.5f * user.getRNG().nextFloat()));
        Triple<ItemStack, ShaderRegistryEntry, ShaderCase> shader = ShaderRegistry
                .getStoredShaderAndCase(stack);
        if (shader != null) {
            Vec3d pos = Utils.getLivingFrontPos(user, .4375, user.height * .75,
                    user.getActiveHand() == EnumHand.MAIN_HAND ? user.getPrimaryHand()
                            : user.getPrimaryHand().opposite(),
                    false, 1);/*from w ww  . ja  v a 2  s. c o m*/
            shader.getMiddle().getEffectFunction().execute(user.world, shader.getLeft(), stack,
                    shader.getRight().getShaderType(), pos, null, .0625f);
        }
    }
}

From source file:at.gridtec.lambda4j.predicate.tri.ThrowableTriPredicate.java

/**
 * Applies this predicate to the given tuple.
 *
 * @param tuple The tuple to be applied to the predicate
 * @return The return value from the predicate, which is its result.
 * @throws NullPointerException If given argument is {@code null}
 * @throws X Any throwable from this predicates action
 * @see org.apache.commons.lang3.tuple.Triple
 *//*from w  w w.  j  a  va  2s.  com*/
default boolean testThrows(@Nonnull Triple<T, U, V> tuple) throws X {
    Objects.requireNonNull(tuple);
    return testThrows(tuple.getLeft(), tuple.getMiddle(), tuple.getRight());
}

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 ww .jav  a2 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:blusunrize.immersiveengineering.common.items.ItemRailgun.java

@Override
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase user, int timeLeft) {
    if (user instanceof EntityPlayer) {
        int inUse = this.getMaxItemUseDuration(stack) - timeLeft;
        ItemNBTHelper.remove(stack, "inUse");
        if (inUse < getChargeTime(stack))
            return;
        int energy = IEConfig.Tools.railgun_consumption;
        float energyMod = 1 + this.getUpgrades(stack).getFloat("consumption");
        energy = (int) (energy * energyMod);
        if (this.extractEnergy(stack, energy, true) == energy) {
            ItemStack ammo = findAmmo((EntityPlayer) user);
            if (!ammo.isEmpty()) {
                Vec3d vec = user.getLookVec();
                float speed = 20;
                EntityRailgunShot shot = new EntityRailgunShot(user.world, user, vec.x * speed, vec.y * speed,
                        vec.z * speed, Utils.copyStackWithAmount(ammo, 1));
                ammo.shrink(1);//from  www  .j a v a  2s  . c  o  m
                if (ammo.getCount() <= 0)
                    ((EntityPlayer) user).inventory.deleteStack(ammo);
                user.world.playSound(null, user.posX, user.posY, user.posZ, IESounds.railgunFire,
                        SoundCategory.PLAYERS, 1, .5f + (.5f * user.getRNG().nextFloat()));
                this.extractEnergy(stack, energy, false);
                if (!world.isRemote)
                    user.world.spawnEntity(shot);

                Triple<ItemStack, ShaderRegistryEntry, ShaderCase> shader = ShaderRegistry
                        .getStoredShaderAndCase(stack);
                if (shader != null) {
                    Vec3d pos = Utils.getLivingFrontPos(user, .75, user.height * .75,
                            user.getActiveHand() == EnumHand.MAIN_HAND ? user.getPrimaryHand()
                                    : user.getPrimaryHand().opposite(),
                            false, 1);
                    shader.getMiddle().getEffectFunction().execute(world, shader.getLeft(), stack,
                            shader.getRight().getShaderType(), pos, user.getForward(), .125f);
                }
            }
        }
    }
}