List of usage examples for java.util EnumMap EnumMap
public EnumMap(Map<K, ? extends V> m)
From source file:org.apache.syncope.core.logic.init.ClassPathScanImplementationLookup.java
@Override @SuppressWarnings("unchecked") public void load() { classNames = new EnumMap<>(Type.class); for (Type type : Type.values()) { classNames.put(type, new HashSet<String>()); }//from w w w.j a v a 2s . c o m reportletClasses = new HashMap<>(); accountRuleClasses = new HashMap<>(); passwordRuleClasses = new HashMap<>(); ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider( false); scanner.addIncludeFilter(new AssignableTypeFilter(Reportlet.class)); scanner.addIncludeFilter(new AssignableTypeFilter(AccountRule.class)); scanner.addIncludeFilter(new AssignableTypeFilter(PasswordRule.class)); scanner.addIncludeFilter(new AssignableTypeFilter(MappingItemTransformer.class)); scanner.addIncludeFilter(new AssignableTypeFilter(SchedTaskJobDelegate.class)); scanner.addIncludeFilter(new AssignableTypeFilter(ReconciliationFilterBuilder.class)); scanner.addIncludeFilter(new AssignableTypeFilter(LogicActions.class)); scanner.addIncludeFilter(new AssignableTypeFilter(PropagationActions.class)); scanner.addIncludeFilter(new AssignableTypeFilter(PullActions.class)); scanner.addIncludeFilter(new AssignableTypeFilter(PushActions.class)); scanner.addIncludeFilter(new AssignableTypeFilter(PullCorrelationRule.class)); scanner.addIncludeFilter(new AssignableTypeFilter(Validator.class)); scanner.addIncludeFilter(new AssignableTypeFilter(NotificationRecipientsProvider.class)); for (BeanDefinition bd : scanner.findCandidateComponents(StringUtils.EMPTY)) { try { Class<?> clazz = ClassUtils.resolveClassName(bd.getBeanClassName(), ClassUtils.getDefaultClassLoader()); boolean isAbsractClazz = Modifier.isAbstract(clazz.getModifiers()); if (Reportlet.class.isAssignableFrom(clazz) && !isAbsractClazz) { ReportletConfClass annotation = clazz.getAnnotation(ReportletConfClass.class); if (annotation == null) { LOG.warn("Found Reportlet {} without declared configuration", clazz.getName()); } else { classNames.get(Type.REPORTLET_CONF).add(annotation.value().getName()); reportletClasses.put(annotation.value(), (Class<? extends Reportlet>) clazz); } } if (AccountRule.class.isAssignableFrom(clazz) && !isAbsractClazz) { AccountRuleConfClass annotation = clazz.getAnnotation(AccountRuleConfClass.class); if (annotation == null) { LOG.warn("Found account policy rule {} without declared configuration", clazz.getName()); } else { classNames.get(Type.ACCOUNT_RULE_CONF).add(annotation.value().getName()); accountRuleClasses.put(annotation.value(), (Class<? extends AccountRule>) clazz); } } if (PasswordRule.class.isAssignableFrom(clazz) && !isAbsractClazz) { PasswordRuleConfClass annotation = clazz.getAnnotation(PasswordRuleConfClass.class); if (annotation == null) { LOG.warn("Found password policy rule {} without declared configuration", clazz.getName()); } else { classNames.get(Type.PASSWORD_RULE_CONF).add(annotation.value().getName()); passwordRuleClasses.put(annotation.value(), (Class<? extends PasswordRule>) clazz); } } if (MappingItemTransformer.class.isAssignableFrom(clazz) && !isAbsractClazz && !clazz.equals(JEXLMappingItemTransformerImpl.class)) { classNames.get(Type.MAPPING_ITEM_TRANSFORMER).add(clazz.getName()); } if (SchedTaskJobDelegate.class.isAssignableFrom(clazz) && !isAbsractClazz && !PullJobDelegate.class.isAssignableFrom(clazz) && !PushJobDelegate.class.isAssignableFrom(clazz) && !GroupMemberProvisionTaskJobDelegate.class.isAssignableFrom(clazz)) { classNames.get(Type.TASKJOBDELEGATE).add(bd.getBeanClassName()); } if (ReconciliationFilterBuilder.class.isAssignableFrom(clazz) && !isAbsractClazz) { classNames.get(Type.RECONCILIATION_FILTER_BUILDER).add(bd.getBeanClassName()); } if (LogicActions.class.isAssignableFrom(clazz) && !isAbsractClazz) { classNames.get(Type.LOGIC_ACTIONS).add(bd.getBeanClassName()); } if (PropagationActions.class.isAssignableFrom(clazz) && !isAbsractClazz) { classNames.get(Type.PROPAGATION_ACTIONS).add(bd.getBeanClassName()); } if (PullActions.class.isAssignableFrom(clazz) && !isAbsractClazz) { classNames.get(Type.PULL_ACTIONS).add(bd.getBeanClassName()); } if (PushActions.class.isAssignableFrom(clazz) && !isAbsractClazz) { classNames.get(Type.PUSH_ACTIONS).add(bd.getBeanClassName()); } if (PullCorrelationRule.class.isAssignableFrom(clazz) && !isAbsractClazz && !PlainAttrsPullCorrelationRule.class.isAssignableFrom(clazz)) { classNames.get(Type.PULL_CORRELATION_RULE).add(bd.getBeanClassName()); } if (Validator.class.isAssignableFrom(clazz) && !isAbsractClazz) { classNames.get(Type.VALIDATOR).add(bd.getBeanClassName()); } if (NotificationRecipientsProvider.class.isAssignableFrom(clazz) && !isAbsractClazz) { classNames.get(Type.NOTIFICATION_RECIPIENTS_PROVIDER).add(bd.getBeanClassName()); } } catch (Throwable t) { LOG.warn("Could not inspect class {}", bd.getBeanClassName(), t); } } classNames = Collections.unmodifiableMap(classNames); reportletClasses = Collections.unmodifiableMap(reportletClasses); accountRuleClasses = Collections.unmodifiableMap(accountRuleClasses); passwordRuleClasses = Collections.unmodifiableMap(passwordRuleClasses); LOG.debug("Implementation classes found: {}", classNames); }
From source file:org.sonar.java.checks.verifier.CheckVerifier.java
protected void collectExpectedIssues(String comment, int line) { String expectedStart = getExpectedIssueTrigger(); if (comment.startsWith(expectedStart)) { String cleanedComment = StringUtils.remove(comment, expectedStart); EnumMap<IssueAttribute, String> attr = new EnumMap<>(IssueAttribute.class); String expectedMessage = StringUtils.substringBetween(cleanedComment, "{{", "}}"); if (StringUtils.isNotEmpty(expectedMessage)) { attr.put(IssueAttribute.MESSAGE, expectedMessage); }// w ww . j a va2 s . co m int expectedLine = line; String attributesSubstr = extractAttributes(comment, attr); cleanedComment = StringUtils .stripEnd(StringUtils.remove(StringUtils.remove(cleanedComment, "[[" + attributesSubstr + "]]"), "{{" + expectedMessage + "}}"), " \t"); if (StringUtils.startsWith(cleanedComment, "@")) { final int lineAdjustment; final char firstChar = cleanedComment.charAt(1); final int endIndex = cleanedComment.indexOf(' '); if (endIndex == -1) { lineAdjustment = Integer.parseInt(cleanedComment.substring(2)); } else { lineAdjustment = Integer.parseInt(cleanedComment.substring(2, endIndex)); } if (firstChar == '+') { expectedLine += lineAdjustment; } else if (firstChar == '-') { expectedLine -= lineAdjustment; } else { Fail.fail("Use only '@+N' or '@-N' to shifts messages."); } } updateEndLine(expectedLine, attr); expected.put(expectedLine, attr); } }
From source file:io.lavagna.service.SearchService.java
public Map<ColumnDefinition, Integer> findTaksByColumnDefinition(Integer projectId, Integer boardId, boolean excludeArchivedBoards, UserWithPermission user) { SearchFilter locationFilter = filter(SearchFilter.FilterType.LOCATION, SearchFilter.ValueType.STRING, BoardColumn.BoardColumnLocation.BOARD.toString()); Map<ColumnDefinition, Integer> results = new EnumMap<>(ColumnDefinition.class); SearchFilter statusOpen = filterByColumnDefinition(ColumnDefinition.OPEN); SearchResults openTasks = find(filtersAsList(locationFilter, statusOpen, excludeArchivedBoards), projectId, boardId, user, 0);//w w w . j a v a2 s . c o m results.put(ColumnDefinition.OPEN, openTasks.getCount()); SearchFilter statusClosed = filterByColumnDefinition(ColumnDefinition.CLOSED); SearchResults closedTasks = find(filtersAsList(locationFilter, statusClosed, excludeArchivedBoards), projectId, boardId, user, 0); results.put(ColumnDefinition.CLOSED, closedTasks.getCount()); SearchFilter statusBacklog = filterByColumnDefinition(ColumnDefinition.BACKLOG); SearchResults backlogTasks = find(filtersAsList(locationFilter, statusBacklog, excludeArchivedBoards), projectId, boardId, user, 0); results.put(ColumnDefinition.BACKLOG, backlogTasks.getCount()); SearchFilter statusDeferred = filterByColumnDefinition(ColumnDefinition.DEFERRED); SearchResults deferredTasks = find(filtersAsList(locationFilter, statusDeferred, excludeArchivedBoards), projectId, boardId, user, 0); results.put(ColumnDefinition.DEFERRED, deferredTasks.getCount()); return results; }
From source file:org.janusgraph.graphdb.database.log.TransactionLogHeader.java
public StaticBuffer serializeUserLog(Serializer serializer, Entry sourceTxEntry, StandardTransactionId sourceTxId) { Preconditions.checkArgument(sourceTxEntry != null && sourceTxEntry.status == LogTxStatus.PRECOMMIT && sourceTxEntry.header.transactionId == sourceTxId.getTransactionId()); StaticBuffer sourceContent = sourceTxEntry.content; Preconditions.checkArgument(sourceContent != null && sourceContent.length() > 0); EnumMap<LogTxMeta, Object> meta = new EnumMap<LogTxMeta, Object>(LogTxMeta.class); meta.put(LogTxMeta.SOURCE_TRANSACTION, sourceTxId); DataOutput out = serializeHeader(serializer, 50 + sourceContent.length(), LogTxStatus.USER_LOG, meta); out.putBytes(sourceContent);//from w ww .j a v a 2s.co m return out.getStaticBuffer(); }
From source file:it.units.malelab.sse.MyGeneticAlgorithm.java
private EnumMap<Evaluator.ResultType, Double> mean(List<EnumMap<Evaluator.ResultType, Double>> statsList) { EnumMap<Evaluator.ResultType, Double> meanStats = new EnumMap<>(Evaluator.ResultType.class); for (Evaluator.ResultType type : Evaluator.ResultType.values()) { double s = 0; double c = 0; for (EnumMap<Evaluator.ResultType, Double> stats : statsList) { if (stats.containsKey(type)) { s = s + stats.get(type); c = c + 1;/*from w w w .ja v a 2 s .co m*/ } } if (c > 0) { meanStats.put(type, s / c); } } return meanStats; }
From source file:alfio.manager.NotificationManager.java
@Autowired public NotificationManager(Mailer mailer, MessageSource messageSource, PlatformTransactionManager transactionManager, EmailMessageRepository emailMessageRepository, EventRepository eventRepository, EventDescriptionRepository eventDescriptionRepository, OrganizationRepository organizationRepository, ConfigurationManager configurationManager, FileUploadManager fileUploadManager, TemplateManager templateManager, TicketReservationRepository ticketReservationRepository, TicketCategoryRepository ticketCategoryRepository, PassBookManager passBookManager) { this.messageSource = messageSource; this.mailer = mailer; this.emailMessageRepository = emailMessageRepository; this.eventRepository = eventRepository; this.organizationRepository = organizationRepository; this.tx = new TransactionTemplate(transactionManager); this.configurationManager = configurationManager; GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(Mailer.Attachment.class, new AttachmentConverter()); this.gson = builder.create(); attachmentTransformer = new EnumMap<>(Mailer.AttachmentIdentifier.class); attachmentTransformer.put(Mailer.AttachmentIdentifier.CALENDAR_ICS, generateICS(eventRepository, eventDescriptionRepository, ticketCategoryRepository)); attachmentTransformer.put(Mailer.AttachmentIdentifier.RECEIPT_PDF, receiptOrInvoiceFactory(eventRepository, payload -> TemplateProcessor.buildReceiptPdf(payload.getLeft(), fileUploadManager, payload.getMiddle(), templateManager, payload.getRight()))); attachmentTransformer.put(Mailer.AttachmentIdentifier.INVOICE_PDF, receiptOrInvoiceFactory(eventRepository, payload -> TemplateProcessor.buildInvoicePdf(payload.getLeft(), fileUploadManager, payload.getMiddle(), templateManager, payload.getRight()))); attachmentTransformer.put(Mailer.AttachmentIdentifier.PASSBOOK, passBookManager::getPassBook); attachmentTransformer.put(Mailer.AttachmentIdentifier.TICKET_PDF, generateTicketPDF(eventRepository, organizationRepository, configurationManager, fileUploadManager, templateManager, ticketReservationRepository)); }
From source file:tasly.greathealth.oms.web.inventory.rest.resources.ItemInfoResource.java
@SuppressWarnings("null") @GET/* www. j a va 2s . c om*/ @Path("/flag0update") public Response updateQuantity() { omsLOG.info("Begin to update quantity where flag=0."); final Collection<ItemInfo> itemInfos = itemInfoFacade.getAll(); int flag; String sku; EnumMap<HandleReturn, Object> handleReturn = new EnumMap<HandleReturn, Object>(HandleReturn.class); boolean updateStatus = false; if (itemInfos.size() == 0 || itemInfos == null) { omsLOG.error("Get all itemInfos failed!"); } else { for (final ItemInfo itemInfo : itemInfos) { flag = itemInfo.getStockManageFlag(); sku = itemInfo.getSku(); if (flag == 0) { final List<TaslyItemLocationData> checkTaslyItemLocationDatas = taslyItemLocationService .getByItemID(sku); if (checkTaslyItemLocationDatas == null || checkTaslyItemLocationDatas.size() == 0) { omsLOG.error("sku:" + sku + ",no ItemLocation data!"); continue; } else { try { handleReturn = itemQuantityService.handleUpdateMethod(checkTaslyItemLocationDatas, sku, flag, 0); } catch (final Exception e) { omsLOG.error("handle sku:" + sku + " failed and error is " + e); handleReturn.put(HandleReturn.handleStatus, false); } if ((boolean) handleReturn.get(HandleReturn.handleStatus)) { try { updateStatus = itemQuantityService.updateMethod(sku, flag, 0); if (updateStatus) { omsLOG.debug("sku:" + sku + ",flag=0 allocated ok!"); } } catch (final Exception e) { omsLOG.error("update sku:" + sku + " failed and error is " + e); } } } } } } omsLOG.info("Update quantity where flag=0 finished."); return Response.status(Response.Status.OK).build(); }
From source file:openlr.decoder.properties.OpenLRDecoderProperties.java
/** * Instantiates a new open lr decoder properties. * /*from w w w. java2 s.co m*/ * @param config * the config * @throws OpenLRProcessingException * the open lr processing exception */ public OpenLRDecoderProperties(final Configuration config) throws OpenLRProcessingException { bearingDistance = OpenLRPropertyAccess.getIntegerPropertyValue(config, OpenLRDecoderProperty.BEAR_DIST); maxNodeDistance = OpenLRPropertyAccess.getIntegerPropertyValue(config, OpenLRDecoderProperty.MAX_NODE_DIST); nodeFactor = OpenLRPropertyAccess.getIntegerPropertyValue(config, OpenLRDecoderProperty.NODE_FACTOR); lineFactor = OpenLRPropertyAccess.getIntegerPropertyValue(config, OpenLRDecoderProperty.LINE_FACTOR); frcVariance = OpenLRPropertyAccess.getIntegerPropertyValue(config, OpenLRDecoderProperty.FRC_VARIANCE); minimumAcceptedRating = OpenLRPropertyAccess.getIntegerPropertyValue(config, OpenLRDecoderProperty.MIN_ACC_RATING); maxNumberRetries = OpenLRPropertyAccess.getIntegerPropertyValue(config, OpenLRDecoderProperty.MAX_NR_RETRIES); sameLineDegradation = OpenLRPropertyAccess.getFloatPropertyValue(config, OpenLRDecoderProperty.SAME_LINE_DEGRAD); connectedRouteIncrease = OpenLRPropertyAccess.getFloatPropertyValue(config, OpenLRDecoderProperty.CONNECT_ROUTE_INC); dnpVariance = OpenLRPropertyAccess.getIntegerPropertyValue(config, OpenLRDecoderProperty.DNP_VARIANCE); maxBearingDiff = OpenLRPropertyAccess.getIntegerPropertyValue(config, OpenLRDecoderProperty.MAX_BEAR_DIFF); frcRating = new EnumMap<RatingCategory, Integer>(RatingCategory.class); fowRating = new EnumMap<RatingCategory, Integer>(RatingCategory.class); bearingRating = new EnumMap<RatingCategory, Integer>(RatingCategory.class); frcIntervals = new EnumMap<RatingCategory, Integer>(RatingCategory.class); bearingIntervals = new EnumMap<RatingCategory, Integer>(RatingCategory.class); for (RatingCategory cat : RatingCategory.values()) { fowRating.put(cat, OpenLRPropertyAccess.getIntegerPropertyValueFromMap(config, OpenLRDecoderProperty.FOW_RATING, cat.getIdentifier())); frcRating.put(cat, OpenLRPropertyAccess.getIntegerPropertyValueFromMap(config, OpenLRDecoderProperty.FRC_RATING, cat.getIdentifier())); bearingRating.put(cat, OpenLRPropertyAccess.getIntegerPropertyValueFromMap(config, OpenLRDecoderProperty.BEAR_RATING, cat.getIdentifier())); if (cat != RatingCategory.POOR) { frcIntervals.put(cat, OpenLRPropertyAccess.getIntegerPropertyValueFromMap(config, OpenLRDecoderProperty.FRC_INTERVALS, cat.getIdentifier())); bearingIntervals.put(cat, OpenLRPropertyAccess.getIntegerPropertyValueFromMap(config, OpenLRDecoderProperty.BEAR_INTERVALS, cat.getIdentifier())); } } calcAffectedLines = OpenLRPropertyAccess.getBooleanPropertyValue(config, OpenLRDecoderProperty.CALC_AFFECTED_LINES); linesDirectlyFactor = OpenLRPropertyAccess.getFloatPropertyValue(config, OpenLRDecoderProperty.LINES_DIRECTLY_FACTOR); compTime4Cache = OpenLRPropertyAccess.getIntegerPropertyValue(config, OpenLRDecoderProperty.COMP_TIME_4_CACHE); }
From source file:fr.ritaly.dungeonmaster.map.FloorSwitch.java
public void addActuator(TriggerType triggerType, Actuator actuator) { Validate.notNull(triggerType, "The given trigger type is null"); Validate.notNull(actuator, "The given actuator is null"); if (actuators == null) { // Crer la Map la vole actuators = new EnumMap<TriggerType, Actuator>(TriggerType.class); }//from w w w. j a v a 2 s .c o m actuators.put(triggerType, Actuators.combine(actuators.get(triggerType), actuator)); }
From source file:com.trenako.criteria.SearchRequest.java
private void initValues() { values = new EnumMap<>(Criteria.class); }