Advertisement
jbjares

SourceEnum

May 10th, 2015
670
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. package com.soundwave.model.enumeration;
  2.  
  3. import java.util.EnumSet;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6.  
  7. public enum SourceNamesEnum {
  8.  
  9.     ANDROID(0),
  10.     RDIO(1),
  11.     SPOTIFY(2),
  12.     YOUTUBE(3),
  13.     SOUNDCLOUD(4),
  14.     DEEZER(5),
  15.     PLAYER_PRO(6),
  16.     WINAMP(7),
  17.     AMAZON_MUSIC(8),
  18.     TIDAL_LOSSLESS_AUDIO(9);
  19.    
  20.     private int code;
  21.  
  22.  
  23.     private static final Map<Integer, SourceNamesEnum> lookup = new HashMap<Integer, SourceNamesEnum>();
  24.  
  25.     static {
  26.         for (SourceNamesEnum w : EnumSet.allOf(SourceNamesEnum.class)){
  27.             lookup.put(w.getCode(), w);        
  28.         }
  29.     }
  30.  
  31.  
  32.     private SourceNamesEnum(int code) {
  33.         this.code = code;
  34.     }
  35.  
  36.     public int getCode() {
  37.         return code;
  38.     }
  39.  
  40.     public static SourceNamesEnum get(int code) {
  41.         return lookup.get(code);
  42.     }
  43.    
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement