Example usage for com.google.common.primitives Ints join

List of usage examples for com.google.common.primitives Ints join

Introduction

In this page you can find the example usage for com.google.common.primitives Ints join.

Prototype

public static String join(String separator, int... array) 

Source Link

Document

Returns a string containing the supplied int values separated by separator .

Usage

From source file:suneido.database.immudb.IndexInfo.java

void addToRecord(RecordBuilder rb) {
    assert root != 0;
    rb.add(Ints.join(",", columns)).add(root).add(treeLevels).add(nnodes).add(totalSize);
}

From source file:suneido.database.immudb.Index.java

private static DataRecord toRecord(int tblnum, int[] colNums, boolean isKey, boolean unique,
        ForeignKeySource fksrc) {/*from w ww.ja  va  2 s  . c om*/
    RecordBuilder rb = new RecordBuilder();
    rb.add(tblnum).add(Ints.join(",", colNums));
    if (unique)
        rb.add(UNIQUE);
    else
        rb.add(isKey);
    if (fksrc != null)
        rb.add(fksrc.tablename).add(fksrc.columns).add(fksrc.mode);
    DataRecord r = rb.build();
    r.tblnum(TN.INDEXES);
    return r;
}

From source file:org.gradle.cache.internal.CacheVersion.java

@Override
public String toString() {
    return Ints.join(COMPONENT_SEPARATOR, components);
}

From source file:suneido.database.immudb.Index.java

@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("tbl ").append(tblnum).append(" ");
    appendType(sb);// w  w w . ja v a2 s . c  o  m
    sb.append("(").append(Ints.join(",", colNums)).append(")");
    if (fksrc != null)
        sb.append(" in ").append(fksrc.tablename);
    return sb.toString();
}

From source file:com.kegare.caveworld.client.config.GuiSelectBiome.java

@Override
protected void actionPerformed(GuiButton button) {
    if (button.enabled) {
        switch (button.id) {
        case 0:// w w w  .  ja v a2s  .  co  m
            if (biomeList.selected.isEmpty()) {
                if (parentTextField != null) {
                    parentTextField.setText("");
                }

                if (parentElement != null) {
                    parentElement.setListFromChildScreen(new Object[0]);
                }
            } else {
                List<Integer> result = Lists.newArrayList(
                        Collections2.transform(biomeList.selected, new Function<BiomeGenBase, Integer>() {
                            @Override
                            public Integer apply(BiomeGenBase biome) {
                                return biome == null ? 0 : biome.biomeID;
                            }
                        }));

                Collections.sort(result);

                if (parentScreen instanceof SelectListener) {
                    ((SelectListener) parentScreen).setResult(result);
                }

                if (parentTextField != null) {
                    parentTextField.setText(Ints.join(", ", Ints.toArray(result)));
                }

                if (parentElement != null) {
                    parentElement.setListFromChildScreen(result.toArray());
                }
            }

            if (parentTextField != null) {
                parentTextField.setFocused(true);
                parentTextField.setCursorPositionEnd();
            }

            mc.displayGuiScreen(parentScreen);
            break;
        case 1:
            CaveConfigGui.detailInfo = detailInfo.isChecked();
            break;
        case 2:
            CaveConfigGui.instantFilter = instantFilter.isChecked();
            break;
        }
    }
}

From source file:com.android.sdklib.repositoryv2.meta.DetailsTypes.java

/**
 * Gets the default path/unique id for the given build tools
 *//*  w ww .  j a va2  s  .c o m*/
public static String getBuildToolsPath(Revision revision) {
    String revisionStr = Ints.join(".", revision.toIntArray(false)) + (revision.isPreview() ? "-preview" : "");
    return SdkConstants.FD_BUILD_TOOLS + RepoPackage.PATH_SEPARATOR + revisionStr;
}

From source file:org.lilyproject.repository.impl.BlobManagerImpl.java

private Blob getBlobFromRecord(Record record, QName fieldName, FieldType fieldType, int... indexes)
        throws BlobNotFoundException {
    Object value = record.getField(fieldName);
    ValueType valueType = fieldType.getValueType();
    if (!valueType.getDeepestValueType().getBaseName().equals("BLOB")) {
        throw new BlobNotFoundException("Blob could not be retrieved from '" + record.getId() + "', '"
                + fieldName + "' at index: " + Ints.join("/", indexes));
    }/*from  w w  w .  j a va  2  s  .  co  m*/

    if (indexes == null) {
        indexes = new int[0];
    }

    for (int i = 0; i < indexes.length; i++) {
        int index = indexes[i];
        try {
            if (valueType.getBaseName().equals("LIST")) {
                value = ((List<Object>) value).get(index);
                valueType = valueType.getNestedValueType();
                continue;
            }
            if (valueType.getBaseName().equals("PATH")) {
                value = ((HierarchyPath) value).getElements()[index];
                valueType = valueType.getNestedValueType();
                continue;
            }
            throw new BlobNotFoundException("Invalid index to retrieve Blob from '" + record.getId() + "', '"
                    + fieldName + "' : " + Ints.join("/", Arrays.copyOf(indexes, i + 1)));
        } catch (IndexOutOfBoundsException e) {
            throw new BlobNotFoundException("Invalid index to retrieve Blob from '" + record.getId() + "', '"
                    + fieldName + "' : " + Ints.join("/", Arrays.copyOf(indexes, i + 1)), e);
        }
    }
    if (!valueType.getBaseName().equals("BLOB")) {
        throw new BlobNotFoundException("Blob could not be retrieved from '" + record.getId() + "', '"
                + fieldName + "' at index: " + Ints.join("/", indexes));
    }
    return (Blob) value;
}

From source file:com.flexive.shared.FxArrayUtils.java

/**
 * Convert an int array to a string array with the given separator
 *
 * @param elements  elements to convert to a String
 * @param separator separator for the resulting String
 * @return String representation of the array
 *//*from ww w . ja va  2  s.  c  o m*/
public static String toStringArray(int[] elements, char separator) {
    return Ints.join(String.valueOf(separator), elements);
}

From source file:com.kegare.caveworld.client.config.GuiVeinsEntry.java

@Override
protected void actionPerformed(GuiButton button) {
    if (button.enabled) {
        switch (button.id) {
        case 0:/*from  w w w .j  a v  a 2 s  .c om*/
            if (editMode) {
                if (Strings.isNullOrEmpty(blockField.getText()) || NumberUtils.toInt(countField.getText()) <= 0
                        || NumberUtils.toInt(weightField.getText()) <= 0
                        || NumberUtils.toInt(rateField.getText()) <= 0) {
                    return;
                }

                veinList.selected.setBlock(
                        new BlockEntry(blockField.getText(), NumberUtils.toInt(blockMetaField.getText())));
                veinList.selected.setGenBlockCount(
                        NumberUtils.toInt(countField.getText(), veinList.selected.getGenBlockCount()));
                veinList.selected.setGenWeight(
                        NumberUtils.toInt(weightField.getText(), veinList.selected.getGenWeight()));
                veinList.selected
                        .setGenRate(NumberUtils.toInt(rateField.getText(), veinList.selected.getGenRate()));
                veinList.selected.setGenMinHeight(
                        NumberUtils.toInt(minHeightField.getText(), veinList.selected.getGenMinHeight()));
                veinList.selected.setGenMaxHeight(
                        NumberUtils.toInt(maxHeightField.getText(), veinList.selected.getGenMaxHeight()));
                veinList.selected.setGenTargetBlock(
                        new BlockEntry(targetField.getText(), NumberUtils.toInt(targetMetaField.getText())));

                List<Integer> ids = Lists.newArrayList();

                for (String str : Splitter.on(',').trimResults().omitEmptyStrings()
                        .split(biomesField.getText())) {
                    if (NumberUtils.isNumber(str)) {
                        ids.add(Integer.parseInt(str));
                    }
                }

                Collections.sort(ids);

                veinList.selected.setGenBiomes(Ints.toArray(ids));

                hoverCache.remove(veinList.selected);

                actionPerformed(cancelButton);

                veinList.scrollToSelected();
            } else {
                boolean flag = CaveworldAPI.getCaveVeins().size() != veinList.veins.size();

                CaveworldAPI.clearCaveVeins();

                if (flag) {
                    try {
                        FileUtils.forceDelete(new File(Config.veinsCfg.toString()));

                        Config.veinsCfg.load();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

                for (ICaveVein vein : veinList.veins) {
                    CaveworldAPI.addCaveVein(vein);
                }

                if (Config.veinsCfg.hasChanged()) {
                    Config.veinsCfg.save();
                }

                actionPerformed(cancelButton);
            }

            break;
        case 1:
            if (editMode) {
                actionPerformed(cancelButton);
            } else {
                editMode = true;
                initGui();

                veinList.scrollToSelected();

                blockField.setText(
                        GameData.getBlockRegistry().getNameForObject(veinList.selected.getBlock().getBlock()));
                blockMetaField.setText(Integer.toString(veinList.selected.getBlock().getMetadata()));
                countField.setText(Integer.toString(veinList.selected.getGenBlockCount()));
                weightField.setText(Integer.toString(veinList.selected.getGenWeight()));
                rateField.setText(Integer.toString(veinList.selected.getGenRate()));
                minHeightField.setText(Integer.toString(veinList.selected.getGenMinHeight()));
                maxHeightField.setText(Integer.toString(veinList.selected.getGenMaxHeight()));
                targetField.setText(GameData.getBlockRegistry()
                        .getNameForObject(veinList.selected.getGenTargetBlock().getBlock()));
                targetMetaField.setText(Integer.toString(veinList.selected.getGenTargetBlock().getMetadata()));
                biomesField.setText(Ints.join(", ", veinList.selected.getGenBiomes()));
            }

            break;
        case 2:
            if (editMode) {
                editMode = false;
                initGui();
            } else {
                mc.displayGuiScreen(parentScreen);
            }

            break;
        case 3:
            mc.displayGuiScreen(new GuiSelectBlock(this));
            break;
        case 4:
            if (veinList.veins.remove(veinList.selected)) {
                int i = veinList.contents.indexOf(veinList.selected);

                veinList.contents.remove(i);
                veinList.selected = veinList.contents.get(i, veinList.contents.get(--i, null));
            }

            break;
        case 5:
            for (Object entry : veinList.veins.toArray()) {
                veinList.selected = (ICaveVein) entry;

                actionPerformed(removeButton);
            }

            break;
        case 6:
            CaveConfigGui.detailInfo = detailInfo.isChecked();
            break;
        case 7:
            CaveConfigGui.instantFilter = instantFilter.isChecked();
            break;
        }
    }
}

From source file:com.kegare.caveworld.client.config.GuiVeinsEntry.java

@Override
public void drawScreen(int mouseX, int mouseY, float ticks) {
    veinList.drawScreen(mouseX, mouseY, ticks);

    drawCenteredString(fontRendererObj, I18n.format(Caveworld.CONFIG_LANG + "veins"), width / 2, 15, 0xFFFFFF);

    super.drawScreen(mouseX, mouseY, ticks);

    if (editMode) {
        GuiTextField textField;/* w ww . j  a  va  2s. c  om*/

        for (int i = 0; i < editFieldList.size(); ++i) {
            textField = editFieldList.get(i);
            textField.drawTextBox();
            drawString(fontRendererObj, editLabelList.get(i), textField.xPosition - maxLabelWidth - 10,
                    textField.yPosition + 3, 0xBBBBBB);
        }

        if (blockHoverChecker.checkHover(mouseX, mouseY)) {
            if (!hoverCache.containsKey(blockHoverChecker)) {
                List<String> hover = Lists.newArrayList();
                String key = Caveworld.CONFIG_LANG + "veins.block";
                hover.add(EnumChatFormatting.GRAY + I18n.format(key));
                hover.addAll(fontRendererObj.listFormattedStringToWidth(I18n.format(key + ".tooltip"), 300));

                hoverCache.put(blockHoverChecker, hover);
            }

            func_146283_a(hoverCache.get(blockHoverChecker), mouseX, mouseY);
        } else if (countHoverChecker.checkHover(mouseX, mouseY)) {
            if (!hoverCache.containsKey(countHoverChecker)) {
                List<String> hover = Lists.newArrayList();
                String key = Caveworld.CONFIG_LANG + "veins.genBlockCount";
                hover.add(EnumChatFormatting.GRAY + I18n.format(key));
                hover.addAll(fontRendererObj.listFormattedStringToWidth(I18n.format(key + ".tooltip"), 300));

                hoverCache.put(countHoverChecker, hover);
            }

            func_146283_a(hoverCache.get(countHoverChecker), mouseX, mouseY);
        } else if (weightHoverChecker.checkHover(mouseX, mouseY)) {
            if (!hoverCache.containsKey(weightHoverChecker)) {
                List<String> hover = Lists.newArrayList();
                String key = Caveworld.CONFIG_LANG + "veins.genWeight";
                hover.add(EnumChatFormatting.GRAY + I18n.format(key));
                hover.addAll(fontRendererObj.listFormattedStringToWidth(I18n.format(key + ".tooltip"), 300));

                hoverCache.put(weightHoverChecker, hover);
            }

            func_146283_a(hoverCache.get(weightHoverChecker), mouseX, mouseY);
        } else if (rateHoverChecker.checkHover(mouseX, mouseY)) {
            if (!hoverCache.containsKey(rateHoverChecker)) {
                List<String> hover = Lists.newArrayList();
                String key = Caveworld.CONFIG_LANG + "veins.genRate";
                hover.add(EnumChatFormatting.GRAY + I18n.format(key));
                hover.addAll(fontRendererObj.listFormattedStringToWidth(I18n.format(key + ".tooltip"), 300));

                hoverCache.put(rateHoverChecker, hover);
            }

            func_146283_a(hoverCache.get(rateHoverChecker), mouseX, mouseY);
        } else if (heightHoverChecker.checkHover(mouseX, mouseY)) {
            if (!hoverCache.containsKey(heightHoverChecker)) {
                List<String> hover = Lists.newArrayList();
                String key = Caveworld.CONFIG_LANG + "veins.genHeight";
                hover.add(EnumChatFormatting.GRAY + I18n.format(key));
                hover.addAll(fontRendererObj.listFormattedStringToWidth(I18n.format(key + ".tooltip"), 300));

                hoverCache.put(heightHoverChecker, hover);
            }

            func_146283_a(hoverCache.get(heightHoverChecker), mouseX, mouseY);
        } else if (targetHoverChecker.checkHover(mouseX, mouseY)) {
            if (!hoverCache.containsKey(targetHoverChecker)) {
                List<String> hover = Lists.newArrayList();
                String key = Caveworld.CONFIG_LANG + "veins.genTargetBlock";
                hover.add(EnumChatFormatting.GRAY + I18n.format(key));
                hover.addAll(fontRendererObj.listFormattedStringToWidth(I18n.format(key + ".tooltip"), 300));

                hoverCache.put(targetHoverChecker, hover);
            }

            func_146283_a(hoverCache.get(targetHoverChecker), mouseX, mouseY);
        } else if (biomesHoverChecker.checkHover(mouseX, mouseY)) {
            if (!hoverCache.containsKey(biomesHoverChecker)) {
                List<String> hover = Lists.newArrayList();
                String key = Caveworld.CONFIG_LANG + "veins.genBiomes";
                hover.add(EnumChatFormatting.GRAY + I18n.format(key));
                hover.addAll(fontRendererObj.listFormattedStringToWidth(I18n.format(key + ".tooltip"), 300));

                hoverCache.put(biomesHoverChecker, hover);
            }

            func_146283_a(hoverCache.get(biomesHoverChecker), mouseX, mouseY);
        }
    } else {
        filterTextField.drawTextBox();
    }

    if (detailHoverChecker.checkHover(mouseX, mouseY)) {
        if (!hoverCache.containsKey(detailHoverChecker)) {
            hoverCache.put(detailHoverChecker, fontRendererObj
                    .listFormattedStringToWidth(I18n.format(Caveworld.CONFIG_LANG + "detail.hover"), 300));
        }

        func_146283_a(hoverCache.get(detailHoverChecker), mouseX, mouseY);
    } else if (instantHoverChecker.checkHover(mouseX, mouseY)) {
        if (!hoverCache.containsKey(instantHoverChecker)) {
            hoverCache.put(instantHoverChecker, fontRendererObj
                    .listFormattedStringToWidth(I18n.format(Caveworld.CONFIG_LANG + "instant.hover"), 300));
        }

        func_146283_a(hoverCache.get(instantHoverChecker), mouseX, mouseY);
    } else if (veinList.func_148141_e(mouseY) && isCtrlKeyDown()) {
        ICaveVein entry = veinList.contents.get(veinList.func_148124_c(mouseX, mouseY), null);

        if (entry != null) {
            if (!hoverCache.containsKey(entry)) {
                List<String> info = Lists.newArrayList();

                info.add(EnumChatFormatting.GRAY + I18n.format(Caveworld.CONFIG_LANG + "veins.block") + ": "
                        + GameData.getBlockRegistry().getNameForObject(entry.getBlock().getBlock()) + ", "
                        + entry.getBlock().getMetadata());
                info.add(EnumChatFormatting.GRAY + I18n.format(Caveworld.CONFIG_LANG + "veins.genBlockCount")
                        + ": " + entry.getGenBlockCount());
                info.add(EnumChatFormatting.GRAY + I18n.format(Caveworld.CONFIG_LANG + "veins.genWeight") + ": "
                        + entry.getGenWeight());
                info.add(EnumChatFormatting.GRAY + I18n.format(Caveworld.CONFIG_LANG + "veins.genRate") + ": "
                        + entry.getGenRate());
                info.add(EnumChatFormatting.GRAY + I18n.format(Caveworld.CONFIG_LANG + "veins.genHeight") + ": "
                        + entry.getGenMinHeight() + ", " + entry.getGenMaxHeight());
                info.add(EnumChatFormatting.GRAY + I18n.format(Caveworld.CONFIG_LANG + "veins.genTargetBlock")
                        + ": "
                        + GameData.getBlockRegistry().getNameForObject(entry.getGenTargetBlock().getBlock())
                        + ", " + entry.getGenTargetBlock().getMetadata());

                if (entry.getGenBiomes().length > 0) {
                    List<String> biomes = fontRendererObj
                            .listFormattedStringToWidth(I18n.format(Caveworld.CONFIG_LANG + "veins.genBiomes")
                                    + ": " + Ints.join(", ", entry.getGenBiomes()), 300);

                    for (String str : biomes) {
                        info.add(EnumChatFormatting.GRAY + str);
                    }
                }

                hoverCache.put(entry, info);
            }

            func_146283_a(hoverCache.get(entry), mouseX, mouseY);
        }
    }
}