Java Code Examples for com.google.common.collect.ImmutableTable.Builder

The following are top voted examples for showing how to use com.google.common.collect.ImmutableTable.Builder. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: RuneCraftery   File: GameData.java   View source code 5 votes vote down vote up
public static void buildModObjectTable()
{
    if (modObjectTable != null)
    {
        throw new IllegalStateException("Illegal call to buildModObjectTable!");
    }

    Map<Integer, Cell<String, String, Integer>> map = Maps.transformValues(idMap, new Function<ItemData,Cell<String,String,Integer>>() {
        public Cell<String,String,Integer> apply(ItemData data)
        {
            if ("Minecraft".equals(data.getModId()) || !data.isOveridden())
            {
                return null;
            }
            return Tables.immutableCell(data.getModId(), data.getItemType(), data.getItemId());
        }
    });

    Builder<String, String, Integer> tBuilder = ImmutableTable.builder();
    for (Cell<String, String, Integer> c : map.values())
    {
        if (c!=null)
        {
            tBuilder.put(c);
        }
    }
    modObjectTable = tBuilder.build();
}
 
Example 2
Project: RuneCraftery   File: GameData.java   View source code 5 votes vote down vote up
public static void dumpRegistry(File minecraftDir)
{
    if (customItemStacks == null)
    {
        return;
    }
    if (Boolean.valueOf(System.getProperty("fml.dumpRegistry", "false")).booleanValue())
    {
        ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
        for (String modId : customItemStacks.rowKeySet())
        {
            builder.putAll(modId, customItemStacks.row(modId).keySet());
        }

        File f = new File(minecraftDir, "itemStackRegistry.csv");
        MapJoiner mapJoiner = Joiner.on("\n").withKeyValueSeparator(",");
        try
        {
            Files.write(mapJoiner.join(builder.build().entries()), f, Charsets.UTF_8);
            FMLLog.log(Level.INFO, "Dumped item registry data to %s", f.getAbsolutePath());
        }
        catch (IOException e)
        {
            FMLLog.log(Level.SEVERE, e, "Failed to write registry data to %s", f.getAbsolutePath());
        }
    }
}
 
Example 3
Project: RuneCraftery   File: GameData.java   View source code 5 votes vote down vote up
public static void buildModObjectTable()
{
    if (modObjectTable != null)
    {
        throw new IllegalStateException("Illegal call to buildModObjectTable!");
    }

    Map<Integer, Cell<String, String, Integer>> map = Maps.transformValues(idMap, new Function<ItemData,Cell<String,String,Integer>>() {
        public Cell<String,String,Integer> apply(ItemData data)
        {
            if ("Minecraft".equals(data.getModId()) || !data.isOveridden())
            {
                return null;
            }
            return Tables.immutableCell(data.getModId(), data.getItemType(), data.getItemId());
        }
    });

    Builder<String, String, Integer> tBuilder = ImmutableTable.builder();
    for (Cell<String, String, Integer> c : map.values())
    {
        if (c!=null)
        {
            tBuilder.put(c);
        }
    }
    modObjectTable = tBuilder.build();
}
 
Example 4
Project: RuneCraftery   File: GameData.java   View source code 5 votes vote down vote up
public static void dumpRegistry(File minecraftDir)
{
    if (customItemStacks == null)
    {
        return;
    }
    if (Boolean.valueOf(System.getProperty("fml.dumpRegistry", "false")).booleanValue())
    {
        ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
        for (String modId : customItemStacks.rowKeySet())
        {
            builder.putAll(modId, customItemStacks.row(modId).keySet());
        }

        File f = new File(minecraftDir, "itemStackRegistry.csv");
        MapJoiner mapJoiner = Joiner.on("\n").withKeyValueSeparator(",");
        try
        {
            Files.write(mapJoiner.join(builder.build().entries()), f, Charsets.UTF_8);
            FMLLog.log(Level.INFO, "Dumped item registry data to %s", f.getAbsolutePath());
        }
        catch (IOException e)
        {
            FMLLog.log(Level.SEVERE, e, "Failed to write registry data to %s", f.getAbsolutePath());
        }
    }
}
 
Example 5
Project: BetterNutritionMod   File: GameData.java   View source code 5 votes vote down vote up
public static void buildModObjectTable()
{
    if (modObjectTable != null)
    {
        throw new IllegalStateException("Illegal call to buildModObjectTable!");
    }

    Map<Integer, Cell<String, String, Integer>> map = Maps.transformValues(idMap, new Function<ItemData,Cell<String,String,Integer>>() {
        public Cell<String,String,Integer> apply(ItemData data)
        {
            if ("Minecraft".equals(data.getModId()) || !data.isOveridden())
            {
                return null;
            }
            return Tables.immutableCell(data.getModId(), data.getItemType(), data.getItemId());
        }
    });

    Builder<String, String, Integer> tBuilder = ImmutableTable.builder();
    for (Cell<String, String, Integer> c : map.values())
    {
        if (c!=null)
        {
            tBuilder.put(c);
        }
    }
    modObjectTable = tBuilder.build();
}
 
Example 6
Project: BetterNutritionMod   File: GameData.java   View source code 5 votes vote down vote up
public static void dumpRegistry(File minecraftDir)
{
    if (customItemStacks == null)
    {
        return;
    }
    if (Boolean.valueOf(System.getProperty("fml.dumpRegistry", "false")).booleanValue())
    {
        ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
        for (String modId : customItemStacks.rowKeySet())
        {
            builder.putAll(modId, customItemStacks.row(modId).keySet());
        }

        File f = new File(minecraftDir, "itemStackRegistry.csv");
        MapJoiner mapJoiner = Joiner.on("\n").withKeyValueSeparator(",");
        try
        {
            Files.write(mapJoiner.join(builder.build().entries()), f, Charsets.UTF_8);
            FMLLog.log(Level.INFO, "Dumped item registry data to %s", f.getAbsolutePath());
        }
        catch (IOException e)
        {
            FMLLog.log(Level.SEVERE, e, "Failed to write registry data to %s", f.getAbsolutePath());
        }
    }
}