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:dhbw.ka.mwi.businesshorizon2.ui.process.scenario.ScenarioViewImpl.java

/**
 * Die Methode fuegt der View ein Szenario hinzu. Sie baut hierzu saemtliche
 * notwendigen GUI-Elemente und entsprecheenden Listener hinzu.
 * //from w ww.j  av  a  2 s. c  o m
 * @author Julius Hacker
 * @param rateReturnEquity Standardwert fuer die Renditeforderung Eigenkapital
 * @param rateReturnCapitalStock Standardwert fuer die Renditeforderung Fremdkapital
 * @param businessTax Standardwert fuer die Gewerbesteuer
 * @param corporateAndSolitaryTax Standardwert fuer die Koerperschaftssteuer mit Solidaritaetszuschlag.
 */
@Override
public void addScenario(String rateReturnEquity, String rateReturnCapitalStock, String corporateAndSolitaryTax,
        String businessTax, boolean isIncludeInCalculation, final int number) {
    HashMap<String, AbstractComponent> scenarioComponents = new HashMap<String, AbstractComponent>();

    Property.ValueChangeListener changeListener = new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            presenter.updateScenario(number);
            logger.debug("TextChange ausgeloest");
            logger.debug("ChangeListener " + System.identityHashCode(this));
        }
    };

    HorizontalLayout hlScenario = new HorizontalLayout();
    hlScenario.setSizeFull();

    FormLayout formLeft = new FormLayout();
    FormLayout formRight = new FormLayout();
    hlScenario.addComponent(formLeft);
    //hlScenario.addComponent(formRight);

    final Label scenarioName = new Label("<strong>Szenario " + number + "</strong>");
    scenarioName.setContentMode(Label.CONTENT_XHTML);
    scenarioComponents.put("label", scenarioName);
    formLeft.addComponent(scenarioName);
    scenarioName.setWidth(Sizeable.SIZE_UNDEFINED, 0);

    final CheckBox cbBerechnungEinbezug = new CheckBox("In Berechnung einbeziehen");
    cbBerechnungEinbezug.setValue(isIncludeInCalculation);
    cbBerechnungEinbezug.setImmediate(true);
    cbBerechnungEinbezug.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            presenter.updateScenario(number);
            logger.debug("ChangeListener " + System.identityHashCode(this));
        }

    });
    scenarioComponents.put("isIncludeInCalculation", cbBerechnungEinbezug);
    formLeft.addComponent(cbBerechnungEinbezug);

    final TextField tfEigenkapital = new TextField("Renditeforderung Eigenkapital: ");
    if (!"0.0".equals(rateReturnEquity)) {
        tfEigenkapital.setValue(rateReturnEquity);
    }
    tfEigenkapital.setImmediate(true);
    tfEigenkapital.addListener(changeListener);
    scenarioComponents.put("rateReturnEquity", tfEigenkapital);
    formLeft.addComponent(tfEigenkapital);

    final TextField tfFremdkapital = new TextField("Renditeforderung Fremdkapital: ");
    if (!"0.0".equals(rateReturnCapitalStock)) {
        tfFremdkapital.setValue(rateReturnCapitalStock);
    }
    tfFremdkapital.setImmediate(true);
    tfFremdkapital.addListener(changeListener);
    scenarioComponents.put("rateReturnCapitalStock", tfFremdkapital);
    formLeft.addComponent(tfFremdkapital);

    final TextField tfGewerbesteuer = new TextField("Gewerbesteuer: ");
    if (!"0.0".equals(businessTax)) {
        tfGewerbesteuer.setValue(businessTax);
    }
    tfGewerbesteuer.setImmediate(true);
    tfGewerbesteuer.addListener(changeListener);
    scenarioComponents.put("businessTax", tfGewerbesteuer);
    formLeft.addComponent(tfGewerbesteuer);

    final TextField tfKoerperschaftssteuer = new TextField(
            "K\u00F6rperschaftssteuer mit Solidarit\u00E4tszuschlag: ");
    if (!"0.0".equals(corporateAndSolitaryTax)) {
        tfKoerperschaftssteuer.setValue(corporateAndSolitaryTax);
    }
    tfKoerperschaftssteuer.setImmediate(true);
    tfKoerperschaftssteuer.addListener(changeListener);
    scenarioComponents.put("corporateAndSolitaryTax", tfKoerperschaftssteuer);
    formLeft.addComponent(tfKoerperschaftssteuer);

    final Button removeScenario = new Button("Szenario entfernen");
    removeScenario.addListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            presenter.removeScenario(number);
        }

    });
    formLeft.addComponent(removeScenario);

    formLeft.setWidth(Sizeable.SIZE_UNDEFINED, 0);
    formLeft.setWidth(Sizeable.SIZE_UNDEFINED, 0);

    scenarioComponents.put("scenario", hlScenario);

    this.scenarios.add(scenarioComponents);
    this.vlScenarios.addComponent(hlScenario);
}

From source file:com.my.diff.MyDKCSVFileSource.java

public String toString() {
    if (DKRuntime.getInstance().getIsTest())
        return _file.getName();
    return String.format("%s@%x[%s]", ClassUtils.getShortClassName(this.getClass()),
            System.identityHashCode(this), _file.getPath());
}

From source file:edu.wisc.my.portlets.bookmarks.domain.Folder.java

/**
 * @see java.lang.Object#toString()/*w  ww . ja  v a2 s  .c o  m*/
 */
public String toString() {
    final Set<Integer> visited = toStringVisitedFolder.getSet();
    final int identityHash = System.identityHashCode(this);
    try {
        if (!visited.add(identityHash)) {
            visited.clear();
            throw new IllegalStateException("A loop exists in the Folder tree.");
        }

        return new ToStringBuilder(this).appendSuper(super.toString()).append("children", this.children)
                .append("minimized", this.minimized).toString();
    } finally {
        visited.remove(identityHash);
    }
}

From source file:org.asteriskjava.live.internal.AsteriskQueueMemberImpl.java

@Override
public String toString() {
    final StringBuffer sb;

    sb = new StringBuffer("AsteriskQueueMember[");
    sb.append("location='").append(location).append("'");
    sb.append("state='").append(state).append("'");
    sb.append("paused='").append(paused).append("'");
    sb.append("membership='").append(membership).append("'");
    sb.append("queue='").append(queue.getName()).append("'");
    sb.append("callsTaken='").append(getCallsTaken()).append("'");
    sb.append("lastCall='").append(getLastCall()).append("'");
    sb.append("systemHashcode=").append(System.identityHashCode(this));
    sb.append("]");

    return sb.toString();
}

From source file:net.gleamynode.oil.impl.wal.QueueIteratorImpl.java

public QueueReference moveTo(Queue queue) {
    Validate.notNull(queue);/*from   w w w.  j av  a  2s  .  c  om*/

    if (!(queue instanceof QueueImpl)) {
        throw new IllegalArgumentException();
    }

    if (this == queue) {
        throw new IllegalArgumentException();
    }

    QueueReference result;
    QueueImpl q = (QueueImpl) queue;

    if (grandparent != q.getParent()) {
        throw new IllegalArgumentException();
    }

    Sync lockA = parent.getLock().writeLock();
    Sync lockB = q.getLock().writeLock();

    // sort locks to avoid deadlocks.
    if (System.identityHashCode(lockA) > System.identityHashCode(lockB)) {
        Sync tmp = lockA;
        lockA = lockB;
        lockB = tmp;
    }

    grandparent.acquireSharedLock();
    SyncUtil.acquire(lockA);
    SyncUtil.acquire(lockB);
    SyncUtil.acquire(lock.writeLock());

    try {
        QueueExtent extent = getCurrentExtent();
        result = extent.moveTo(offset, q);

        if (result != null) {
            tryToRemoveCurrentExtent();
        }
    } finally {
        lock.writeLock().release();
        lockB.release();
        lockA.release();
        grandparent.releaseSharedLock();
    }

    return result;
}

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

/**
 * Create a distribution from the mask image (packed in YX order)
 * /*from   w w w  .j a v a2 s .  c  o m*/
 * @param mask
 * @param width
 *            The width of the mask in pixels
 * @param height
 *            the height of the mask in pixels
 * @param depth
 *            The mask depth
 * @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 z-depth
 */
public MaskDistribution(int[] mask, int width, int height, double depth, double scaleX, double scaleY,
        RandomGenerator randomGenerator, UniformDistribution uniformDistribution) {
    if (width < 1 || height < 1)
        throw new IllegalArgumentException("Dimensions must be above zero");
    if (scaleX < 0 || scaleY < 0)
        throw new IllegalArgumentException("Scale must be above zero");
    if (mask == null || mask.length < width * height)
        throw new IllegalArgumentException("Mask must not be null and must at least (width * height) in size");
    if (randomGenerator == null)
        randomGenerator = new Well19937c(System.currentTimeMillis() + System.identityHashCode(this));

    this.randomGenerator = randomGenerator;
    setUniformDistribution(uniformDistribution);
    this.mask = mask;
    this.width = width;
    this.scaleX = scaleX;
    this.scaleY = scaleY;
    this.height = height;
    this.half_width = width / 2;
    this.half_height = height / 2;
    this.min = -depth / 2;
    this.depth = depth;

    final int size = width * height;
    int count = 0;
    for (int i = 0; i < size; i++) {
        if (mask[i] != 0)
            count++;
    }

    if (count == 0)
        throw new IllegalArgumentException("Mask must have non-zero pixels");

    indices = new int[count];
    count = 0;
    for (int i = 0; i < size; i++) {
        if (mask[i] != 0)
            indices[count++] = i;
    }

    // Fischer-Yates shuffle the indices to scramble the mask positions
    for (int i = indices.length; i-- > 1;) {
        final int j = randomGenerator.nextInt(i + 1);
        final int tmp = indices[i];
        indices[i] = indices[j];
        indices[j] = tmp;
    }
}

From source file:org.apache.geode.internal.util.ArrayUtils.java

public static void objectRefString(Object obj, StringBuilder sb) {
    if (obj != null) {
        sb.append(obj.getClass().getSimpleName()).append('@')
                .append(Integer.toHexString(System.identityHashCode(obj)));
    } else {//from   www.  j a v a2  s  .co m
        sb.append("(null)");
    }
}

From source file:net.sf.jasperreports.engine.export.FlashPrintElement.java

/**
 * Returns the name of the parameter to be used for a hyperlink, as used
 * by {@link #makeLinkPlaceholder(JRPrintHyperlink)} and
 * {@link #resolveLinks(String, JRGenericPrintElement, JRHyperlinkProducer, boolean)}.
 * /*  w  w w .  ja  va 2  s . c o  m*/
 * @param hyperlink the hyperlink
 * @return the hyperlink parameter name
 * @see #makeLinkPlaceholder(JRPrintHyperlink)
 */
public static String makeLinkParameterName(JRPrintHyperlink hyperlink) {
    return "link-" + System.identityHashCode(hyperlink);
}

From source file:org.envirocar.app.storage.DbAdapterImpl.java

/**
 * init with default valus for maximum time and distance between
 * two measurements. see {@link #init(Context, long, double)}
 * // w  w  w.  j a  va  2s  .co  m
 * @param ctx the used android context
 * @throws InstantiationException if the connection to the database fails
 */
public static DbAdapter instance() {
    logger.info("Returning DbAdapterImpl; Hash: " + System.identityHashCode(instance));
    return instance;
}

From source file:org.apache.mnemonic.DurablePersonNGTest.java

@Test(dependsOnMethods = { "testGenPeople" })
public void testCheckPeople() throws RetrieveDurableEntityError {
    NonVolatileMemAllocator act = new NonVolatileMemAllocator(
            Utils.getNonVolatileMemoryAllocatorService("pmalloc"), 1024 * 1024 * 8, "./pobj_person.dat", false);
    act.setBufferReclaimer(new Reclaim<ByteBuffer>() {
        @Override/*  w w  w.  j av  a 2 s  . com*/
        public boolean reclaim(ByteBuffer mres, Long sz) {
            System.out.println(String.format("Reclaim Memory Buffer: %X  Size: %s",
                    System.identityHashCode(mres), null == sz ? "NULL" : sz.toString()));
            return false;
        }
    });
    act.setChunkReclaimer(new Reclaim<Long>() {
        @Override
        public boolean reclaim(Long mres, Long sz) {
            System.out.println(String.format("Reclaim Memory Chunk: %X  Size: %s",
                    System.identityHashCode(mres), null == sz ? "NULL" : sz.toString()));
            return false;
        }
    });

    Checksum pic_cs = new CRC32();
    pic_cs.reset();
    Checksum fp_cs = new CRC32();
    fp_cs.reset();
    long size;
    byte[] buf;

    long val;
    for (long i = 0; i < cKEYCAPACITY; ++i) {
        System.out.printf("----------Key %d--------------\n", i);
        val = act.getHandler(i);
        if (0L == val) {
            break;
        }
        Person<Integer> person = PersonFactory.restore(act, val, true);
        while (null != person) {
            person.testOutput();
            person.getPicture().get().clear();
            buf = new byte[person.getPicture().get().capacity()];
            person.getPicture().get().get(buf);
            pic_cs.update(buf, 0, buf.length);
            byte b;
            for (int j = 0; j < person.getPreference().getSize(); ++j) {
                b = unsafe.getByte(person.getPreference().get() + j);
                fp_cs.update(b);
            }
            person = person.getMother();
        }
    }

    act.close();
    Assert.assertEquals(pic_cs.getValue(), pic_checksum);
    Assert.assertEquals(fp_cs.getValue(), fp_checksum);
}