1 package org.robolectric.res.android; 2 3 public class ApkAssetsCookie { 4 5 public static final int kInvalidCookie = -1; 6 public static final ApkAssetsCookie K_INVALID_COOKIE = new ApkAssetsCookie(kInvalidCookie); 7 8 // hey memory/gc optimization! 9 private static final ApkAssetsCookie[] PREBAKED = new ApkAssetsCookie[256]; 10 static { 11 for (int i = 0; i < PREBAKED.length; i++) { 12 PREBAKED[i] = new ApkAssetsCookie(i); 13 } 14 } 15 forInt(int cookie)16 public static ApkAssetsCookie forInt(int cookie) { 17 if (cookie == kInvalidCookie) { 18 return K_INVALID_COOKIE; 19 } 20 return PREBAKED[cookie]; 21 } 22 23 private final int cookie; 24 ApkAssetsCookie(int cookie)25 private ApkAssetsCookie(int cookie) { 26 this.cookie = cookie; 27 } 28 intValue()29 public int intValue() { 30 return cookie; 31 } 32 } 33