List of usage examples for java.util EnumMap EnumMap
public EnumMap(Map<K, ? extends V> m)
From source file:com.adobe.acs.commons.mcp.impl.processes.PageRelocator.java
private void note(String page, Report col, Object value) { synchronized (reportData) { if (!reportData.containsKey(page)) { reportData.put(page, new EnumMap<>(Report.class)); }/*from ww w . j av a 2 s .c o m*/ reportData.get(page).put(col, value); } }
From source file:fr.ritaly.dungeonmaster.ai.CreatureManager.java
private final void _addCreature(Creature creature) { Validate.notNull(creature, "The given creature is null"); if (!Creature.Size.FOUR.equals(creature.getSize())) { throw new IllegalArgumentException("The given creature <" + creature + "> has an invalid size (actual: " + creature.getSize() + ", expected: " + Creature.Size.FOUR + ")"); }//from www . j a v a 2s . c om if (hasCreatures()) { throw new IllegalArgumentException("The element " + position + " is already occupied by at least one creature (" + getCreatures() + ")"); } if (creatures == null) { creatures = new EnumMap<Sector, Creature>(Sector.class); } creatures.put(Sector.NORTH_EAST, creature); creatures.put(Sector.NORTH_WEST, creature); creatures.put(Sector.SOUTH_EAST, creature); creatures.put(Sector.SOUTH_WEST, creature); if (log.isDebugEnabled()) { log.debug(creature + " stepped on " + position + " (4 sectors)"); } }
From source file:org.openhab.io.imperihome.internal.processor.ItemProcessor.java
private Map<TagType, List<String>> getIssTags(Item item) { Map<TagType, List<String>> tags = new EnumMap<>(TagType.class); for (String tag : item.getTags()) { if (tag.startsWith(PREFIX_ISS)) { String issTag = tag.substring(PREFIX_ISS.length()); for (TagType tagType : TagType.values()) { if (issTag.startsWith(tagType.getPrefix() + ':')) { String tagValue = issTag.substring(tagType.getPrefix().length() + 1); if (!tags.containsKey(tagType)) { tags.put(tagType, new LinkedList<String>()); } else if (!tagType.isMultiValue()) { logger.error("Found multiple values for tag {} - only first value is used", tagType.getPrefix()); }//from ww w .j a v a2 s . c o m tags.get(tagType).add(tagValue); break; } } } } return tags; }
From source file:gov.nih.nci.firebird.service.annual.registration.AnnualRegistrationServiceBean.java
@Override public FirebirdMessage getCoordinatorCompletedRegistrationEmailMessage(FirebirdUser coordinator, AnnualRegistration registration) { Map<FirebirdTemplateParameter, Object> parameterValues = new EnumMap<FirebirdTemplateParameter, Object>( FirebirdTemplateParameter.class); parameterValues.put(FirebirdTemplateParameter.ANNUAL_REGISTRATION, registration); parameterValues.put(FirebirdTemplateParameter.FIREBIRD_LINK, generateRegistrationLink(registration)); parameterValues.put(FirebirdTemplateParameter.REGISTRATION_COORDINATOR, coordinator.getPerson()); return getTemplateService().generateMessage( FirebirdMessageTemplate.COORDINATOR_COMPLETED_ANNUAL_REGISTRATION_EMAIL, parameterValues); }
From source file:org.apache.hadoop.corona.ConfigManager.java
/** * The main constructor for the config manager given the types and the name * of the config file to use/*from w w w .j a v a 2s. c o m*/ * @param types the types to initialize the configuration for */ public ConfigManager(Collection<ResourceType> types, CoronaConf conf) { this.TYPES = types; this.conf = conf; Class<?> poolsConfigDocumentGeneratorClass = conf.getPoolsConfigDocumentGeneratorClass(); if (poolsConfigDocumentGeneratorClass != null) { try { this.poolsConfigDocumentGenerator = (PoolsConfigDocumentGenerator) poolsConfigDocumentGeneratorClass .newInstance(); poolsConfigDocumentGenerator.initialize(conf); } catch (InstantiationException e) { LOG.warn("Failed to instantiate " + poolsConfigDocumentGeneratorClass, e); } catch (IllegalAccessException e) { LOG.warn("Failed to instantiate " + poolsConfigDocumentGeneratorClass, e); } } else { poolsConfigDocumentGenerator = null; } poolsReloadPeriodMs = conf.getPoolsReloadPeriodMs(); configReloadPeriodMs = conf.getConfigReloadPeriodMs(); LOG.info("ConfigManager: PoolsConfigDocumentGenerator class = " + poolsConfigDocumentGeneratorClass + ", poolsReloadPeriodMs = " + poolsReloadPeriodMs + ", configReloadPeriodMs = " + configReloadPeriodMs); typeToNodeWait = new EnumMap<ResourceType, Long>(ResourceType.class); typeToRackWait = new EnumMap<ResourceType, Long>(ResourceType.class); defaultPoolComparator = DEFAULT_POOL_COMPARATOR; shareStarvingRatio = DEFAULT_SHARE_STARVING_RATIO; minPreemptPeriod = DEFAULT_MIN_PREEMPT_PERIOD; grantsPerIteration = DEFAULT_GRANTS_PER_ITERATION; starvingTimeForMinimum = DEFAULT_STARVING_TIME_FOR_MINIMUM; starvingTimeForShare = DEFAULT_STARVING_TIME_FOR_SHARE; preemptedTaskMaxRunningTime = DEFAULT_PREEMPT_TASK_MAX_RUNNING_TIME; preemptionRounds = DEFAULT_PREEMPTION_ROUNDS; scheduleFromNodeToSession = DEFAULT_SCHEDULE_FROM_NODE_TO_SESSION; reloadThread = new ReloadThread(); reloadThread.setName("Config reload thread"); reloadThread.setDaemon(true); for (ResourceType type : TYPES) { typeToNodeWait.put(type, 0L); typeToRackWait.put(type, 0L); } ClassLoader cl = Thread.currentThread().getContextClassLoader(); if (cl == null) { cl = ConfigManager.class.getClassLoader(); } classLoader = cl; if (poolsConfigDocumentGenerator != null) { if (generatePoolsConfigIfClassSet() == null) { throw new IllegalStateException("Failed to generate the pools " + "config. Must succeed on initialization of ConfigManager."); } } try { findConfigFiles(); reloadAllConfig(true); } catch (IOException e) { LOG.error("Failed to load " + configFileName, e); } catch (SAXException e) { LOG.error("Failed to load " + configFileName, e); } catch (ParserConfigurationException e) { LOG.error("Failed to load " + configFileName, e); } catch (JSONException e) { LOG.error("Failed to load " + configFileName, e); } }
From source file:org.talend.camel.designer.ui.wizards.JavaCamelJobScriptsExportWSWizardPage.java
@Override protected Map<ExportChoice, Object> getExportChoiceMap() { Map<ExportChoice, Object> exportChoiceMap = new EnumMap<ExportChoice, Object>(ExportChoice.class); exportChoiceMap.put(ExportChoice.needJobItem, false); exportChoiceMap.put(ExportChoice.needSourceCode, false); exportChoiceMap.put(ExportChoice.needMetaInfo, true); exportChoiceMap.put(ExportChoice.needContext, true); exportChoiceMap.put(ExportChoice.needLauncher, exportAsZip); if (addBSButton != null) { exportChoiceMap.put(ExportChoice.needMavenScript, addBSButton.getSelection()); if (isAddMavenScript()) { exportChoiceMap.put(ExportChoice.needAssembly, true); exportChoiceMap.put(ExportChoice.needLauncher, true); }/*from www. j a v a 2s.c om*/ } exportChoiceMap.put(ExportChoice.onlyDefautContext, onlyExportDefaultContext); return exportChoiceMap; }
From source file:org.apache.qpid.server.security.access.config.RuleSet.java
private Map<ObjectType, List<Rule>> getObjectToRuleCache(final Subject subject, final Operation operation) { // Lookup identity in cache and create empty operation map if required Map<Operation, Map<ObjectType, List<Rule>>> operations = _cache.get(subject); if (operations == null) { operations = new EnumMap<Operation, Map<ObjectType, List<Rule>>>(Operation.class); _cache.put(subject, operations); }/*from w w w. j a va 2 s . co m*/ // Lookup operation and create empty object type map if required Map<ObjectType, List<Rule>> objects = operations.get(operation); if (objects == null) { objects = new EnumMap<ObjectType, List<Rule>>(ObjectType.class); operations.put(operation, objects); } return objects; }
From source file:fr.ritaly.dungeonmaster.item.Item.java
protected Item(Type type) { Validate.notNull(type, "The given item type is null"); this.type = type; // Store the number of charges associated to this item to decrease this // number when the item's used Map<Action, Integer> map = null; for (ActionDef actionDef : type.getActions()) { if (actionDef.isUseCharges()) { // This action is limited by a number of charges if (map == null) { map = new EnumMap<Action, Integer>(Action.class); }/* www. j a v a2 s.c o m*/ // FIXME How to determine the number of charges ? This differs from one object to another map.put(actionDef.getAction(), 3); } } if ((map != null) && !map.isEmpty()) { this.charges = map; } else { this.charges = null; } this.effects = type.getEffects(); }
From source file:org.apache.hadoop.raid.RaidNodeMetrics.java
private Map<String, Map<RaidState, MetricsLongValue>> createSourceMap() { Map<String, Map<RaidState, MetricsLongValue>> result = new HashMap<String, Map<RaidState, MetricsLongValue>>(); for (Codec codec : Codec.getCodecs()) { Map<RaidState, MetricsLongValue> m = new HashMap<RaidState, MetricsLongValue>(); for (RaidState state : RaidState.values()) { m.put(state, null);/*ww w . j av a 2 s .c o m*/ } m = new EnumMap<RaidState, MetricsLongValue>(m); result.put(codec.id, m); } return result; }
From source file:fr.ritaly.dungeonmaster.map.Element.java
public final void addProjectile(Projectile projectile, Sector sector) { Validate.notNull(projectile, "The given projectile is null"); Validate.notNull(sector, "The given sector is null"); if (!isTraversableByProjectile() && !Type.DOOR.equals(getType())) { // Une porte peut accueillir un projectile mme si celle-ci est // ferme afin qu'il puisse exploser throw new UnsupportedOperationException("The projectile can't arrive on " + getId()); }/*from w w w .j a va2 s . c om*/ if (log.isDebugEnabled()) { log.debug(projectile.getId() + " arrived on " + getId() + " (sector: " + sector + ")"); } if (projectiles == null) { // Crer la Map la vole projectiles = new EnumMap<Sector, Projectile>(Sector.class); } // L'emplacement doit initialement tre vide if (projectiles.get(sector) != null) { throw new IllegalArgumentException("The cell " + sector + " of element " + getId() + " is already occupied by a projectile (" + projectiles.get(sector) + ")"); } // Mmoriser le projectile projectiles.put(sector, projectile); afterProjectileArrived(projectile); }