com.google.common.collect.Mapscom.google.common.collect.ImmutableMap



Project jclouds/jclouds in file ...ions.DirectoryEntryListToResourceMetadataList.java (2011-04-03)
@@ -36,8 +36,8 @@ import org.jclouds.io.payloads.BaseMutableContentMetadata;
 
 import com.google.common.base.Function;
 import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
 
 /**
  * @author Adrian Cole
@@ -61,10 +61,11 @@ public class DirectoryEntryListToResourceMetadataList implements
                      StorageType type = from.getType() == FileType.DIRECTORY ? StorageType.FOLDER : StorageType.BLOB;
                      if (type == StorageType.FOLDER)
                         return new StorageMetadataImpl(type, from.getObjectID(), from.getObjectName(), defaultLocation
-                                 .get(), null, null, null, Maps.<String, String> newHashMap());
+                                 .get(), null, null, null,ImmutableMap.<String,String>of());
                      else
                         return new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(),
-                                 null, null, null, Maps.<String, String> newHashMap(), new BaseMutableContentMetadata());
+                                 null, null, null,ImmutableMap.<String,String>of(), null,
+                                 null, new BaseMutableContentMetadata());
                   }
 
                }), from.getToken());
Project jclouds/legacy-jclouds in file ...ions.DirectoryEntryListToResourceMetadataList.java (2011-04-03)
@@ -36,8 +36,8 @@ import org.jclouds.io.payloads.BaseMutableContentMetadata;
 
 import com.google.common.base.Function;
 import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
-import com.google.common.collect.Maps;
 
 /**
  * @author Adrian Cole
@@ -61,10 +61,11 @@ public class DirectoryEntryListToResourceMetadataList implements
                      StorageType type = from.getType() == FileType.DIRECTORY ? StorageType.FOLDER : StorageType.BLOB;
                      if (type == StorageType.FOLDER)
                         return new StorageMetadataImpl(type, from.getObjectID(), from.getObjectName(), defaultLocation
-                                 .get(), null, null, null, Maps.<String, String> newHashMap());
+                                 .get(), null, null, null,ImmutableMap.<String,String>of());
                      else
                         return new BlobMetadataImpl(from.getObjectID(), from.getObjectName(), defaultLocation.get(),
-                                 null, null, null, Maps.<String, String> newHashMap(), new BaseMutableContentMetadata());
+                                 null, null, null,ImmutableMap.<String,String>of(), null,
+                                 null, new BaseMutableContentMetadata());
                   }
 
                }), from.getToken());
Project Bukkit/Bukkit in file ...a08f37798d0/src.main.java.org.bukkit.DyeColor.java (2012-12-21)
@@ -2,7 +2,7 @@ package org.bukkit;
 
 import java.util.Map;
 
-import com.google.common.collect.Maps;
+import com.google.common.collect.ImmutableMap;
 
 /**
  * All supported color values for dyes and cloth
@@ -12,76 +12,79 @@ public enum DyeColor {
     /**
      * Represents white dye
      */
-    WHITE(0x0, Color.WHITE),
+    WHITE(0x0, Color.WHITE, Color.fromRGB(0x1E1B1B)),
     /**
      * Represents orange dye
      */
-    ORANGE(0x1, Color.fromRGB(0xD87f33)),
+    ORANGE(0x1, Color.fromRGB(0xD87f33), Color.fromRGB(0xB3312C)),
     /**
      * Represents magenta dye
      */
-    MAGENTA(0x2, Color.fromRGB(0xB24CD8)),
+    MAGENTA(0x2, Color.fromRGB(0xB24CD8), Color.fromRGB(0x3B511A)),
     /**
      * Represents light blue dye
      */
-    LIGHT_BLUE(0x3, Color.fromRGB(0x6699D8)),
+    LIGHT_BLUE(0x3, Color.fromRGB(0x6699D8), Color.fromRGB(0x51301A)),
     /**
      * Represents yellow dye
      */
-    YELLOW(0x4, Color.fromRGB(0xE5E533)),
+    YELLOW(0x4, Color.fromRGB(0xE5E533), Color.fromRGB(0x253192)),
     /**
      * Represents lime dye
      */
-    LIME(0x5, Color.fromRGB(0x7FCC19)),
+    LIME(0x5, Color.fromRGB(0x7FCC19), Color.fromRGB(0x7B2FBE)),
     /**
      * Represents pink dye
      */
-    PINK(0x6, Color.fromRGB(0xF27FA5)),
+    PINK(0x6, Color.fromRGB(0xF27FA5), Color.fromRGB(0x287697)),
     /**
      * Represents gray dye
      */
-    GRAY(0x7, Color.fromRGB(0x4C4C4C)),
+    GRAY(0x7, Color.fromRGB(0x4C4C4C), Color.fromRGB(0xABABAB)),
     /**
      * Represents silver dye
      */
-    SILVER(0x8, Color.fromRGB(0x999999)),
+    SILVER(0x8, Color.fromRGB(0x999999), Color.fromRGB(0x434343)),
     /**
      * Represents cyan dye
      */
-    CYAN(0x9, Color.fromRGB(0x4C7F99)),
+    CYAN(0x9, Color.fromRGB(0x4C7F99), Color.fromRGB(0xD88198)),
     /**
      * Represents purple dye
      */
-    PURPLE(0xA, Color.fromRGB(0x7F3FB2)),
+    PURPLE(0xA, Color.fromRGB(0x7F3FB2), Color.fromRGB(0x41CD34)),
     /**
      * Represents blue dye
      */
-    BLUE(0xB, Color.fromRGB(0x334CB2)),
+    BLUE(0xB, Color.fromRGB(0x334CB2), Color.fromRGB(0xDECF2A)),
     /**
      * Represents brown dye
      */
-    BROWN(0xC, Color.fromRGB(0x664C33)),
+    BROWN(0xC, Color.fromRGB(0x664C33), Color.fromRGB(0x6689D3)),
     /**
      * Represents green dye
      */
-    GREEN(0xD, Color.fromRGB(0x667F33)),
+    GREEN(0xD, Color.fromRGB(0x667F33), Color.fromRGB(0xC354CD)),
     /**
      * Represents red dye
      */
-    RED(0xE, Color.fromRGB(0x993333)),
+    RED(0xE, Color.fromRGB(0x993333), Color.fromRGB(0xEB8844)),
     /**
      * Represents black dye
      */
-    BLACK(0xF, Color.fromRGB(0x191919));
+    BLACK(0xF, Color.fromRGB(0x191919), Color.fromRGB(0xF0F0F0));
 
     private final byte data;
     private final Color color;
-    private final static Map<Byte, DyeColor> BY_DATA = Maps.newHashMap();
-    private final static Map<Color, DyeColor> BY_COLOR = Maps.newHashMap();
+    private final Color firework;
+    private final static DyeColor[] BY_DATA;
+    private final static Map<Color, DyeColor> BY_COLOR;
+    private final static Map<Color, DyeColor> BY_FIREWORK;
 
-    private DyeColor(final int data, Color color) {
+    private DyeColor(final int data, Color color, Color firework) {
         this.data = (byte) data;
         this.color = color;
+        this.firework = firework;
     }
 
     /**
@@ -103,13 +106,26 @@ public enum DyeColor {
     }
 
     /**
+     * Gets the firework color that this dye represents
+     *
+     * @return The {@link Color} that this dye represents
+     */
+    public Color getFireworkColor() {
+        return firework;
+    }
+
+    /**
      * Gets the DyeColor with the given data value
      *
      * @param data Data value to fetch
      * @return The {@link DyeColor} representing the given value, or null if it doesn't exist
      */
     public static DyeColor getByData(final byte data) {
-        return BY_DATA.get(data);
+        int i = 0xff & data;
+        if (i > BY_DATA.length) {
+            return null;
+        }
+        return BY_DATA[i];
     }
 
     /**
@@ -122,10 +138,28 @@ public enum DyeColor {
         return BY_COLOR.get(color);
     }
 
+    /**
+     * Gets the DyeColor with the given firework color value
+     *
+     * @param color Color value to get dye by
+     * @return The {@link DyeColor} representing the given value, or null if it doesn't exist
+     */
+    public static DyeColor getByFireworkColor(final Color color) {
+        return BY_FIREWORK.get(color);
+    }
+
     static {
+        BY_DATA = values();
+        ImmutableMap.Builder<Color, DyeColor> byColor = ImmutableMap.builder();
+        ImmutableMap.Builder<Color, DyeColor> byFirework = ImmutableMap.builder();
+
         for (DyeColor color : values()) {
-            BY_DATA.put(color.getData(), color);
-            BY_COLOR.put(color.getColor(), color);
+            BY_DATA[color.data & 0xff] = color;
+            byColor.put(color.getColor(), color);
+            byFirework.put(color.getFireworkColor(), color);
         }
+
+        BY_COLOR = byColor.build();
+        BY_FIREWORK = byFirework.build();
     }
 }
Project Graylog2/graylog2-server in file ...g.graylog2.rest.resources.count.CountResource.java (2014-10-06)
@@ -17,7 +17,7 @@
 package org.graylog2.rest.resources.count;
 
 import com.codahale.metrics.annotation.Timed;
-import com.google.common.collect.Maps;
+import com.google.common.collect.ImmutableMap;
 import org.apache.shiro.authz.annotation.RequiresAuthentication;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.graylog2.indexer.counts.Counts;
@@ -33,9 +33,6 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import java.util.Map;
 
-/**
- * @author Lennart Koopmann <lennart@torch.sh>
- */
 @RequiresAuthentication
 @Api(value = "Counts", description = "Message counts")
 @Path("/count")
@@ -48,15 +45,13 @@ public class CountResource extends RestResource {
         this.counts = counts;
     }
 
-    @GET @Path("/total") @Timed
+    @GET
+    @Path("/total")
+    @Timed
     @RequiresPermissions(RestPermissions.MESSAGECOUNT_READ)
     @ApiOperation(value = "Total number of messages in all your indices.")
     @Produces(MediaType.APPLICATION_JSON)
-    public String total() {
-        Map<String, Long> result = Maps.newHashMap();
-        result.put("events", counts.total());
-
-        return json(result);
+    public Map<String, Long> total() {
+        return ImmutableMap.of("events", counts.total());
     }
-
 }
Project Graylog2/graylog2-server in file ...graylog2.rest.resources.system.PluginResource.java (2014-10-06)
@@ -17,8 +17,8 @@
 package org.graylog2.rest.resources.system;
 
 import com.codahale.metrics.annotation.Timed;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
 import org.graylog2.plugin.PluginMetaData;
 import org.graylog2.plugin.Version;
 import com.wordnik.swagger.annotations.Api;
@@ -69,18 +69,15 @@ public class PluginResource extends RestResource {
     @GET
     @Timed
     @ApiOperation(value = "List all installed plugins on this node.")
-    public String list() {
-        Map<String, Object> result = Maps.newHashMap();
-        result.put("total", pluginMetaDataSet.size());
-
-        List<PluginMetaDataValue> pluginMetaDataValues = Lists.newArrayList();
+    public Map<String, Object> list() {
+        final List<PluginMetaDataValue> pluginMetaDataValues = Lists.newArrayList();
 
         for (PluginMetaData pluginMetaData : pluginMetaDataSet) {
             pluginMetaDataValues.add(new PluginMetaDataValue(pluginMetaData));
         }
 
-        result.put("plugins", pluginMetaDataValues);
-
-        return json(result);
+        return ImmutableMap.of(
+                "plugins", pluginMetaDataValues,
+                "total", pluginMetaDataValues.size());
     }
 }