List of usage examples for java.util Collections unmodifiableMap
public static <K, V> Map<K, V> unmodifiableMap(Map<? extends K, ? extends V> m)
From source file:org.openmrs.module.metadatasharing.handler.impl.OpenmrsMetadataHandler.java
/** * @param scanner// ww w . j a va 2s. co m * @throws IOException * @should support classes with same simple name */ @Autowired public OpenmrsMetadataHandler(OpenmrsClassScanner scanner) throws IOException { Map<String, Class<? extends OpenmrsMetadata>> typesToClasses = new HashMap<String, Class<? extends OpenmrsMetadata>>(); Map<Class<? extends OpenmrsMetadata>, String> classesToTypes = new HashMap<Class<? extends OpenmrsMetadata>, String>(); Set<Class<? extends OpenmrsMetadata>> ignoredTypes = new HashSet<Class<? extends OpenmrsMetadata>>(); ignoredTypes.add(User.class); ignoredTypes.add(FormField.class); for (Class<OpenmrsMetadata> clazz : scanner.getOpenmrsMetadataClasses()) { if (ignoredTypes.contains(clazz)) { continue; } Class<? extends OpenmrsMetadata> otherClazz = typesToClasses.get(clazz.getSimpleName()); if (otherClazz != null) { log.info(clazz.getName() + " and " + otherClazz.getName() + " have the same simple name. Trying to resolve the confict..."); String otherName = extractSimpleNameForModule(otherClazz); //try with a module name if (otherName != null) { Class<? extends OpenmrsMetadata> unresolvable = typesToClasses.get(otherName); if (unresolvable != null) { otherName = otherClazz.getName(); //fall back to full name } log.info(otherClazz.getName() + " added as " + otherName); typesToClasses.put(otherName, otherClazz); classesToTypes.put(otherClazz, otherName); typesToClasses.put(clazz.getSimpleName(), clazz); classesToTypes.put(clazz, clazz.getSimpleName()); } else { String name = extractSimpleNameForModule(clazz); //try with a module name Class<? extends OpenmrsMetadata> unresolvable = typesToClasses.get(name); if (unresolvable != null) { name = clazz.getName(); //fall back to full name } log.info(clazz.getName() + " added as " + name); typesToClasses.put(name, clazz); classesToTypes.put(clazz, name); typesToClasses.put(otherClazz.getSimpleName(), otherClazz); classesToTypes.put(otherClazz, otherClazz.getSimpleName()); } } else { typesToClasses.put(clazz.getSimpleName(), clazz); classesToTypes.put(clazz, clazz.getSimpleName()); } } types = Collections.unmodifiableMap(classesToTypes); }
From source file:org.apache.nifi.processors.example.utils.RenameJSONFields.java
@OnScheduled public void onScheduled(final ProcessContext context) { Map<String, String> mFieldMappings = new HashMap<>(); String fieldMappingsProp = context.getProperty(FIELD_MAPPINGS).getValue(); String[] fieldMappingsSplit = fieldMappingsProp.split("[,]"); for (String fieldMapping : fieldMappingsSplit) { int equalsIndex = fieldMapping.indexOf('='); String fieldName = fieldMapping.substring(0, equalsIndex); String mappedName = fieldMapping.substring(equalsIndex + 1); mFieldMappings.put(fieldName, mappedName); }/*from w w w . j a v a 2 s. c om*/ this.fieldMappings = Collections.unmodifiableMap(mFieldMappings); Set<String> mExcludeFields = new HashSet<>(); String excludeFields = context.getProperty(EXCLUDE_FIELDS).getValue(); if (excludeFields != null && !excludeFields.isEmpty()) { String[] excludeFieldsSplit = excludeFields.split("[,]"); for (String excludeField : excludeFieldsSplit) { mExcludeFields.add(excludeField); } } this.excludeFields = Collections.unmodifiableSet(mExcludeFields); }
From source file:org.jasig.cas.authentication.ImmutableAuthentication.java
@Override public Map<String, HandlerResult> getSuccesses() { return Collections.unmodifiableMap(this.successes); }
From source file:lodsve.core.condition.ConditionEvaluationReport.java
/** * Returns condition outcomes from this report, grouped by the source. * * @return the condition outcomes//from w w w. ja v a 2 s .c om */ public Map<String, ConditionAndOutcomes> getConditionAndOutcomesBySource() { if (!this.addedAncestorOutcomes) { for (Entry<String, ConditionAndOutcomes> entry : this.outcomes.entrySet()) { if (!entry.getValue().isFullMatch()) { addNoMatchOutcomeToAncestors(entry.getKey()); } } this.addedAncestorOutcomes = true; } return Collections.unmodifiableMap(this.outcomes); }
From source file:com.callidusrobotics.droptables.model.ResultEntry.java
@JsonProperty("parameters") public Map<String, String> getParameters() { return Collections.unmodifiableMap(parameters); }
From source file:org.apache.hadoop.hbase.rest.client.Client.java
/** * Get all extra headers (read-only). */ public Map<String, String> getExtraHeaders() { return Collections.unmodifiableMap(extraHeaders); }
From source file:hirondelle.situris.main.centrosInteresse.FileUploadWrapper.java
/** Return a {@code Map<String, String[]>} for all regular parameters. Does not return any file upload paramters at all. Does not include query params passed to <tt>request.getRequestDispatcher(String)</tt>. *//* w w w . j ava 2 s . c om*/ @Override public Map getParameterMap() { Map<String, String[]> result = new LinkedHashMap<String, String[]>(); for (String key : fRegularParams.keySet()) { result.put(key, fRegularParams.get(key).toArray(new String[0])); } return Collections.unmodifiableMap(result); }
From source file:org.ihtsdo.otf.snomed.service.ConceptLookUpServiceImpl.java
@Override @Cacheable(value = { "concepts" }) public Map<String, Concept> getConcepts(Set<String> conceptIds) throws ConceptServiceException { LOGGER.debug("getting concepts details for {}", conceptIds); Map<String, Concept> concepts = new HashMap<String, Concept>(); TitanGraph g = null;// w ww . j av a2 s. c om try { g = factory.getReadOnlyGraph(); /**/ List<String> idLst = new ArrayList<String>(); idLst.addAll(conceptIds); int length = idLst.size() / 1024; int to = idLst.size() > 1024 ? 1024 : conceptIds.size(); int from = 0; for (int i = 0; i < length + 1; i++) { LOGGER.debug("getting concept description from {} to {} ", from, to); List<String> subList = idLst.subList(from, to); String ids = org.apache.commons.lang.StringUtils.join(subList, " OR "); Iterable<Result<Vertex>> vs = g.indexQuery("concept", "v.sctid:" + ids).vertices(); for (Result<Vertex> r : vs) { Vertex v = r.getElement(); Object sctid = v.getProperty(Properties.sctid.toString()); Object label = v.getProperty(Properties.title.toString()); if (sctid != null && label != null && idLst.contains(sctid.toString())) { Concept c = convertToConcept(v); concepts.put(sctid.toString(), c); } } //to run next loop if required from = to > idLst.size() ? idLst.size() : to; to = (to + 1024) > idLst.size() ? idLst.size() : to + 1024; } RefsetGraphFactory.commit(g); } catch (Exception e) { LOGGER.error("Error duing concept details for concept map fetch", e); RefsetGraphFactory.rollback(g); throw new ConceptServiceException(e); } finally { RefsetGraphFactory.shutdown(g); } LOGGER.debug("returning total {} concepts ", concepts.size()); return Collections.unmodifiableMap(concepts); }
From source file:org.jasig.cas.web.report.SingleSignOnSessionsReportController.java
/** * Gets sso sessions./* w ww . j a v a 2s .co m*/ * * @return the sso sessions */ private Collection<Map<String, Object>> getSsoSessions() { final List<Map<String, Object>> activeSessions = new ArrayList<Map<String, Object>>(); for (final Ticket ticket : getNonExpiredTicketGrantingTickets()) { final TicketGrantingTicket tgt = (TicketGrantingTicket) ticket; final Map<String, Object> sso = new HashMap<>(SsoSessionAttributeKeys.values().length); sso.put(SsoSessionAttributeKeys.AUTHENTICATED_PRINCIPAL.toString(), tgt.getAuthentication().getPrincipal().getId()); sso.put(SsoSessionAttributeKeys.AUTHENTICATION_DATE.toString(), tgt.getAuthentication().getAuthenticationDate()); sso.put(SsoSessionAttributeKeys.NUMBER_OF_USES.toString(), tgt.getCountOfUses()); if (this.includeTicketGrantingTicketId) { sso.put(SsoSessionAttributeKeys.TICKET_GRANTING_TICKET.toString(), tgt.getId()); } activeSessions.add(Collections.unmodifiableMap(sso)); } return Collections.unmodifiableCollection(activeSessions); }
From source file:com.parse.ParseConfig.java
ParseConfig(Map<String, Object> params) {
this.params = Collections.unmodifiableMap(params);
}