List of usage examples for java.util EnumMap EnumMap
public EnumMap(Map<K, ? extends V> m)
From source file:org.marketcetera.photon.views.FillsView.java
@Override public void init(IViewSite site, IMemento memento) throws PartInitException { super.init(site, memento); if (memento != null) { IMemento[] filters = memento.getChildren(FILTER_TAG); if (filters.length > 0) { mFilters = new EnumMap<Grouping, String>(Grouping.class); for (IMemento filter : filters) { mFilters.put(Grouping.valueOf(filter.getString(GROUPING_ATTRIBUTE)), filter.getString(VALUE_ATTRIBUTE)); }/*from ww w.j a va 2 s.com*/ } IMemento instrument = memento.getChild(INSTRUMENT_TAG); if (instrument != null) { mInstrument = InstrumentFromMemento.restore(instrument); } } updatePartName(); }
From source file:com.att.aro.ui.view.diagnostictab.plot.WifiPlot.java
@Override public void populate(XYPlot plot, AROTraceData analysis) { wifiData = new XYIntervalSeriesCollection(); if (analysis == null) { logger.info("didn't get analysis trace data! "); } else {//from w ww.j a va 2 s . c o m TraceResultType resultType = analysis.getAnalyzerResult().getTraceresult().getTraceResultType(); if (resultType.equals(TraceResultType.TRACE_FILE)) { logger.info("it is not contain the file "); } else { TraceDirectoryResult traceresult = (TraceDirectoryResult) analysis.getAnalyzerResult() .getTraceresult(); Map<WifiState, XYIntervalSeries> seriesMap = new EnumMap<WifiState, XYIntervalSeries>( WifiState.class); for (WifiState eventType : WifiState.values()) { XYIntervalSeries series = new XYIntervalSeries(eventType); seriesMap.put(eventType, series); switch (eventType) { case WIFI_UNKNOWN: case WIFI_DISABLED: // Don't chart these break; default: wifiData.addSeries(series); break; } } // Populate the data set List<WifiInfo> wifiInfos = traceresult.getWifiInfos(); final Map<Double, WifiInfo> eventMap = new HashMap<Double, WifiInfo>(wifiInfos.size()); Iterator<WifiInfo> iter = wifiInfos.iterator(); if (iter.hasNext()) { while (iter.hasNext()) { WifiInfo wifiEvent = iter.next(); seriesMap.get(wifiEvent.getWifiState()).add(wifiEvent.getBeginTimeStamp(), wifiEvent.getBeginTimeStamp(), wifiEvent.getEndTimeStamp(), 0.5, 0, 1); eventMap.put(wifiEvent.getBeginTimeStamp(), wifiEvent); } } XYItemRenderer renderer = plot.getRenderer(); for (WifiState eventType : WifiState.values()) { Color paint; switch (eventType) { case WIFI_CONNECTED: case WIFI_CONNECTING: case WIFI_DISCONNECTING: paint = new Color(34, 177, 76); break; case WIFI_DISCONNECTED: case WIFI_SUSPENDED: paint = Color.YELLOW; break; default: paint = Color.WHITE; break; } int index = wifiData.indexOf(eventType); if (index >= 0) { renderer.setSeriesPaint(index, paint); } } // Assign ToolTip to renderer renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { WifiState eventType = (WifiState) wifiData.getSeries(series).getKey(); StringBuffer message = new StringBuffer( ResourceBundleHelper.getMessageString("wifi.tooltip.prefix")); message.append(MessageFormat.format(ResourceBundleHelper.getMessageString("wifi.tooltip"), dataset.getX(series, item), ResourceBundleHelper.getEnumString(eventType))); switch (eventType) { case WIFI_CONNECTED: WifiInfo info = eventMap.get(dataset.getX(series, item)); if (info != null && info.getWifiState() == WifiState.WIFI_CONNECTED) { message.append(MessageFormat.format( ResourceBundleHelper.getMessageString("wifi.connTooltip"), info.getWifiMacAddress(), info.getWifiRSSI(), info.getWifiSSID())); } break; default: break; } message.append(ResourceBundleHelper.getMessageString("wifi.tooltip.suffix")); return message.toString(); } }); } } plot.setDataset(wifiData); // return plot; }
From source file:org.rakam.server.http.ParameterProcessor.java
public static Parameter applyAnnotations(Swagger swagger, Parameter parameter, Type type, List<Annotation> annotations) { final AnnotationsHelper helper = new AnnotationsHelper(annotations); if (helper.isContext()) { return null; }/*from w ww . j a va 2 s . co m*/ final ParamWrapper<?> param = helper.getApiParam(); if (param.isHidden()) { return null; } final String defaultValue = helper.getDefaultValue(); if (parameter instanceof AbstractSerializableParameter) { final AbstractSerializableParameter<?> p = (AbstractSerializableParameter<?>) parameter; if (param.isRequired()) { p.setRequired(true); } if (StringUtils.isNotEmpty(param.getName())) { p.setName(param.getName()); } if (StringUtils.isNotEmpty(param.getDescription())) { p.setDescription(param.getDescription()); } if (StringUtils.isNotEmpty(param.getAccess())) { p.setAccess(param.getAccess()); } if (StringUtils.isNotEmpty(param.getDataType())) { p.setType(param.getDataType()); } AllowableValues allowableValues = AllowableValuesUtils.create(param.getAllowableValues()); if (p.getItems() != null || param.isAllowMultiple()) { if (p.getItems() == null) { // Convert to array final Map<PropertyBuilder.PropertyId, Object> args = new EnumMap<PropertyBuilder.PropertyId, Object>( PropertyBuilder.PropertyId.class); args.put(PropertyBuilder.PropertyId.DEFAULT, p.getDefaultValue()); p.setDefaultValue(null); args.put(PropertyBuilder.PropertyId.ENUM, p.getEnum()); p.setEnum(null); args.put(PropertyBuilder.PropertyId.MINIMUM, p.getMinimum()); p.setMinimum(null); args.put(PropertyBuilder.PropertyId.EXCLUSIVE_MINIMUM, p.isExclusiveMinimum()); p.setExclusiveMinimum(null); args.put(PropertyBuilder.PropertyId.MAXIMUM, p.getMaximum()); p.setMaximum(null); args.put(PropertyBuilder.PropertyId.EXCLUSIVE_MAXIMUM, p.isExclusiveMaximum()); p.setExclusiveMaximum(null); Property items = PropertyBuilder.build(p.getType(), p.getFormat(), args); p.type(ArrayProperty.TYPE).format(null).items(items); } final Map<PropertyBuilder.PropertyId, Object> args = new EnumMap<PropertyBuilder.PropertyId, Object>( PropertyBuilder.PropertyId.class); if (StringUtils.isNotEmpty(defaultValue)) { args.put(PropertyBuilder.PropertyId.DEFAULT, defaultValue); } if (allowableValues != null) { args.putAll(allowableValues.asPropertyArguments()); } PropertyBuilder.merge(p.getItems(), args); } else { if (StringUtils.isNotEmpty(defaultValue)) { p.setDefaultValue(defaultValue); } processAllowedValues(allowableValues, p); } } else { // must be a body param BodyParameter bp = new BodyParameter(); bp.setRequired(param.isRequired()); bp.setName(StringUtils.isNotEmpty(param.getName()) ? param.getName() : "body"); if (StringUtils.isNotEmpty(param.getDescription())) { bp.setDescription(param.getDescription()); } if (StringUtils.isNotEmpty(param.getAccess())) { bp.setAccess(param.getAccess()); } final Property property = ModelConverters.getInstance().readAsProperty(type); if (property != null) { final Map<PropertyBuilder.PropertyId, Object> args = new EnumMap<PropertyBuilder.PropertyId, Object>( PropertyBuilder.PropertyId.class); if (StringUtils.isNotEmpty(defaultValue)) { args.put(PropertyBuilder.PropertyId.DEFAULT, defaultValue); } bp.setSchema(PropertyBuilder.toModel(PropertyBuilder.merge(property, args))); for (Map.Entry<String, Model> entry : ModelConverters.getInstance().readAll(type).entrySet()) { swagger.addDefinition(entry.getKey(), entry.getValue()); } } parameter = bp; } return parameter; }
From source file:org.apache.syncope.core.init.ImplementationClassNamesLoader.java
public void load() { classNames = new EnumMap<Type, Set<String>>(Type.class); for (Type type : Type.values()) { classNames.put(type, new HashSet<String>()); }/*ww w.j av a 2s . co m*/ Set<String> classes = new HashSet<String>(); classes.add(UserReportlet.class.getName()); classes.add(RoleReportlet.class.getName()); classes.add(StaticReportlet.class.getName()); classNames.put(Type.REPORTLET, classes); classes = new HashSet<String>(); classes.add(SampleJob.class.getName()); classNames.put(Type.TASKJOB, classes); classes = new HashSet<String>(); classes.add(LDAPMembershipSyncActions.class.getName()); classes.add(LDAPPasswordSyncActions.class.getName()); classes.add(DBPasswordSyncActions.class.getName()); classNames.put(Type.SYNC_ACTIONS, classes); classes = new HashSet<String>(); classes.add(LDAPMembershipPropagationActions.class.getName()); classes.add(LDAPPasswordPropagationActions.class.getName()); classes.add(DBPasswordPropagationActions.class.getName()); classNames.put(Type.PROPAGATION_ACTIONS, classes); classes = new HashSet<String>(); classes.add(BasicValidator.class.getName()); classes.add(AlwaysTrueValidator.class.getName()); classes.add(EmailAddressValidator.class.getName()); classNames.put(Type.VALIDATOR, classes); classNames = Collections.unmodifiableMap(classNames); LOG.debug("Implementation classes found: {}", classNames); }
From source file:edu.cornell.mannlib.vitro.webapp.utils.developer.DeveloperSettings.java
private DeveloperSettings() { this.settings = new EnumMap<>(Key.class); }
From source file:illarion.compile.Compiler.java
private static void processFileMode(@Nonnull final CommandLine cmd) throws IOException { storagePaths = new EnumMap<>(CompilerType.class); String npcPath = cmd.getOptionValue('n'); if (npcPath != null) { storagePaths.put(CompilerType.easyNPC, Paths.get(npcPath)); }// w w w .j a va2 s. com String questPath = cmd.getOptionValue('q'); if (questPath != null) { storagePaths.put(CompilerType.easyQuest, Paths.get(questPath)); } for (String file : cmd.getArgs()) { Path path = Paths.get(file); if (Files.isDirectory(path)) { Files.walkFileTree(path, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { FileVisitResult result = super.visitFile(file, attrs); if (result == FileVisitResult.CONTINUE) { processPath(file); return FileVisitResult.CONTINUE; } return result; } }); } else { processPath(path); } } }
From source file:tasly.greathealth.oms.inventory.facades.DefaultItemQuantityFacade.java
@Override public boolean updateItemQuantity() { EnumMap<HandleReturn, Object> handleReturn = new EnumMap<HandleReturn, Object>(HandleReturn.class); boolean updateStatus = true; final List<String> errorSkus = new ArrayList<>(); final List<ItemInfoData> itemInfoDatas = itemInfoService.getAll(); if (itemInfoDatas != null && itemInfoDatas.size() > 0) { for (int i = 0; i < itemInfoDatas.size(); i++) { final String sku = itemInfoDatas.get(i).getSku(); final int totalNumber = itemInfoDatas.get(i).getQuantity(); final int flag = itemInfoDatas.get(i).getStockManageFlag(); final Date nowDay = new Date(); final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssZ"); final String nowDate = sdf.format(nowDay); final String nowDateString = nowDate.substring(0, 8); final String modifyDay = itemInfoDatas.get(i).getExt1(); String modifyDayString = null; if (StringUtils.isEmpty(modifyDay)) { modifyDayString = ""; } else { modifyDayString = modifyDay.substring(0, 8); }//from w ww .j a va2 s.c o m if ("".equals(modifyDayString) || nowDateString.equals(modifyDayString) || 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, totalNumber); } 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)) { if ((boolean) handleReturn.get(HandleReturn.errorStatus)) { errorSkus.add(sku); } try { updateStatus = itemQuantityService.updateMethod(sku, flag, (int) handleReturn.get(HandleReturn.availableNumber)); if (flag == 0 && updateStatus) { omsLOG.debug("sku:" + sku + ",flag=0 allocated ok!"); } else if (flag == 1 && updateStatus) { omsLOG.debug("sku:" + sku + ",flag=1 allocated ok!"); } } catch (final Exception e) { omsLOG.error("update sku:" + sku + " failed and error is " + e); } } else { continue; } } } else if (!nowDateString.equals(modifyDayString) && flag == 1) { omsLOG.error("sku:" + sku + ",modifyTime:" + modifyDayString + ",nowday:" + nowDateString + ".The modifyTime not equal currentdate,current sku skip allocated"); continue; } } if (errorSkus.size() > 0) { final StringBuffer skulist = new StringBuffer(); for (final String errorSku : errorSkus) { skulist.append(errorSku + ","); } omsSkuLog.error("???SKU" + skulist.toString()); } return true; } else { omsLOG.error("get iteminfos failed!"); return false; } }
From source file:com.trenako.criteria.SearchCriteria.java
/** * Creates an empty {@code SearchCriteria}. */ public SearchCriteria() { values = new EnumMap<>(Criteria.class); }
From source file:org.apache.asterix.common.config.ConfigUsageTest.java
@Test public void generateUsageCSV() throws IOException { new File(CSV_FILE).getParentFile().mkdirs(); try (final PrintStream output = new PrintStream(new FileOutputStream(CSV_FILE))) { generateUsage("\"", "\",\"", "\"", new EnumMap<>(Column.class), output); // TODO(mblow): add some validation (in addition to just ensuring no exceptions...) }/*from w w w.j a va 2 s. com*/ }
From source file:org.apache.syncope.core.logic.init.ImplementationClassNamesLoader.java
@Override public void load() { classNames = new EnumMap<>(Type.class); for (Type type : Type.values()) { classNames.put(type, new HashSet<String>()); }/*from w w w .j av a2 s. co m*/ ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider( false); scanner.addIncludeFilter(new AssignableTypeFilter(Reportlet.class)); scanner.addIncludeFilter(new AssignableTypeFilter(TaskJob.class)); scanner.addIncludeFilter(new AssignableTypeFilter(SyncActions.class)); scanner.addIncludeFilter(new AssignableTypeFilter(PushActions.class)); scanner.addIncludeFilter(new AssignableTypeFilter(SyncCorrelationRule.class)); // Remove once SYNCOPE-631 is done //scanner.addIncludeFilter(new AssignableTypeFilter(PushCorrelationRule.class)); scanner.addIncludeFilter(new AssignableTypeFilter(PropagationActions.class)); scanner.addIncludeFilter(new AssignableTypeFilter(Validator.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) { classNames.get(Type.REPORTLET).add(clazz.getName()); } if (TaskJob.class.isAssignableFrom(clazz) && !isAbsractClazz && !SyncJob.class.isAssignableFrom(clazz) && !PushJob.class.isAssignableFrom(clazz)) { classNames.get(Type.TASKJOB).add(bd.getBeanClassName()); } if (SyncActions.class.isAssignableFrom(clazz) && !isAbsractClazz) { classNames.get(Type.SYNC_ACTIONS).add(bd.getBeanClassName()); } if (PushActions.class.isAssignableFrom(clazz) && !isAbsractClazz) { classNames.get(Type.PUSH_ACTIONS).add(bd.getBeanClassName()); } if (SyncCorrelationRule.class.isAssignableFrom(clazz) && !isAbsractClazz) { classNames.get(Type.SYNC_CORRELATION_RULE).add(bd.getBeanClassName()); } // Uncomment when SYNCOPE-631 is done /* if (PushCorrelationRule.class.isAssignableFrom(clazz) && !isAbsractClazz) { * classNames.get(Type.PUSH_CORRELATION_RULES).add(metadata.getClassName()); * } */ if (PropagationActions.class.isAssignableFrom(clazz) && !isAbsractClazz) { classNames.get(Type.PROPAGATION_ACTIONS).add(bd.getBeanClassName()); } if (Validator.class.isAssignableFrom(clazz) && !isAbsractClazz) { classNames.get(Type.VALIDATOR).add(bd.getBeanClassName()); } } catch (Throwable t) { LOG.warn("Could not inspect class {}", bd.getBeanClassName(), t); } } classNames = Collections.unmodifiableMap(classNames); LOG.debug("Implementation classes found: {}", classNames); }