List of usage examples for java.util Map clear
void clear();
From source file:com.bstek.dorado.data.variant.MetaData.java
@Override public void clear() { if (entityEnhancer != null) { EntityDataType dataType = entityEnhancer.getDataType(); if (dataType != null && !dataType.getPropertyDefs().isEmpty()) { throw new UnsupportedOperationException(); }// ww w . j av a2 s. c o m Map<String, Object> exProperties = entityEnhancer.getExProperties(); if (exProperties != null) { exProperties.clear(); } } else { super.clear(); } }
From source file:com.helpinput.spring.refresher.mvc.MvcContextRefresher.java
@Override public void refresh(ApplicationContext context, Map<Class<?>, ScanedType> scanedClasses) { boolean needUpdateHandlerMapping = false; boolean needUpdateInterceptor = false; for (Entry<Class<?>, ScanedType> entry : scanedClasses.entrySet()) { if ((entry.getValue().getValue() > ScanedType.SAME.getValue()) && entry.getKey().getAnnotation(Controller.class) != null) { needUpdateHandlerMapping = true; break; }/*from ww w . j a v a 2 s .c om*/ } for (Entry<Class<?>, ScanedType> entry : scanedClasses.entrySet()) { if ((entry.getValue().getValue() > ScanedType.SAME.getValue()) && HandlerInterceptor.class.isAssignableFrom(entry.getKey())) { needUpdateInterceptor = true; break; } } if (needUpdateInterceptor) { DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory) ((AbstractApplicationContext) context) .getBeanFactory(); Map<String, AbstractHandlerMapping> mappings = dlbf.getBeansOfType(AbstractHandlerMapping.class); if (Utils.hasLength(mappings)) { Field interceptorsField = Utils.findField(AbstractHandlerMapping.class, "interceptors"); Field mappedInterceptorsFeild = Utils.findField(AbstractHandlerMapping.class, "mappedInterceptors"); Method initApplicationContext = Utils.findMethod(AbstractHandlerMapping.class, "initApplicationContext"); if (interceptorsField != null && mappedInterceptorsFeild != null && initApplicationContext != null) { for (AbstractHandlerMapping mapping : mappings.values()) { synchronized (mapping) { final List<Object> interceptors = Utils.getFieldValue(mapping, interceptorsField); if (Utils.hasLength(interceptors)) interceptors.clear(); final List<MappedInterceptor> mappedInterceptors = Utils.getFieldValue(mapping, mappedInterceptorsFeild); if (Utils.hasLength(mappedInterceptors)) mappedInterceptors.clear(); Utils.InvokedMethod(mapping, initApplicationContext); } } } } } if (needUpdateHandlerMapping) { final String mapName = "org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0"; Object mappingHandler = context.getBean(mapName); if (mappingHandler != null) { Method method = Utils.findMethod(mappingHandler, "initHandlerMethods"); Map<?, ?> handlerMethods = Utils.getFieldValue(mappingHandler, "handlerMethods"); Map<?, ?> urlMap = Utils.getFieldValue(mappingHandler, "urlMap"); if (method != null && handlerMethods != null && urlMap != null) { synchronized (mappingHandler) { handlerMethods.clear(); urlMap.clear(); Utils.InvokedMethod(mappingHandler, method); } } } } }
From source file:jcurl.sim.core.SlideStrategy.java
public void init(final Map props) { props.clear(); props.putAll(props);/*from ww w . j a v a2s .co m*/ DimVal time = (DimVal) getProp(D2T_TIME); if (time == null) time = new DimVal(25, Dim.SEC_HOG_TEE); if (!Dim.SEC_HOG_TEE.equals(time.dim)) throw new IllegalArgumentException("Draw to tee time must be seconds hog/tee"); DimVal curl = (DimVal) getProp(D2T_CURL); if (curl == null) curl = new DimVal(1, Dim.METER); if (!curl.dim.isLength()) throw new IllegalArgumentException("Draw to tee curl must be a length (meter/feet/...)"); setDraw2Tee(time.val, curl.val); }
From source file:com.swcguild.addressbookmvc.dao.AddressBookDaoTest.java
@Test public void searchContacts() { Contact nc = new Contact(); nc.setFirstName("Marc"); nc.setLastName("Lorenzo"); nc.setStreet("Woodlawn"); nc.setCity("Detroit"); nc.setState("MI"); nc.setZip("48013"); dao.addContact(nc);//from w ww. j av a 2 s. co m Contact nc2 = new Contact(); nc2.setFirstName("Valentino"); nc2.setLastName("Rossi"); nc2.setStreet("Main"); nc2.setCity("Akron"); nc2.setState("OH"); nc2.setZip("44311"); dao.addContact(nc2); Contact nc3 = new Contact(); nc3.setFirstName("Jorge"); nc3.setLastName("Lorenzo"); nc3.setStreet("Griffith"); nc3.setCity("Davidson"); nc3.setState("NC"); nc3.setZip("28036"); dao.addContact(nc3); Map<SearchTerm, String> criteria = new HashMap<>(); criteria.put(SearchTerm.FIRST_NAME, "Valentino"); List<Contact> cList = dao.searchContacts(criteria); assertEquals(1, cList.size()); assertEquals(nc2, cList.get(0)); criteria.clear(); criteria.put(SearchTerm.LAST_NAME, "Lorenzo"); cList = dao.searchContacts(criteria); assertEquals(2, cList.size()); criteria.clear(); criteria.put(SearchTerm.STREET, "Woodlawn"); cList = dao.searchContacts(criteria); assertEquals(1, cList.size()); assertEquals(nc, cList.get(0)); criteria.clear(); criteria.put(SearchTerm.CITY, "Davidson"); cList = dao.searchContacts(criteria); assertEquals(1, cList.size()); assertEquals(nc3, cList.get(0)); criteria.clear(); criteria.put(SearchTerm.STATE, "GA"); cList = dao.searchContacts(criteria); assertEquals(0, cList.size()); criteria.clear(); criteria.put(SearchTerm.ZIP, "28036"); cList = dao.searchContacts(criteria); assertEquals(1, cList.size()); assertEquals(nc3, cList.get(0)); }
From source file:com.titankingdoms.dev.titanchat.core.channel.ChannelManager.java
/** * Unloads the manager//from ww w . j a v a 2 s .c om */ public void unload() { for (Channel channel : getChannels()) unregisterChannel(channel); for (ChannelLoader loader : getLoaders()) unregisterLoader(loader); for (Map<String, Channel> status : this.statuses.values()) status.clear(); }
From source file:org.wallerlab.yoink.regionizer.partitioner.GridPointAssigner.java
/** * for a grid point, get its two neighbours from Voronoi partitioning, if it * satisfies the criteria(two neighbours are different, not both in QM core * region or in non-QM core adaptive search region.), it will be used for * following calculation of density interaction analysis(like DORI and * SEDD).//w w w .j a v a 2 s . c om * * @param tempCoord * -{@link org.wallerlab.yoink.api.model.molecular.Coord}, the * coordinate of the grid point * @param regions * - a Map, Region.Name * {@link org.wallerlab.yoink.api.model.regionizer.Region.Name } * as key, Region * {@link org.wallerlab.yoink.api.model.regionizer.Region} as * value * @param cubeRegionName * {@link org.wallerlab.yoink.api.model.regionizer.Region.Name} * @return properties - a Map, String {@link java.lang.String} as Key, * Object {@link java.lang.Object} as value */ public Map assign(Coord tempCoord, Map<Region.Name, Region> regions, Region.Name cubeRegionName) { Region qmCoreRegion = regions.get(Region.Name.QM_CORE); Region nonQmCoreRegion = regions.get(Region.Name.NONQM_CORE_ADAPTIVE_SEARCH); Map<String, Object> properties = voronoiCalculator.calculate(tempCoord, regions.get(cubeRegionName).getMolecules()); Set<Molecule> moleculeSet = (Set<Molecule>) properties.get("twoClosestMolecules"); boolean notNeighbourPair = (boolean) (moleculeSet.size() != 2); switch (cubeRegionName) { case SYSTEM: if (notNeighbourPair) { properties.clear(); } break; default: boolean bothNeighboursAreInNonQmCore = nonQmCoreRegion.containsAll(moleculeSet); boolean bothNeighboursAreInQmCore = qmCoreRegion.containsAll(moleculeSet); if (notNeighbourPair || bothNeighboursAreInNonQmCore || bothNeighboursAreInQmCore) { properties.clear(); } } return properties; }
From source file:com.microsoft.projectoxford.vision.VisionServiceRestClient.java
@Override public AnalysisResult describe(String url, int maxCandidates) throws VisionServiceException { Map<String, Object> params = new HashMap<>(); params.put("maxCandidates", maxCandidates); String path = apiRoot + "/describe"; String uri = WebServiceRequest.getUrl(path, params); params.clear(); params.put("url", url); String json = (String) this.restCall.request(uri, "POST", params, null, false); AnalysisResult visualFeature = this.gson.fromJson(json, AnalysisResult.class); return visualFeature; }
From source file:com.microsoft.projectoxford.vision.VisionServiceRestClient.java
@Override public AnalysisResult describe(InputStream stream, int maxCandidates) throws VisionServiceException, IOException { Map<String, Object> params = new HashMap<>(); params.put("maxCandidates", maxCandidates); String path = apiRoot + "/describe"; String uri = WebServiceRequest.getUrl(path, params); params.clear(); byte[] data = IOUtils.toByteArray(stream); params.put("data", data); String json = (String) this.restCall.request(uri, "POST", params, "application/octet-stream", false); AnalysisResult visualFeature = this.gson.fromJson(json, AnalysisResult.class); return visualFeature; }
From source file:fr.mcc.ginco.services.ConceptHierarchicalRelationshipServiceUtil.java
@Override public List<ThesaurusConcept> getRootConcepts(ThesaurusConcept concept) { ThesaurusConcept start;//from w ww . j a v a 2 s . c om Map<String, Integer> path = new HashMap<String, Integer>(); Set<ThesaurusConcept> roots = new HashSet<ThesaurusConcept>(); path.clear(); roots.clear(); path.put(concept.getIdentifier(), 0); start = concept; getRoot(concept, 0, start, path, roots); return new ArrayList<ThesaurusConcept>(roots); }
From source file:fuzzy.util.MaxMF.java
public Map<Double, Double> evaluate(Collection<T> x, MembershipFunction<T> mf) { Map<Double, Double> max = new HashMap<Double, Double>(); BigDecimal maxValue = BigDecimal.valueOf(0.0); boolean first = true; for (T value : x) { BigDecimal temp = new BigDecimal(mf.evaluate(value), new MathContext(precision, roundingMode)); if (first || temp.compareTo(maxValue) > 0) { first = false;/*from w w w . j a v a2s .c om*/ maxValue = temp; max.clear(); max.put(value.doubleValue(), temp.doubleValue()); } else if (temp.compareTo(maxValue) == 0) { max.put(value.doubleValue(), temp.doubleValue()); } // else ignore since it's less than the maximum value } return max; }