Java 类com.google.common.base.Joiner.MapJoiner 实例源码

项目:guava-mock    文件:JoinerTest.java   
public void testMap() {
  MapJoiner j = Joiner.on(';').withKeyValueSeparator(':');
  assertEquals("", j.join(ImmutableMap.of()));
  assertEquals(":", j.join(ImmutableMap.of("", "")));

  Map<String, String> mapWithNulls = Maps.newLinkedHashMap();
  mapWithNulls.put("a", null);
  mapWithNulls.put(null, "b");

  try {
    j.join(mapWithNulls);
    fail();
  } catch (NullPointerException expected) {
  }

  assertEquals("a:00;00:b", j.useForNull("00").join(mapWithNulls));

  StringBuilder sb = new StringBuilder();
  j.appendTo(sb, ImmutableMap.of(1, 2, 3, 4, 5, 6));
  assertEquals("1:2;3:4;5:6", sb.toString());
}
项目:googles-monorepo-demo    文件:JoinerTest.java   
public void testMap() {
  MapJoiner j = Joiner.on(';').withKeyValueSeparator(':');
  assertEquals("", j.join(ImmutableMap.of()));
  assertEquals(":", j.join(ImmutableMap.of("", "")));

  Map<String, String> mapWithNulls = Maps.newLinkedHashMap();
  mapWithNulls.put("a", null);
  mapWithNulls.put(null, "b");

  try {
    j.join(mapWithNulls);
    fail();
  } catch (NullPointerException expected) {
  }

  assertEquals("a:00;00:b", j.useForNull("00").join(mapWithNulls));

  StringBuilder sb = new StringBuilder();
  j.appendTo(sb, ImmutableMap.of(1, 2, 3, 4, 5, 6));
  assertEquals("1:2;3:4;5:6", sb.toString());
}
项目:VarJ    文件:JoinerTest.java   
public void testMap() {
  MapJoiner j = Joiner.on(";").withKeyValueSeparator(":");
  assertEquals("", j.join(ImmutableMap.of()));
  assertEquals(":", j.join(ImmutableMap.of("", "")));

  Map<String, String> mapWithNulls = Maps.newLinkedHashMap();
  mapWithNulls.put("a", null);
  mapWithNulls.put(null, "b");

  try {
    j.join(mapWithNulls);
    fail();
  } catch (NullPointerException expected) {
  }

  assertEquals("a:00;00:b", j.useForNull("00").join(mapWithNulls));

  StringBuilder sb = new StringBuilder();
  j.appendTo(sb, ImmutableMap.of(1, 2, 3, 4, 5, 6));
  assertEquals("1:2;3:4;5:6", sb.toString());
}
项目:guava-libraries    文件:JoinerTest.java   
public void testMap() {
  MapJoiner j = Joiner.on(";").withKeyValueSeparator(":");
  assertEquals("", j.join(ImmutableMap.of()));
  assertEquals(":", j.join(ImmutableMap.of("", "")));

  Map<String, String> mapWithNulls = Maps.newLinkedHashMap();
  mapWithNulls.put("a", null);
  mapWithNulls.put(null, "b");

  try {
    j.join(mapWithNulls);
    fail();
  } catch (NullPointerException expected) {
  }

  assertEquals("a:00;00:b", j.useForNull("00").join(mapWithNulls));

  StringBuilder sb = new StringBuilder();
  j.appendTo(sb, ImmutableMap.of(1, 2, 3, 4, 5, 6));
  assertEquals("1:2;3:4;5:6", sb.toString());
}
项目:guava-libraries    文件:JoinerTest.java   
public void testMap() {
  MapJoiner j = Joiner.on(";").withKeyValueSeparator(":");
  assertEquals("", j.join(ImmutableMap.of()));
  assertEquals(":", j.join(ImmutableMap.of("", "")));

  Map<String, String> mapWithNulls = Maps.newLinkedHashMap();
  mapWithNulls.put("a", null);
  mapWithNulls.put(null, "b");

  try {
    j.join(mapWithNulls);
    fail();
  } catch (NullPointerException expected) {
  }

  assertEquals("a:00;00:b", j.useForNull("00").join(mapWithNulls));

  StringBuilder sb = new StringBuilder();
  j.appendTo(sb, ImmutableMap.of(1, 2, 3, 4, 5, 6));
  assertEquals("1:2;3:4;5:6", sb.toString());
}
项目:guava    文件:JoinerTest.java   
public void testMap() {
  MapJoiner j = Joiner.on(';').withKeyValueSeparator(':');
  assertEquals("", j.join(ImmutableMap.of()));
  assertEquals(":", j.join(ImmutableMap.of("", "")));

  Map<String, String> mapWithNulls = Maps.newLinkedHashMap();
  mapWithNulls.put("a", null);
  mapWithNulls.put(null, "b");

  try {
    j.join(mapWithNulls);
    fail();
  } catch (NullPointerException expected) {
  }

  assertEquals("a:00;00:b", j.useForNull("00").join(mapWithNulls));

  StringBuilder sb = new StringBuilder();
  j.appendTo(sb, ImmutableMap.of(1, 2, 3, 4, 5, 6));
  assertEquals("1:2;3:4;5:6", sb.toString());
}
项目:guava    文件:JoinerTest.java   
public void testMap() {
  MapJoiner j = Joiner.on(';').withKeyValueSeparator(':');
  assertEquals("", j.join(ImmutableMap.of()));
  assertEquals(":", j.join(ImmutableMap.of("", "")));

  Map<String, String> mapWithNulls = Maps.newLinkedHashMap();
  mapWithNulls.put("a", null);
  mapWithNulls.put(null, "b");

  try {
    j.join(mapWithNulls);
    fail();
  } catch (NullPointerException expected) {
  }

  assertEquals("a:00;00:b", j.useForNull("00").join(mapWithNulls));

  StringBuilder sb = new StringBuilder();
  j.appendTo(sb, ImmutableMap.of(1, 2, 3, 4, 5, 6));
  assertEquals("1:2;3:4;5:6", sb.toString());
}
项目:xtext-extras    文件:ResolvedTypes.java   
protected void appendContent(/* @Nullable */ Map<?, ?> map, String prefix, StringBuilder result, String indentation) {
    if (map != null) {
        MapJoiner joiner = Joiner.on("\n  " + indentation).withKeyValueSeparator(" -> ");
        result.append("\n").append(indentation).append(prefix).append(":\n").append(indentation).append("  ");
        joiner.appendTo(result, map);
    }
}
项目:TRHS_Club_Mod_2016    文件:GameData.java   
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.ERROR, e, "Failed to write registry data to %s", f.getAbsolutePath());
        }
    }
}
项目:CauldronGit    文件:GameData.java   
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.ERROR, e, "Failed to write registry data to %s", f.getAbsolutePath());
        }
    }
}
项目:Cauldron    文件:GameData.java   
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.ERROR, e, "Failed to write registry data to %s", f.getAbsolutePath());
        }
    }
}
项目:Cauldron    文件:GameData.java   
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.ERROR, e, "Failed to write registry data to %s", f.getAbsolutePath());
        }
    }
}
项目:Cauldron    文件:GameData.java   
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.ERROR, e, "Failed to write registry data to %s", f.getAbsolutePath());
        }
    }
}
项目:RuneCraftery    文件:GameData.java   
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());
        }
    }
}
项目:RuneCraftery    文件:GameData.java   
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());
        }
    }
}
项目:BetterNutritionMod    文件:GameData.java   
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());
        }
    }
}
项目:owsi-core-parent    文件:Renderer.java   
public static Renderer<Map<?, ?>> fromMapJoiner(Function<? super Locale, ? extends MapJoiner> joinerFunction) {
    return new MapJoinerRenderer(joinerFunction);
}
项目:owsi-core-parent    文件:Renderer.java   
public MapJoinerRenderer(Function<? super Locale, ? extends MapJoiner> joinerFunction) {
    super();
    this.joinerFunction = checkNotNull(joinerFunction);
}
项目:owsi-core-parent    文件:Renderer.java   
@Override
public String render(Map<?, ?> value, Locale locale) {
    checkNotNull(locale);
    MapJoiner joiner = joinerFunction.apply(locale);
    return joiner.join(value);
}