List of usage examples for java.lang Class hashCode
@HotSpotIntrinsicCandidate public native int hashCode();
From source file:com.inspiresoftware.lib.dto.geda.impl.DTOSupportImpl.java
private Boolean isAnnotatedClass(final Class clazz) { final Integer classHash = Integer.valueOf(clazz.hashCode()); Boolean isAnn;/*from ww w. j av a 2 s . co m*/ if (isClassAnnotatedCache.containsKey(classHash)) { isAnn = isClassAnnotatedCache.get(classHash); } else { isAnn = Boolean.valueOf(clazz.getAnnotation(Dto.class) != null); isClassAnnotatedCache.put(classHash, isAnn); } return isAnn; }
From source file:org.romaframework.core.classloader.RomaClassLoader.java
/** * Explicit reload a class// ww w. ja v a2s.com * * @param iClassName * @return * @throws ClassNotFoundException */ public Class<?> reloadClass(String iClassName) throws ClassNotFoundException { init(); Class<?> cls; synchronized (this) { if (reloadedClasses == null) { reloadedClasses = new HashMap<String, Class<?>>(); } } synchronized (reloadedClasses) { // LOAD CLASS FOR REAL cls = super.findClass(iClassName); reloadedClasses.put(iClassName, cls); signalToAllListeners(cls); } log.warn("[RomaClassLoader.reloadClass] Reloaded class: " + cls + ", hash: " + cls.hashCode()); return cls; }
From source file:net.ymate.platform.core.lang.BlurObject.java
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((attr == null) ? 0 : attr.hashCode()); Class<?> _attrClass = attr == null ? null : attr.getClass(); result = prime * result + ((_attrClass == null) ? 0 : _attrClass.hashCode()); result = prime * result;//from w w w. jav a 2 s . co m return result; }
From source file:net.ymate.platform.commons.lang.BlurObject.java
public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((attr == null) ? 0 : attr.hashCode()); Class<?> _attrClass = attr.getClass(); result = prime * result + ((_attrClass == null) ? 0 : _attrClass.hashCode()); result = prime * result;/*from w w w. j a va2 s. c o m*/ return result; }
From source file:org.owntracks.android.ui.base.navigator.ActivityNavigator.java
private SecondaryDrawerItem secondaryDrawerItemForClass(AppCompatActivity activeActivity, Class<?> targetActivityClass, @StringRes int targetActivityTitleRessource, @DrawableRes int iconResource) { return new SecondaryDrawerItem().withName(activeActivity.getString(targetActivityTitleRessource)) .withIcon(iconResource).withIconColorRes(COLOR_ICON_SECONDARY) .withSelectedIconColorRes(COLOR_ICON_SECONDARY_ACTIVE).withIconTintingEnabled(true) .withTag(targetActivityClass).withSelectable(false).withTextColorRes(R.color.md_black_1000) .withIdentifier(targetActivityClass.hashCode()); }
From source file:org.owntracks.android.ui.base.navigator.ActivityNavigator.java
private PrimaryDrawerItem drawerItemForClass(AppCompatActivity activeActivity, Class<?> targetActivityClass, @StringRes int targetActivityTitleRessource, @DrawableRes int iconResource) { return new PrimaryDrawerItem().withName(activeActivity.getString(targetActivityTitleRessource)) .withSelectable(false).withSelectedTextColorRes(COLOR_ICON_PRIMARY_ACTIVE).withIcon(iconResource) .withIconColorRes(COLOR_ICON_PRIMARY).withIconTintingEnabled(true) .withSelectedIconColorRes(COLOR_ICON_PRIMARY_ACTIVE).withTag(targetActivityClass) .withTextColorRes(R.color.md_black_1000).withIdentifier(targetActivityClass.hashCode()); }
From source file:org.broadleafcommerce.openadmin.server.dao.DynamicEntityDaoImpl.java
protected String getCacheKey(ForeignKey foreignField, String[] additionalNonPersistentProperties, ForeignKey[] additionalForeignFields, MergedPropertyType mergedPropertyType, Boolean populateManyToOneFields, Class<?> clazz, String configurationKey, Boolean isParentExcluded) { StringBuilder sb = new StringBuilder(150); sb.append(clazz.hashCode()); sb.append(foreignField == null ? "" : foreignField.toString()); sb.append(configurationKey);/* ww w . j a v a2s.c o m*/ sb.append(isParentExcluded); if (additionalNonPersistentProperties != null) { for (String prop : additionalNonPersistentProperties) { sb.append(prop); } } if (additionalForeignFields != null) { for (ForeignKey key : additionalForeignFields) { sb.append(key.toString()); } } sb.append(mergedPropertyType); sb.append(populateManyToOneFields); String digest; try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] messageDigest = md.digest(sb.toString().getBytes()); BigInteger number = new BigInteger(1, messageDigest); digest = number.toString(16); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); } return pad(digest, 32, '0'); }
From source file:org.rhq.core.pc.inventory.ResourceContainer.java
/** * Creates a proxy to this container's resource component, essentially returning the component exposed as the given * facet interface. This proxy will ensure that calls to the component's interface are synchronized with the given * lock type. If <code>lockType</code> is {@link FacetLockType#NONE} and there is no timeout, then the resource's * actual component instance is returned as-is (i.e. it will not be wrapped in a proxy - which means this returns * the same as {@link #getResourceComponent()}). * * @param facetInterface the interface that the component implements and will expose via the proxy * @param lockType the type of lock to use when synchronizing access; must not be null * @param timeout if the method invocation thread has not completed after this many milliseconds, interrupt * it; value must be positive * @param daemonThread whether or not the thread used for the invocation should be a daemon thread * @param onlyIfStarted if <code>true</code>, and the component is not started, an exception is thrown * * @return a proxy that wraps the given component and exposes the given facet interface; will never be null * * @throws PluginContainerException if the component does not exist or does not implement the interface *//*from w w w . j av a2 s. c om*/ public <T> T createResourceComponentProxy(Class<T> facetInterface, FacetLockType lockType, long timeout, boolean daemonThread, boolean onlyIfStarted) throws PluginContainerException { if (onlyIfStarted) { if (!ResourceComponentState.STARTED.equals(getResourceComponentState())) { throw new PluginContainerException("Resource component could not be retrieved for resource [" + getResource() + "] because the component is not started. Its state is [" + getResourceComponentState() + "]"); } } ResourceComponent resourceComponent = this.getResourceComponent(); if (resourceComponent == null) { throw new PluginContainerException("Component does not exist for resource: " + getResource()); } if (!(facetInterface.isAssignableFrom(resourceComponent.getClass()))) { throw new PluginContainerException( "Component does not support the [" + facetInterface.getName() + "] interface: " + this); } // If no locking is required and there is no timeout, there is no need for a proxy - return the actual component. if (lockType == FacetLockType.NONE && timeout == 0) { return (T) resourceComponent; } // Check for a cached proxy. int key; key = facetInterface.hashCode(); key = 31 * key + lockType.hashCode(); key = 31 * key + (int) (timeout ^ (timeout >>> 32)); key = 31 * key + (daemonThread ? 1 : 0); synchronized (this) { if (this.proxyCache == null) { this.proxyCache = new HashMap<Integer, Object>(); } T proxy = (T) this.proxyCache.get(key); if (proxy == null) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); // this is the handler that will actually acquire the lock and invoke the facet method call ResourceComponentInvocationHandler handler = new ResourceComponentInvocationHandler(this, lockType, timeout, daemonThread, facetInterface); // this is the proxy that will look like the facet interface that the caller will use proxy = (T) Proxy.newProxyInstance(classLoader, new Class<?>[] { facetInterface }, handler); this.proxyCache.put(key, proxy); } return proxy; } }