Example usage for java.lang System identityHashCode

List of usage examples for java.lang System identityHashCode

Introduction

In this page you can find the example usage for java.lang System identityHashCode.

Prototype

@HotSpotIntrinsicCandidate
public static native int identityHashCode(Object x);

Source Link

Document

Returns the same hash code for the given object as would be returned by the default method hashCode(), whether or not the given object's class overrides hashCode().

Usage

From source file:com.oasisfeng.nevo.decorators.media.MediaPlayerDecorator.java

@Override
protected void apply(final StatusBarNotificationEvo evolving) throws Exception {
    if (evolving.isClearable())
        return; // Just sticky notification, to reduce the overhead.
    final INotification n = evolving.notification();
    RemoteViews content_view = n.getBigContentView(); // Prefer big content view since it usually contains more actions
    if (content_view == null)
        content_view = n.getContentView();
    if (content_view == null)
        return;/*  w ww .j a va 2s  . c  om*/
    final AtomicReference<IntentSender> sender_holder = new AtomicReference<>();
    final View views = content_view.apply(new ContextWrapper(this) {
        @Override
        public void startIntentSender(final IntentSender intent, final Intent fillInIntent, final int flagsMask,
                final int flagsValues, final int extraFlags) throws IntentSender.SendIntentException {
            startIntentSender(intent, fillInIntent, flagsMask, flagsValues, extraFlags, null);
        }

        @Override
        public void startIntentSender(final IntentSender intent, final Intent fillInIntent, final int flagsMask,
                final int flagsValues, final int extraFlags, final Bundle options)
                throws IntentSender.SendIntentException {
            sender_holder.set(intent);
        }
    }, null);
    if (!(views instanceof ViewGroup))
        return;

    final List<NotificationCompat.Action> actions = new ArrayList<>(8);
    findClickable((ViewGroup) views, new Predicate<View>() {
        @Override
        public boolean apply(final View v) {
            sender_holder.set(null);
            v.performClick(); // trigger startIntentSender() above
            final IntentSender sender = sender_holder.get();
            if (sender == null) {
                Log.w(TAG, v + " has OnClickListener but no PendingIntent in it.");
                return true;
            }

            final PendingIntent pending_intent = getPendingIntent(sender);
            if (v instanceof TextView) {
                final CharSequence text = ((TextView) v).getText();
                actions.add(new NotificationCompat.Action(0, text, pending_intent));
            } else if (v instanceof ImageView) {
                final int res = getImageViewResource((ImageView) v);
                CharSequence title = v.getContentDescription();
                if (title == null)
                    title = "<" + System.identityHashCode(v);
                actions.add(new NotificationCompat.Action(res, title, pending_intent));
            } else {
                CharSequence title = v.getContentDescription();
                if (title == null)
                    title = "<" + System.identityHashCode(v);
                actions.add(new NotificationCompat.Action(0, title, pending_intent));
            }
            return true;
        }
    });

    final Notification mirror;
    final String pkg = evolving.getPackageName();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        final Notification.Builder b = new Notification.Builder(createPackageContext(pkg, 0))
                .setContentTitle(n.extras().getCharSequence(NotificationCompat.EXTRA_TITLE))
                .setLargeIcon(n.getLargeIcon()).setSmallIcon(fixIconPkg(n.getSmallIcon(), pkg));
        for (final NotificationCompat.Action action : actions)
            b.addAction(new Action.Builder(Icon.createWithResource(pkg, action.getIcon()), action.getTitle(),
                    action.getActionIntent()).build());
        mirror = b.build();
    } else {
        final NotificationCompat.Builder b = new NotificationCompat.Builder(createPackageContext(pkg, 0))
                .setContentTitle(n.extras().getCharSequence(NotificationCompat.EXTRA_TITLE))
                .setLargeIcon(n.extras().getParcelable(NotificationCompat.EXTRA_LARGE_ICON).<Bitmap>get())
                .setSmallIcon(android.R.drawable.ic_media_play);
        for (final NotificationCompat.Action action : actions)
            b.addAction(action);
        mirror = b.build();
    }
    final NotificationManagerCompat nm = NotificationManagerCompat.from(this);
    nm.notify("M<" + evolving.getPackageName() + (evolving.getTag() != null ? ">" + evolving.getTag() : ">"),
            evolving.getId(), mirror);
}

From source file:org.apache.ranger.plugin.policyengine.RangerPolicyEngineImpl.java

public RangerPolicyEngineImpl(String appId, ServicePolicies servicePolicies,
        RangerPolicyEngineOptions options) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> RangerPolicyEngineImpl(" + appId + ", " + servicePolicies + ", " + options + ")");
    }//from   w  ww .j  av  a 2 s  .  c  o m

    RangerPerfTracer perf = null;

    if (RangerPerfTracer.isPerfTraceEnabled(PERF_POLICYENGINE_INIT_LOG)) {
        perf = RangerPerfTracer.getPerfTracer(PERF_POLICYENGINE_INIT_LOG, "RangerPolicyEngine.init(appId="
                + appId + ",hashCode=" + Integer.toHexString(System.identityHashCode(this)) + ")");
        long freeMemory = Runtime.getRuntime().freeMemory();
        long totalMemory = Runtime.getRuntime().totalMemory();
        PERF_POLICYENGINE_INIT_LOG
                .debug("In-Use memory: " + (totalMemory - freeMemory) + ", Free memory:" + freeMemory);
    }

    if (options == null) {
        options = new RangerPolicyEngineOptions();
    }

    if (StringUtils.isBlank(options.evaluatorType)
            || StringUtils.equalsIgnoreCase(options.evaluatorType, RangerPolicyEvaluator.EVALUATOR_TYPE_AUTO)) {

        String serviceType = servicePolicies.getServiceDef().getName();
        String propertyName = "ranger.plugin." + serviceType
                + ".policyengine.evaluator.auto.maximum.policycount.for.cache.type";

        int thresholdForUsingOptimizedEvaluator = RangerConfiguration.getInstance().getInt(propertyName,
                MAX_POLICIES_FOR_CACHE_TYPE_EVALUATOR);

        int servicePoliciesCount = servicePolicies.getPolicies().size()
                + (servicePolicies.getTagPolicies() != null
                        ? servicePolicies.getTagPolicies().getPolicies().size()
                        : 0);

        if (servicePoliciesCount > thresholdForUsingOptimizedEvaluator) {
            options.evaluatorType = RangerPolicyEvaluator.EVALUATOR_TYPE_OPTIMIZED;
        } else {
            options.evaluatorType = RangerPolicyEvaluator.EVALUATOR_TYPE_CACHED;
        }
    } else if (StringUtils.equalsIgnoreCase(options.evaluatorType,
            RangerPolicyEvaluator.EVALUATOR_TYPE_CACHED)) {
        options.evaluatorType = RangerPolicyEvaluator.EVALUATOR_TYPE_CACHED;
    } else {
        // All other cases
        options.evaluatorType = RangerPolicyEvaluator.EVALUATOR_TYPE_OPTIMIZED;
    }

    policyRepository = new RangerPolicyRepository(appId, servicePolicies, options);

    ServicePolicies.TagPolicies tagPolicies = servicePolicies.getTagPolicies();

    if (!options.disableTagPolicyEvaluation && tagPolicies != null
            && !StringUtils.isEmpty(tagPolicies.getServiceName()) && tagPolicies.getServiceDef() != null
            && !CollectionUtils.isEmpty(tagPolicies.getPolicies())) {

        if (LOG.isDebugEnabled()) {
            LOG.debug("RangerPolicyEngineImpl : Building tag-policy-repository for tag-service "
                    + tagPolicies.getServiceName());
        }

        tagPolicyRepository = new RangerPolicyRepository(appId, tagPolicies, options,
                servicePolicies.getServiceDef(), servicePolicies.getServiceName());

    } else {
        if (LOG.isDebugEnabled()) {
            LOG.debug("RangerPolicyEngineImpl : No tag-policy-repository for service "
                    + servicePolicies.getServiceName());
        }
        tagPolicyRepository = null;
    }

    List<RangerContextEnricher> tmpList;

    List<RangerContextEnricher> tagContextEnrichers = tagPolicyRepository == null ? null
            : tagPolicyRepository.getContextEnrichers();
    List<RangerContextEnricher> resourceContextEnrichers = policyRepository.getContextEnrichers();

    if (CollectionUtils.isEmpty(tagContextEnrichers)) {
        tmpList = resourceContextEnrichers;
    } else if (CollectionUtils.isEmpty(resourceContextEnrichers)) {
        tmpList = tagContextEnrichers;
    } else {
        tmpList = new ArrayList<RangerContextEnricher>(tagContextEnrichers);
        tmpList.addAll(resourceContextEnrichers);
    }

    this.allContextEnrichers = tmpList;

    policyEvaluatorsMap = createPolicyEvaluatorsMap();

    RangerPerfTracer.log(perf);

    if (PERF_POLICYENGINE_INIT_LOG.isDebugEnabled()) {
        long freeMemory = Runtime.getRuntime().freeMemory();
        long totalMemory = Runtime.getRuntime().totalMemory();
        PERF_POLICYENGINE_INIT_LOG
                .debug("In-Use memory: " + (totalMemory - freeMemory) + ", Free memory:" + freeMemory);
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("<== RangerPolicyEngineImpl()");
    }
}

From source file:org.v2020.data.entity.Node.java

@Override
public int hashCode() {
    return id == null ? System.identityHashCode(this) : id.hashCode();
}

From source file:de.kaiserpfalzEdv.commons.dto.NameBuilder.java

public Comparator<Nameable> getCanonicalNameComparator() {
    return new Comparator<Nameable>() {
        @Override/*  ww  w.jav  a 2  s  .  co m*/
        public int compare(Nameable o1, Nameable o2) {
            return new CompareToBuilder().append(o1.getCanonicalName(), o2.getCanonicalName()).build();
        }

        @Override
        public String toString() {
            return "CanonicalNameComparator@" + System.identityHashCode(this);
        }
    };
}

From source file:org.dataconservancy.access.connector.HttpDcsConnector.java

public HttpDcsConnector(DcsConnectorConfig config, DcsModelBuilder mb) {
    if (config == null) {
        throw new IllegalArgumentException("DcsConnectorConfig must not be null.");
    }/*from  ww  w.java 2  s  .  c o  m*/

    if (mb == null) {
        throw new IllegalArgumentException("DcsModelBuilder must not be null.");
    }

    this.config = config;
    this.mb = mb;

    final ClientConnectionManager cm;
    final BasicHttpParams httpParams = new BasicHttpParams();

    if (config.getMaxOpenConn() > 1) {
        final SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
        ConnManagerParams.setMaxTotalConnections(httpParams, config.getMaxOpenConn());
        ConnPerRouteBean connPerRoute = new ConnPerRouteBean(config.getMaxOpenConn());
        ConnManagerParams.setMaxConnectionsPerRoute(httpParams, connPerRoute);
        if (config.getConnPoolTimeout() > 0) {
            ConnManagerParams.setTimeout(httpParams, config.getConnPoolTimeout() * 1000);
        }
        cm = new ThreadSafeClientConnManager(httpParams, schemeRegistry);
        new ConnectionMonitorThread(cm).start();
    } else {
        cm = null;
    }

    if (config.getConnTimeout() > 0) {
        httpParams.setParameter("http.connection.timeout", config.getConnTimeout() * 1000);
        httpParams.setParameter("http.socket.timeout", config.getConnTimeout() * 1000);
    }

    this.client = new DefaultHttpClient(cm, httpParams);
    log.debug("Instantiated {} ({}) with configuration {}",
            new Object[] { this.getClass().getName(), System.identityHashCode(this), config });
}

From source file:org.envirocar.app.application.service.BackgroundServiceImpl.java

@Override
public void onRebind(Intent intent) {
    super.onRebind(intent);
    logger.info("onRebind " + getClass().getName() + "; Hash: " + System.identityHashCode(this));
}

From source file:gdsc.smlm.model.MaskDistribution3D.java

/**
 * Create a distribution from the stack of mask images (packed in YX order)
 * // w w w.j  av  a 2s. c om
 * @param masks
 * @param width
 *            The width of the mask in pixels
 * @param height
 *            the height of the mask in pixels
 * @param sliceDepth
 *            The depth of each slice
 * @param scaleX
 *            Used to scale the mask X-coordinate to a new value
 * @param scaleY
 *            Used to scale the mask Y-coordinate to a new value
 * @param randomGenerator
 *            Used to pick random pixels in the mask
 * @param uniformDistribution
 *            Used for sub-pixel location and slice z-depth
 */
public MaskDistribution3D(List<int[]> masks, int width, int height, double sliceDepth, double scaleX,
        double scaleY, RandomGenerator randomGenerator, UniformDistribution uniformDistribution) {
    if (width < 1 || height < 1)
        throw new IllegalArgumentException("Dimensions must be above zero");
    if (sliceDepth <= 0)
        throw new IllegalArgumentException("Slice depth must be above zero");
    if (masks == null || masks.isEmpty())
        throw new IllegalArgumentException("Mask must not be null or empty");
    if (randomGenerator == null)
        randomGenerator = new Well19937c(System.currentTimeMillis() + System.identityHashCode(this));

    this.randomGenerator = randomGenerator;
    if (uniformDistribution == null)
        uniformDistribution = new UniformDistribution(null, new double[] { 1, 1, 1 },
                randomGenerator.nextInt());

    // Create a mask for each distribution
    this.sliceDepth = sliceDepth;
    depth = sliceDepth * masks.size();
    minDepth = depth * -0.5;
    slices = new MaskDistribution[masks.size()];
    cumulativeSize = new int[masks.size()];
    int i = 0;
    final int length = masks.get(0).length;
    for (int[] mask : masks) {
        if (length != mask.length)
            throw new IllegalArgumentException("Masks must be the same size");
        slices[i] = new MaskDistribution(mask, width, height, sliceDepth, scaleX, scaleY, randomGenerator,
                uniformDistribution);
        size += slices[i].getSize();
        cumulativeSize[i] = size;
        i++;
    }
}

From source file:info.magnolia.module.servletsanity.support.ServletAssert.java

private static void appendResponseChain(HttpServletResponse response) throws IOException {
    append("Response Chain:");
    ServletResponse rs = response;//from w w  w . java  2s  .  c  om
    do {
        append("&nbsp;&nbsp;&nbsp;&nbsp;" + rs.getClass().getName() + " @ " + System.identityHashCode(rs)
                + " - " + rs.toString());
        rs = rs instanceof HttpServletResponseWrapper ? ((HttpServletResponseWrapper) rs).getResponse() : null;
    } while (rs != null);
    append("");
}

From source file:com.redhat.persistence.oql.Generator.java

void hash(ObjectType type) {
    appendHash("t");
    appendHash(Integer.toString(System.identityHashCode(type.getRoot())));
    terminal();
    appendHash(type.getQualifiedName());
    terminal();
}

From source file:org.apache.geode.internal.process.ControlFileWatchdog.java

@Override
public String toString() {
    StringBuilder sb = new StringBuilder(getClass().getSimpleName());
    sb.append('@').append(System.identityHashCode(this)).append('{');
    sb.append("directory=").append(directory);
    sb.append(", file=").append(file);
    sb.append(", alive=").append(alive); // not synchronized
    sb.append(", stopAfterRequest=").append(stopAfterRequest);
    return sb.append('}').toString();
}