List of usage examples for java.util Map hashCode
int hashCode();
From source file:Main.java
public static void main(String[] a) { Map<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); map.clear();/*w w w. j av a2s.c o m*/ System.out.println(map.hashCode()); }
From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v2.KubernetesV2Utils.java
static public String createSecret(KubernetesAccount account, String namespace, String clusterName, String name, List<SecretMountPair> files) { Map<String, String> contentMap = new HashMap<>(); for (SecretMountPair pair : files) { String contents;//from w ww .j a v a 2 s . c o m try { contents = new String( Base64.getEncoder().encode(IOUtils.toByteArray(new FileInputStream(pair.getContents())))); } catch (IOException e) { throw new HalException(Problem.Severity.FATAL, "Failed to read required config file: " + pair.getContents().getAbsolutePath() + ": " + e.getMessage(), e); } contentMap.put(pair.getName(), contents); } name = name + "-" + Math.abs(contentMap.hashCode()); TemplatedResource secret = new JinjaJarResource("/kubernetes/manifests/secret.yml"); Map<String, Object> bindings = new HashMap<>(); bindings.put("files", contentMap); bindings.put("name", name); bindings.put("namespace", namespace); bindings.put("clusterName", clusterName); secret.extendBindings(bindings); apply(account, secret.toString()); return name; }
From source file:com.redhat.rhn.frontend.taglibs.list.helper.ListSessionSetHelper.java
/** * Initializes this instance, determining the name of the set that will be used * and instantiating it.//ww w. ja v a2s . com * * @param prefix basis for the generation of a unique set name */ private void setup(String prefix) { RequestContext context = getContext(); helper = new SessionSetHelper(context.getRequest()); if (StringUtils.isBlank(prefix)) { prefix = getListable().getClass().getName(); } decl = prefix; Map params = getParamMap(); if (!params.isEmpty()) { decl = decl + params.hashCode(); } set = SessionSetHelper.lookupAndBind(context.getRequest(), decl); }
From source file:com.livinglogic.utils.AbstractMapChain.java
public int hashCode() { int hashCode = first.hashCode(); Map<K, V> second = getSecond(); if (second != null) hashCode ^= second.hashCode(); return hashCode; }
From source file:br.edimarmanica.weir2.rule.filter.RulesFilter.java
/** * remove regras com percentual de valores nulos maior que o limiar *///w w w . java2 s . c o m private void nullValuesFilter() { File dirInput = new File(Paths.PATH_INTRASITE + "/" + site.getPath() + "/extracted_values"); if (General.DEBUG) { System.out.println("\t\t\tNull Values Filter [Regras: " + dirInput.listFiles().length + "]"); } for (File rule : dirInput.listFiles()) { Map<String, String> pageValues = Loader.loadPageValues(rule, true); if ((nrPages - pageValues.size()) * 100 / nrPages <= IntrasiteExtraction.PR_NULL_VALUES) { remainingRules.add(rule.getPath()); //Maps com os mesmo valores de chave => valor tem os mesmos hashcodes remainingRulesPageValuesHashCode.add(pageValues.hashCode()); } } }
From source file:com.icesoft.faces.component.selectinputtext.SelectInputTextRenderer.java
public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException { validateParameters(facesContext, uiComponent, null); if (log.isTraceEnabled()) { log.trace("encodeBegin"); }/*from ww w . j a va 2s .c om*/ SelectInputText component = (SelectInputText) uiComponent; DOMContext domContext = DOMContext.attachDOMContext(facesContext, uiComponent); String clientId = uiComponent.getClientId(facesContext); String divId = ClientIdPool.get(clientId + AUTOCOMPLETE_DIV); if (!domContext.isInitialized()) { Element root = domContext.createRootElement(HTML.DIV_ELEM); Element input = domContext.createElement(HTML.INPUT_ELEM); input.setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_TEXT); setRootElementId(facesContext, input, uiComponent); root.appendChild(input); input.setAttribute(HTML.NAME_ATTR, clientId); input.setAttribute(HTML.CLASS_ATTR, component.getInputTextClass()); String mousedownScript = (String) uiComponent.getAttributes().get(HTML.ONMOUSEDOWN_ATTR); input.setAttribute(HTML.ONMOUSEDOWN_ATTR, combinedPassThru(mousedownScript, "this.focus();")); String inputStyle = component.getWidthAsStyle(); if (inputStyle != null && inputStyle.length() > 0) input.setAttribute(HTML.STYLE_ATTR, inputStyle); else input.removeAttribute(HTML.STYLE_ATTR); input.setAttribute("autocomplete", "off"); Element div = domContext.createElement(HTML.DIV_ELEM); String listClass = component.getListClass(); div.setAttribute(HTML.ID_ATTR, divId); if (listClass == null) { div.setAttribute(HTML.STYLE_ATTR, "display:none;border:1px solid black;background-color:white;z-index:500;"); } else { div.setAttribute(HTML.CLASS_ATTR, listClass); } root.appendChild(div); Element index = domContext.createElement(HTML.INPUT_ELEM); index.setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN); String indexId = ClientIdPool.get(clientId + AUTOCOMPLETE_INDEX); index.setAttribute(HTML.NAME_ATTR, indexId); root.appendChild(index); String rootStyle = component.getStyle(); if (rootStyle != null && rootStyle.length() > 0) root.setAttribute(HTML.STYLE_ATTR, rootStyle); else root.removeAttribute(HTML.STYLE_ATTR); root.setAttribute(HTML.CLASS_ATTR, component.getStyleClass()); // Element script = domContext.createElement(HTML.SCRIPT_ELEM); // script.setAttribute(HTML.SCRIPT_LANGUAGE_ATTR, // HTML.SCRIPT_LANGUAGE_JAVASCRIPT); // String scriptCode = "window.onLoad(function(){" + call + "});"; // Node node = domContext.createTextNode(scriptCode); // script.appendChild(node); // root.appendChild(script); if (log.isDebugEnabled()) { log.debug("SelectInputText:encodeBegin():component created with the following id : " + clientId); } PassThruAttributeRenderer.renderHtmlAttributes(facesContext, uiComponent, input, null, passThruAttributes); PassThruAttributeRenderer.renderHtmlAttributes(facesContext, uiComponent, input, null, new String[] { HTML.TABINDEX_ATTR }); PassThruAttributeRenderer.renderBooleanAttributes(facesContext, uiComponent, input, PassThruAttributeRenderer.EMPTY_STRING_ARRAY); Element scriptEle = domContext.createElement(HTML.SCRIPT_ELEM); scriptEle.setAttribute(HTML.ID_ATTR, ClientIdPool.get(clientId + "script")); scriptEle.setAttribute(HTML.SCRIPT_TYPE_ATTR, HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT); boolean partialSubmit = component.getPartialSubmit(); if (!component.isDisabled() && !component.isReadonly()) { Node node = domContext.createTextNodeUnescaped("new Ice.Autocompleter('" + clientId + "','" + divId + "', " + component.getOptions() + " ,'" + component.getRowClass() + "','" + component.getSelectedRowClass() + "'," + partialSubmit + ");"); scriptEle.appendChild(node); } root.appendChild(scriptEle); Map domUpdateMap = new HashMap(); domUpdateMap.put("rows", component.getRows()); Element span = domContext.createElement(HTML.SPAN_ELEM); span.setAttribute("data-hashcode", String.valueOf(domUpdateMap.hashCode())); span.setAttribute("style", "display: none;"); root.appendChild(span); } }
From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java
@Test(dataProvider = "warmedMap") public void hashCode_withSelf(Map<Integer, Integer> map) { assertThat(map.hashCode(), is(equalTo(map.hashCode()))); }
From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java
@Test(dataProvider = "guardedMap") public void hashCode_withEmpty(Map<Integer, Integer> map) { assertThat(map.hashCode(), is(equalTo(ImmutableMap.of().hashCode()))); }
From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java
@Test(dataProvider = "warmedMap") public void hashCode_whenPopulated(Map<Integer, Integer> map) { Map<Integer, Integer> other = newHashMap(); warmUp(other, 0, capacity());// w w w .ja v a 2 s . c o m assertThat(map.hashCode(), is(equalTo(other.hashCode()))); }
From source file:com.googlecode.concurrentlinkedhashmap.ConcurrentMapTest.java
private void checkEqualsAndHashCodeNotEqual(Map<Integer, Integer> first, Map<Integer, Integer> second, String errorMsg) {/*from www . j ava 2 s .c o m*/ Map<Integer, Integer> map = newGuarded(); Map<Integer, Integer> other = newHashMap(); map.putAll(first); other.putAll(second); assertThat(errorMsg, map.equals(other), is(false)); assertThat(errorMsg, other.equals(map), is(false)); assertThat(errorMsg, map.hashCode(), is(not(equalTo(other.hashCode())))); }