private String getRelativeUnitPattern( Style style, RelativeUnit unit, int pastFutureIndex, StandardPlural pluralForm) { int pluralIndex = pluralForm.ordinal(); do { EnumMap<RelativeUnit, String[][]> unitMap = patternMap.get(style); if (unitMap != null) { String[][] spfCompiledPatterns = unitMap.get(unit); if (spfCompiledPatterns != null) { if (spfCompiledPatterns[pastFutureIndex][pluralIndex] != null) { return spfCompiledPatterns[pastFutureIndex][pluralIndex]; } } } // Consider other styles from alias fallback. // Data loading guaranteed no endless loops. } while ((style = fallbackCache[style.ordinal()]) != null); return null; }
/** * For a given Enum type, creates an immutable map from each of the Enum's values to a * corresponding LockGraphNode, with the {@code allowedPriorLocks} and * {@code disallowedPriorLocks} prepopulated with nodes according to the natural ordering of the * associated Enum values. */ @VisibleForTesting static <E extends Enum<E>> Map<E, LockGraphNode> createNodes(Class<E> clazz) { EnumMap<E, LockGraphNode> map = Maps.newEnumMap(clazz); E[] keys = clazz.getEnumConstants(); final int numKeys = keys.length; ArrayList<LockGraphNode> nodes = Lists.newArrayListWithCapacity(numKeys); // Create a LockGraphNode for each enum value. for (E key : keys) { LockGraphNode node = new LockGraphNode(getLockName(key)); nodes.add(node); map.put(key, node); } // Pre-populate all allowedPriorLocks with nodes of smaller ordinal. for (int i = 1; i < numKeys; i++) { nodes.get(i).checkAcquiredLocks(Policies.THROW, nodes.subList(0, i)); } // Pre-populate all disallowedPriorLocks with nodes of larger ordinal. for (int i = 0; i < numKeys - 1; i++) { nodes.get(i).checkAcquiredLocks(Policies.DISABLED, nodes.subList(i + 1, numKeys)); } return Collections.unmodifiableMap(map); }
@Test public void testConstructorAcceptAsiListMap() { Map<Gene, List<Asi>> asiListMap = new EnumMap<>(Gene.class); MutationSet mutations = new MutationSet("PR46I,PR54V,PR73T,RT103N,RT41L,RT215E,RT181C,RT190A,IN66I"); for (Gene gene : Gene.values()) { asiListMap.put(gene, new ArrayList<>()); MutationSet geneMuts = mutations.getGeneMutations(gene); asiListMap.get(gene).add(new AsiHivdb(gene, geneMuts)); asiListMap.get(gene).add(new AsiAnrs(gene, geneMuts)); asiListMap.get(gene).add(new AsiRega(gene, geneMuts)); } AlgorithmComparison cmp = new AlgorithmComparison(asiListMap); List<ComparableDrugScore> r = cmp.getComparisonResults(); assertEquals(SIREnum.I, getComparableDrugScore(r, Drug.ABC, "ANRS").SIR); assertEquals("Possible resistance", getComparableDrugScore(r, Drug.ABC, "ANRS").interpretation); assertEquals(SIREnum.R, getComparableDrugScore(r, Drug.EFV, "ANRS").SIR); assertEquals("Resistance", getComparableDrugScore(r, Drug.EFV, "ANRS").interpretation); assertEquals(SIREnum.R, getComparableDrugScore(r, Drug.EFV, "HIVDB").SIR); assertEquals("High-Level Resistance", getComparableDrugScore(r, Drug.EFV, "HIVDB").interpretation); assertEquals(SIREnum.R, getComparableDrugScore(r, Drug.EFV, "REGA").SIR); assertEquals("Resistant GSS 0", getComparableDrugScore(r, Drug.EFV, "REGA").interpretation); assertEquals(asiListMap.get(Gene.IN), cmp.getAsiList(Gene.IN)); }
public static void main(String[] args) { Herb[] garden = {new Herb("Basic", Type.ANNUAL), new Herb("Carroway",Type.BIENNIAL), new Herb("Dill", Type.ANNUAL), new Herb("Lavendar", Type.PERENNIAL), new Herb("Parsley", Type.BIENNIAL), new Herb("Rosemary", Type.PERENNIAL) }; //Using an EnumMap to associate data with an enum Map<Herb.Type, Set<Herb>> herbByType = new EnumMap<Herb.Type,Set<Herb>>( Herb.Type.class); for (Herb.Type t : Herb.Type.values()){ herbByType.put(t, new HashSet<Herb>()); } for (Herb h : garden) { herbByType.get(h.type).add(h); } System.out.println(herbByType); }
public void consumeTimeDetail(UResource.Key key, UResource.Value value) { UResource.Table unitTypesTable = value.getTable(); EnumMap<RelativeUnit, String[][]> unitPatterns = styleRelUnitPatterns.get(style); if (unitPatterns == null) { unitPatterns = new EnumMap<RelativeUnit, String[][]>(RelativeUnit.class); styleRelUnitPatterns.put(style, unitPatterns); } String[][] patterns = unitPatterns.get(unit.relUnit); if (patterns == null) { patterns = new String[2][StandardPlural.COUNT]; unitPatterns.put(unit.relUnit, patterns); } // Stuff the pattern for the correct plural index with a simple formatter. for (int i = 0; unitTypesTable.getKeyAndValue(i, key, value); i++) { if (value.getType() == ICUResourceBundle.STRING) { int pluralIndex = StandardPlural.indexFromString(key.toString()); if (patterns[pastFutureIndex][pluralIndex] == null) { patterns[pastFutureIndex][pluralIndex] = SimpleFormatterImpl.compileToStringMinMaxArguments( value.getString(), sb, 0, 1); } } } }
/** * Retrieves the connectivity that has been collected up until this call. This method fills in * {@link ConnectivityCheckResult#UNKNOWN} for results that have not been retrieved yet. * * @return the {@link FeedbackData}. */ public FeedbackData get() { ThreadUtils.assertOnUiThread(); Map<Type, Integer> result = new EnumMap<Type, Integer>(Type.class); // Ensure the map is filled with a result for all {@link Type}s. for (Type type : Type.values()) { if (mResult.containsKey(type)) { result.put(type, mResult.get(type)); } else { result.put(type, ConnectivityCheckResult.UNKNOWN); } } long elapsedTimeMs = SystemClock.elapsedRealtime() - mStartCheckTimeMs; int connectionType = NetworkChangeNotifier.getInstance().getCurrentConnectionType(); return new FeedbackData(result, mTimeoutMs, elapsedTimeMs, connectionType); }
/** * Returns an immutable map instance containing the given entries. * Internally, the returned map will be backed by an {@link EnumMap}. * * <p>The iteration order of the returned map follows the enum's iteration * order, not the order in which the elements appear in the given map. * * @param map the map to make an immutable copy of * @return an immutable map containing those entries * @since 14.0 */ @GwtCompatible(serializable = true) @Beta public static <K extends Enum<K>, V> ImmutableMap<K, V> immutableEnumMap( Map<K, ? extends V> map) { if (map instanceof ImmutableEnumMap) { @SuppressWarnings("unchecked") // safe covariant cast ImmutableEnumMap<K, V> result = (ImmutableEnumMap<K, V>) map; return result; } else if (map.isEmpty()) { return ImmutableMap.of(); } else { for (Map.Entry<K, ? extends V> entry : map.entrySet()) { checkNotNull(entry.getKey()); checkNotNull(entry.getValue()); } return ImmutableEnumMap.asImmutable(new EnumMap<K, V>(map)); } }
private static TileType[][] generateLevel(Random seedPicker, int width, int height) { TileType[][] tiles = new TileType[width][height]; float[][] landData = generateTerrain(seedPicker.nextLong(), width, height, landGen.samplePeriods, landGen.postSmoothing); float[][] biomeData = generateTerrain(seedPicker.nextLong(), width, height, biomeSample, biomeSmooth); EnumMap<Biome, float[][]> biomeTerrain = new EnumMap<>(Biome.class); for(Biome b: Biome.values) biomeTerrain.put(b, b.generateTerrain(seedPicker.nextLong(), width, height)); for (int x = 0; x < tiles.length; x++) { for (int y = 0; y < tiles[x].length; y++) { tiles[x][y] = landGen.getTile(landData[x][y]); if(tiles[x][y] == TileType.GRASS) { Biome biome = biomeGen[getIndex(biomeGen.length, biomeData[x][y])]; tiles[x][y] = biome.getTile(biomeTerrain.get(biome)[x][y]); } } } return tiles; }
@Override public Map<DrugClass, List<MutationPattern>> load() throws SQLException { String sql = "SELECT SequenceID, Pos, AA " + "FROM tblMutations WHERE Gene = ? " + // no stop codon "AND AA != '.' ORDER BY SequenceID, Pos, AA"; Map<DrugClass, List<MutationPattern>> allResult = new EnumMap<>(DrugClass.class); for (Gene gene : Gene.values()) { Map<Integer, MutationSet> allMutations = db.iterateMap( sql, (rs, map) -> { Integer seqId = rs.getInt("SequenceID"); Integer pos = rs.getInt("Pos"); String aa = rs.getString("AA"); MutationSet muts = map.getOrDefault(seqId, new MutationSet()); muts = muts.mergesWith(new Mutation(gene, pos, aa)); map.put(seqId, muts); return null; }, gene.toString()); allResult.putAll(calcGenePatterns(gene, allMutations.values())); } return allResult; }
public Map<DrugClass, Map<Drug, Map<Mutation, Double>>> getDrugClassDrugMutScores() { Map<DrugClass, Map<Drug, Map<Mutation, Double>>> result = new EnumMap<>(DrugClass.class); for (DrugClass drugClass : gene.getDrugClasses()) { result.put(drugClass, new EnumMap<>(Drug.class)); Map<Drug, Map<Mutation, Double>> drugClassResult = result.get(drugClass); for (Drug drug : drugClass.getDrugsForHivdbTesting()) { drugClassResult.put(drug, new LinkedHashMap<>()); Map<Mutation, Double> drugResult = drugClassResult.get(drug); Map<String, Double> drugScores = separatedScores.getOrDefault(drug, Collections.emptyMap()); for (String key : drugScores.keySet()) { if (StringUtils.countMatches(key, "+") > 1) { continue; } Mutation mut = triggeredMuts.get(drug).get(key).first(); drugResult.put(mut, drugScores.get(key)); } } } return result; }
public static void main(String[] args) { EnumMap<Test, String> map1 = new EnumMap<Test, String>(Test.class); map1.put(Test.ONE, "1"); map1.put(Test.TWO, "2"); // We need to force creation of the map1.entrySet int size = map1.entrySet().size(); if (size != 2) { throw new RuntimeException( "Invalid size in original map. Expected: 2 was: " + size); } EnumMap<Test, String> map2 = map1.clone(); map2.remove(Test.ONE); size = map2.entrySet().size(); if (size != 1) { throw new RuntimeException( "Invalid size in cloned instance. Expected: 1 was: " + size); } }
public void maxStats() { Map<MapleStat, Integer> statup = new EnumMap<>(MapleStat.class); c.getPlayer().getStat().str = (short) 999; c.getPlayer().getStat().dex = (short) 999; c.getPlayer().getStat().int_ = (short) 999; c.getPlayer().getStat().luk = (short) 999; int overrDemon = GameConstants.isDemonSlayer(c.getPlayer().getJob()) ? GameConstants.getMPByJob(c.getPlayer().getJob()) : 500000; c.getPlayer().getStat().maxhp = 500000; c.getPlayer().getStat().maxmp = overrDemon; c.getPlayer().getStat().setHp(500000, c.getPlayer()); c.getPlayer().getStat().setMp(overrDemon, c.getPlayer()); statup.put(MapleStat.STR, Integer.valueOf(999)); statup.put(MapleStat.DEX, Integer.valueOf(999)); statup.put(MapleStat.LUK, Integer.valueOf(999)); statup.put(MapleStat.INT, Integer.valueOf(999)); statup.put(MapleStat.HP, Integer.valueOf(500000)); statup.put(MapleStat.MAXHP, Integer.valueOf(500000)); statup.put(MapleStat.MP, Integer.valueOf(overrDemon)); statup.put(MapleStat.MAXMP, Integer.valueOf(overrDemon)); c.getPlayer().getStat().recalcLocalStats(c.getPlayer()); // c.getSession().write(CWvsContext.updatePlayerStats(statup, // c.getPlayer().getJob())); }
public static EntityDamageEvent handleLivingEntityDamageEvent(Entity damagee, DamageSource source, double rawDamage, double hardHatModifier, double blockingModifier, double armorModifier, double resistanceModifier, double magicModifier, double absorptionModifier, Function<Double, Double> hardHat, Function<Double, Double> blocking, Function<Double, Double> armor, Function<Double, Double> resistance, Function<Double, Double> magic, Function<Double, Double> absorption) { Map<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class); Map<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class); modifiers.put(DamageModifier.BASE, rawDamage); modifierFunctions.put(DamageModifier.BASE, ZERO); if (source == DamageSource.fallingBlock || source == DamageSource.anvil) { modifiers.put(DamageModifier.HARD_HAT, hardHatModifier); modifierFunctions.put(DamageModifier.HARD_HAT, hardHat); } if (damagee instanceof EntityPlayer) { modifiers.put(DamageModifier.BLOCKING, blockingModifier); modifierFunctions.put(DamageModifier.BLOCKING, blocking); } modifiers.put(DamageModifier.ARMOR, armorModifier); modifierFunctions.put(DamageModifier.ARMOR, armor); modifiers.put(DamageModifier.RESISTANCE, resistanceModifier); modifierFunctions.put(DamageModifier.RESISTANCE, resistance); modifiers.put(DamageModifier.MAGIC, magicModifier); modifierFunctions.put(DamageModifier.MAGIC, magic); modifiers.put(DamageModifier.ABSORPTION, absorptionModifier); modifierFunctions.put(DamageModifier.ABSORPTION, absorption); return handleEntityDamageEvent(damagee, source, modifiers, modifierFunctions); }
/** * Lazily creates and returns an action setting the mode of this * JGraph. The actual setting is done by a call to {@link #setMode(JGraphMode)}. */ public Action getModeAction(JGraphMode mode) { if (this.modeActionMap == null) { this.modeActionMap = new EnumMap<>(JGraphMode.class); for (final JGraphMode any : JGraphMode.values()) { Action action = new AbstractAction(any.getName(), any.getIcon()) { @Override public void actionPerformed(ActionEvent e) { setMode(any); } }; if (any.getAcceleratorKey() != null) { action.putValue(Action.ACCELERATOR_KEY, any.getAcceleratorKey()); addAccelerator(action); } this.modeActionMap.put(any, action); } } return this.modeActionMap.get(mode); }
private void makeStateMachineTable() { Stack<ApplicableTransition<OPERAND, STATE, EVENTTYPE, EVENT>> stack = new Stack<ApplicableTransition<OPERAND, STATE, EVENTTYPE, EVENT>>(); Map<STATE, Map<EVENTTYPE, Transition<OPERAND, STATE, EVENTTYPE, EVENT>>> prototype = new HashMap<STATE, Map<EVENTTYPE, Transition<OPERAND, STATE, EVENTTYPE, EVENT>>>(); prototype.put(defaultInitialState, null); // I use EnumMap here because it'll be faster and denser. I would // expect most of the states to have at least one transition. stateMachineTable = new EnumMap<STATE, Map<EVENTTYPE, Transition<OPERAND, STATE, EVENTTYPE, EVENT>>>(prototype); for (TransitionsListNode cursor = transitionsListNode; cursor != null; cursor = cursor.next) { stack.push(cursor.transition); } while (!stack.isEmpty()) { stack.pop().apply(this); } }
public DispelBySlotProbability(StatsSet params) { _dispel = params.getString("dispel", null); _rate = params.getInt("rate", 100); if ((_dispel != null) && !_dispel.isEmpty()) { _dispelAbnormals = new EnumMap<>(AbnormalType.class); for (String ngtStack : _dispel.split(";")) { final String[] ngt = ngtStack.split(","); _dispelAbnormals.put(AbnormalType.getAbnormalType(ngt[0]), Short.MAX_VALUE); } } else { _dispelAbnormals = Collections.<AbnormalType, Short> emptyMap(); } }
public Bitmap encodeAsBitmap() throws WriterException { if (!encoded) return null; Map<EncodeHintType, Object> hints = null; String encoding = guessAppropriateEncoding(contents); hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class); if (encoding != null) { hints.put(EncodeHintType.CHARACTER_SET, encoding); } hints.put(EncodeHintType.MARGIN, 2); /* default = 4 */ MultiFormatWriter writer = new MultiFormatWriter(); BitMatrix result = writer.encode(contents, format, dimension, dimension, hints); int width = result.getWidth(); int height = result.getHeight(); int[] pixels = new int[width * height]; // All are 0, or black, by default for (int y = 0; y < height; y++) { int offset = y * width; for (int x = 0; x < width; x++) { pixels[offset + x] = result.get(x, y) ? BLACK : WHITE; } } Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bitmap.setPixels(pixels, 0, width, 0, 0, width, height); return bitmap; }
public Bitmap encodeAsBitmap() throws WriterException { if (!encoded) return null; Map<EncodeHintType, Object> hints = null; String encoding = guessAppropriateEncoding(contents); if (encoding != null) { hints = new EnumMap<EncodeHintType, Object>(EncodeHintType.class); hints.put(EncodeHintType.CHARACTER_SET, encoding); } MultiFormatWriter writer = new MultiFormatWriter(); BitMatrix result = writer.encode(contents, format, dimension, dimension, hints); int width = result.getWidth(); int height = result.getHeight(); int[] pixels = new int[width * height]; // All are 0, or black, by default for (int y = 0; y < height; y++) { int offset = y * width; for (int x = 0; x < width; x++) { pixels[offset + x] = result.get(x, y) ? BLACK : WHITE; } } Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bitmap.setPixels(pixels, 0, width, 0, 0, width, height); return bitmap; }
/** * Gets the string value from qualitativeUnitMap with fallback based on style. */ private String getAbsoluteUnitString(Style style, AbsoluteUnit unit, Direction direction) { EnumMap<AbsoluteUnit, EnumMap<Direction, String>> unitMap; EnumMap<Direction, String> dirMap; do { unitMap = qualitativeUnitMap.get(style); if (unitMap != null) { dirMap = unitMap.get(unit); if (dirMap != null) { String result = dirMap.get(direction); if (result != null) { return result; } } } // Consider other styles from alias fallback. // Data loading guaranteed no endless loops. } while ((style = fallbackCache[style.ordinal()]) != null); return null; }
@Test public void testGroupByGene() { MutationSet sequenceMuts = new MutationSet( new Mutation(Gene.RT, 65, "N"), new Mutation(Gene.RT, 115, "FR"), new Mutation(Gene.RT, 118, "I"), new Mutation(Gene.RT, 103, "N"), new Mutation(Gene.RT, 41, "P"), new Mutation(Gene.PR, 84, "V"), new Mutation(Gene.IN, 155, "S")); Map<Gene, MutationSet> expected = new EnumMap<>(Gene.class); expected.put(Gene.RT, new MutationSet("RT65N,RT115FR,RT118I,RT103N,RT41P")); expected.put(Gene.PR, new MutationSet("PR84V")); expected.put(Gene.IN, new MutationSet("IN155S")); assertEquals(expected, sequenceMuts.groupByGene()); }
public static void main(String[] args) { Map<TestEnum, Integer> map = new EnumMap<>(TestEnum.class); map.put(TestEnum.e00, 0); if (false == map.containsValue(0)) { throw new RuntimeException("EnumMap unexpectedly missing 0 value"); } if (map.containsValue(null)) { throw new RuntimeException("EnumMap unexpectedly holds null value"); } map.put(TestEnum.e00, null); if (map.containsValue(0)) { throw new RuntimeException("EnumMap unexpectedly holds 0 value"); } if (false == map.containsValue(null)) { throw new RuntimeException("EnumMap unexpectedly missing null value"); } }
public List<PlayerBuffValueHolder> getAllBuffs() { final List<PlayerBuffValueHolder> ret = new ArrayList<>(); final Map<Pair<Integer, Byte>, Integer> alreadyDone = new HashMap<>(); final LinkedList<Entry<CharacterTemporaryStat, MapleBuffStatValueHolder>> allBuffs = new LinkedList<>(effects.entrySet()); for (Entry<CharacterTemporaryStat, MapleBuffStatValueHolder> mbsvh : allBuffs) { final Pair<Integer, Byte> key = new Pair<>(mbsvh.getValue().effect.getSourceId(), mbsvh.getValue().effect.getLevel()); if (alreadyDone.containsKey(key)) { ret.get(alreadyDone.get(key)).statup.put(mbsvh.getKey(), mbsvh.getValue().value); } else { alreadyDone.put(key, ret.size()); final EnumMap<CharacterTemporaryStat, Integer> list = new EnumMap<>(CharacterTemporaryStat.class); list.put(mbsvh.getKey(), mbsvh.getValue().value); ret.add(new PlayerBuffValueHolder(mbsvh.getValue().startTime, mbsvh.getValue().effect, list, mbsvh.getValue().localDuration, mbsvh.getValue().cid)); } } return ret; }
private void handlePlainDirection(UResource.Key key, UResource.Value value) { AbsoluteUnit absUnit = unit.absUnit; if (absUnit == null) { return; // Not interesting. } EnumMap<AbsoluteUnit, EnumMap<Direction, String>> unitMap = qualitativeUnitMap.get(style); if (unitMap == null) { unitMap = new EnumMap<AbsoluteUnit, EnumMap<Direction, String>>(AbsoluteUnit.class); qualitativeUnitMap.put(style, unitMap); } EnumMap<Direction,String> dirMap = unitMap.get(absUnit); if (dirMap == null) { dirMap = new EnumMap<Direction,String>(Direction.class); unitMap.put(absUnit, dirMap); } if (dirMap.get(Direction.PLAIN) == null) { dirMap.put(Direction.PLAIN, value.toString()); } }
/** * Initialize the barcode decoder. */ private void initBarcodeReader(List<String> barCodeTypes) { EnumMap<DecodeHintType, Object> hints = new EnumMap<>(DecodeHintType.class); EnumSet<BarcodeFormat> decodeFormats = EnumSet.noneOf(BarcodeFormat.class); if (barCodeTypes != null) { for (String code : barCodeTypes) { BarcodeFormat format = parseBarCodeString(code); if (format != null) { decodeFormats.add(format); } } } hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats); _multiFormatReader.setHints(hints); }
public Map<DrugClass, MutationSet> getNonDrmTsms() { if (nonDrmTsms == null) { nonDrmTsms = new EnumMap<>(DrugClass.class); for (DrugClass drugClass : gene.getDrugClasses()) { MutationSet tsms = Tsms.getTsmsForDrugClass(drugClass, mutations); MutationSet drms = mutations.getDRMs(drugClass); nonDrmTsms.put(drugClass, tsms.subtractsBy(drms)); } } return nonDrmTsms; }
private static EnumMap<SysProp, String> parseExecOutput(String probeResult) { String[] split = probeResult.split(System.getProperty("line.separator")); if (split.length != SysProp.values().length - 1) { // -1 because of Z_ERROR return error("Unexpected command output: \n" + probeResult); } EnumMap<SysProp, String> result = new EnumMap<SysProp, String>(SysProp.class); for (SysProp type : SysProp.values()) { if (type != SysProp.Z_ERROR) { result.put(type, split[type.ordinal()]); } } return result; }
/** * @serialData the {@code Class<E>} for the enum type, the number of distinct * elements, the first element, its count, the second element, its * count, and so on */ @GwtIncompatible // java.io.ObjectInputStream private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); @SuppressWarnings("unchecked") // reading data stored by writeObject Class<E> localType = (Class<E>) stream.readObject(); type = localType; setBackingMap(WellBehavedMap.wrap(new EnumMap<E, Count>(type))); Serialization.populateMultiset(this, stream); }
public GoodGameImplementation(GoodGame gg) { this.gg = gg; this.realization = new EnumMap<>(GoodGame.Resources.class); this.realization.put(GoodGame.Resources.OAUTH, new OauthRealization(gg)); this.realization.put(GoodGame.Resources.PLAYER, new PlayerRealization(gg)); this.realization.put(GoodGame.Resources.STREAMS, new StreamsRealization(gg)); this.realization.put(GoodGame.Resources.CHANNELS, new ChannelsRealization(gg)); this.realization.put(GoodGame.Resources.CHAT, new ChatRealization(gg)); this.realization.put(GoodGame.Resources.GAMES, new GamesRealization(gg)); this.realization.put(GoodGame.Resources.INFO, new InfoRealization(gg)); this.realization.put(GoodGame.Resources.SMILES, new SmilesRealization(gg)); this.realization.put(GoodGame.Resources.GITHUBAPI, new GithubRealization(gg)); this.realization.put(GoodGame.Resources.AJAX, new AjaxRealization(gg)); }
static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) { Bundle extras = intent.getExtras(); if (extras == null || extras.isEmpty()) { return null; } Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class); for (DecodeHintType hintType: DecodeHintType.values()) { if (hintType == DecodeHintType.CHARACTER_SET || hintType == DecodeHintType.NEED_RESULT_POINT_CALLBACK || hintType == DecodeHintType.POSSIBLE_FORMATS) { continue; // This hint is specified in another way } String hintName = hintType.name(); if (extras.containsKey(hintName)) { if (hintType.getValueType().equals(Void.class)) { // Void hints are just flags: use the constant specified by the DecodeHintType hints.put(hintType, Boolean.TRUE); } else { Object hintData = extras.get(hintName); if (hintType.getValueType().isInstance(hintData)) { hints.put(hintType, hintData); } else { Log.w(TAG, "Ignoring hint " + hintType + " because it is not assignable from " + hintData); } } } } Log.i(TAG, "Hints from the Intent: " + hints); return hints; }
public UndetVar(TypeVar origin, Types types) { super(UNDETVAR, origin); bounds = new EnumMap<InferenceBound, List<Type>>(InferenceBound.class); List<Type> declaredBounds = types.getBounds(origin); declaredCount = declaredBounds.length(); bounds.put(InferenceBound.UPPER, declaredBounds); bounds.put(InferenceBound.LOWER, List.<Type>nil()); bounds.put(InferenceBound.EQ, List.<Type>nil()); }
public static Map<DecodeHintType, Object> parseDecodeHints(Intent intent) { Bundle extras = intent.getExtras(); if (extras == null || extras.isEmpty()) { return null; } Map<DecodeHintType,Object> hints = new EnumMap(DecodeHintType.class); for (DecodeHintType hintType: DecodeHintType.values()) { if (hintType == DecodeHintType.CHARACTER_SET || hintType == DecodeHintType.NEED_RESULT_POINT_CALLBACK || hintType == DecodeHintType.POSSIBLE_FORMATS) { continue; // This hint is specified in another way } String hintName = hintType.name(); if (extras.containsKey(hintName)) { if (hintType.getValueType().equals(Void.class)) { // Void hints are just flags: use the constant specified by the DecodeHintType hints.put(hintType, Boolean.TRUE); } else { Object hintData = extras.get(hintName); if (hintType.getValueType().isInstance(hintData)) { hints.put(hintType, hintData); } else { Log.w(TAG, "Ignoring hint " + hintType + " because it is not assignable from " + hintData); } } } } Log.i(TAG, "Hints from the Intent: " + hints); return hints; }
LambdaTranslationContext(JCLambda tree) { super(tree); Frame frame = frameStack.head; switch (frame.tree.getTag()) { case VARDEF: assignedTo = self = ((JCVariableDecl) frame.tree).sym; break; case ASSIGN: self = null; assignedTo = TreeInfo.symbol(((JCAssign) frame.tree).getVariable()); break; default: assignedTo = self = null; break; } // This symbol will be filled-in in complete this.translatedSym = makePrivateSyntheticMethod(0, null, null, owner.enclClass()); translatedSymbols = new EnumMap<>(LambdaSymbolKind.class); translatedSymbols.put(PARAM, new LinkedHashMap<Symbol, Symbol>()); translatedSymbols.put(LOCAL_VAR, new LinkedHashMap<Symbol, Symbol>()); translatedSymbols.put(CAPTURED_VAR, new LinkedHashMap<Symbol, Symbol>()); translatedSymbols.put(CAPTURED_THIS, new LinkedHashMap<Symbol, Symbol>()); translatedSymbols.put(CAPTURED_OUTER_THIS, new LinkedHashMap<Symbol, Symbol>()); translatedSymbols.put(TYPE_VAR, new LinkedHashMap<Symbol, Symbol>()); freeVarProcessedLocalClasses = new HashSet<>(); }
private EnumHashBiMap(Class<K> keyType) { super(WellBehavedMap.wrap( new EnumMap<K, V>(keyType)), Maps.<V, K>newHashMapWithExpectedSize( keyType.getEnumConstants().length)); this.keyType = keyType; }
/** * Creates new composite Transactions. * * @param identifier Identifier of transaction. */ protected AbstractDOMBrokerTransaction(final Object identifier, Map<LogicalDatastoreType, ? extends DOMStoreTransactionFactory> storeTxFactories) { this.identifier = Preconditions.checkNotNull(identifier, "Identifier should not be null"); this.storeTxFactories = Preconditions.checkNotNull(storeTxFactories, "Store Transaction Factories should not be null"); this.backingTxs = new EnumMap<>(LogicalDatastoreType.class); }
protected OpTestCase() { testScenarios = new EnumMap<>(StreamShape.class); testScenarios.put(StreamShape.REFERENCE, Collections.unmodifiableSet(EnumSet.allOf(StreamTestScenario.class))); testScenarios.put(StreamShape.INT_VALUE, Collections.unmodifiableSet(EnumSet.allOf(IntStreamTestScenario.class))); testScenarios.put(StreamShape.LONG_VALUE, Collections.unmodifiableSet(EnumSet.allOf(LongStreamTestScenario.class))); testScenarios.put(StreamShape.DOUBLE_VALUE, Collections.unmodifiableSet(EnumSet.allOf(DoubleStreamTestScenario.class))); }
private RealmCache(String path) { realmPath = path; refAndCountMap = new EnumMap<>(RealmCacheType.class); for (RealmCacheType type : RealmCacheType.values()) { refAndCountMap.put(type, new RefAndCount()); } }
public EntityDamageEvent(Entity entity, DamageCause cause, float damage) { this(entity, cause, new EnumMap<DamageModifier, Float>(DamageModifier.class) { { put(DamageModifier.BASE, damage); } }); }
private Checker(Node node, Set<Detail> details, boolean anded) { this.node = node; this.details = details; this.anded = anded; this.nodeCount = new EnumMap<>(TemplateId.class); node.getChildNodes() .stream() .map(Node::getType) .forEach(type -> this.nodeCount.computeIfAbsent(type, key -> new AtomicInteger()).incrementAndGet()); this.node.setValidated(true); }
@Override public void unregister(Object listener) { if(listener == null) throw new NullPointerException("listener"); for(EnumMap<Listener.Priority, List<Pair<Object, EventHandler>>> map : handlers.values()) { for(List<Pair<Object, EventHandler>> list : map.values()) { List<Pair<Object, EventHandler>> toRemove = new ArrayList<>(); for(Pair<Object, EventHandler> pair : list) { if(pair.getKey() == listener) toRemove.add(pair); } list.removeAll(toRemove); } } }