List of usage examples for org.apache.commons.lang ObjectUtils identityToString
public static String identityToString(Object object)
Gets the toString that would be produced by Object
if a class did not override toString itself.
From source file:ObjectUtilsTrial.java
public static void main(String[] args) { // Create ObjectUtilsTrial instance String one = new String(); String two = one; // Same Reference String three = new String(); // New Object String four = null;/*from w ww . ja v a2s . c o m*/ // four is null, returns DEFAULT System.out.print("1) If null return DEFAULT >>>"); System.out.println(ObjectUtils.defaultIfNull(four, "DEFAULT")); // one and two point to the same object System.out.print("2) References to the same object >>>"); System.out.println(ObjectUtils.equals(one, two)); // one and three are different objects System.out.print("3) Check object references and not values >>>"); System.out.println(ObjectUtils.equals(one, three)); // toString method gets called System.out.print("4) toSring gets invoked >>>"); System.out.println(one); // Object details displayed..toString is not called System.out.print("5) Display object details >>>"); System.out.println(ObjectUtils.identityToString(one)); // Pass null get empty string System.out.print("6) Pass null and get back an Empty string >>>"); System.out.println("**" + ObjectUtils.toString(null) + "**"); }
From source file:com.sldeditor.ui.tree.SLDTreeItemWrapper.java
/** * Generate a unique key./*from www .ja v a 2 s .c om*/ * * @param sldItem the sld item * @return the string */ public static String generateKey(Object sldItem) { if (sldItem == null) { return NULL_VALUE; } return ObjectUtils.identityToString(sldItem); }
From source file:com.linkedin.bowser.core.objects.FunctionObject.java
@Override public String str() { return "<function " + _function.getName() + " at " + ObjectUtils.identityToString(_function) + ">"; }
From source file:com.autentia.wuija.persistence.impl.hibernate.HibernateTestUtils.java
/** * Mtodo pensado para usar en los test, de forma que para la ejecucin tengamos una nica sesin. Sera similar a * clases como <code>penSessionInViewFilter</code>. La idea es invocar este mtodo en un <code>@Before</code>. * <p>//from ww w . j a v a 2 s. co m * Este mtodo se debera invocar una nica vez. * <p> * La sesin se "attacha" al contexto, de forma que est disponible para usar desde las transacciones o desde el * <code>HibernteTemplate</code>. Luego se cerrar con el mtodo {@link #closeSessionFromContext()}. */ public void openSessionAndAttachToContext() { Assert.state(sessionAlreadyOpened == null, "A session is already opened: " + ObjectUtils.identityToString(sessionAlreadyOpened)); sessionAlreadyOpened = SessionFactoryUtils.getSession(sessionFactory, true); TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(sessionAlreadyOpened)); if (log.isDebugEnabled()) { log.debug("Opened Session: " + ObjectUtils.identityToString(sessionAlreadyOpened) + ", with SessionFactory: " + ObjectUtils.identityToString(sessionFactory)); } }
From source file:com.google.gdt.eclipse.designer.palette.ImageBundleUseEntryInfo.java
public ImageBundleUseEntryInfo(ImageBundlePrototypeDescription prototype) { m_prototype = prototype;//from www .ja v a2s .c o m setId(ObjectUtils.identityToString(m_prototype)); setName(m_prototype.getMethod().getName()); { String bundleClassName = m_prototype.getBundle().getDescription().getComponentClass().getName(); setDescription("Allows to create and drop new instance of Image widget for method " + CodeUtils.getShortClass(bundleClassName) + "." + m_prototype.getMethod().getName() + "()"); } }
From source file:com.bstek.dorado.data.type.AbstractDataType.java
@Override public String toString() { return ObjectUtils.identityToString(this) + " [" + "name=" + getName() + ", " + "matchType=" + getMatchType() + "]"; }
From source file:com.autentia.wuija.persistence.impl.hibernate.HibernateTestUtils.java
/** * Mtodo pensado para usar en los test, de forma que para la ejecucin tengamos una nica sesin. Sera similar a * clases como <code>penSessionInViewFilter</code>. La idea es invocar este mtodo en un <code>@After</code>. * <p>// ww w .j av a 2 s . c o m * Este mtodo se debera invocar una nica vez. * <p> * Este mtodo se encarga de cerra la sessin que est "attacha" al contexto, y que se abri con el mtodo * {@link #openSessionAndAttachToContext()}. */ public void closeSessionFromContext() { Assert.state(sessionAlreadyOpened != null, "There is not opened session. You have to call openSessionAndAttachToContext() method before this one"); if (log.isTraceEnabled()) { log.trace("Closing session with SessionFactory: " + ObjectUtils.identityToString(sessionFactory)); } final SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager .unbindResource(sessionFactory); final Session session = sessionHolder.getSession(); Assert.state(sessionAlreadyOpened == session, "You are trying to close session: " + ObjectUtils.identityToString(session) + ", but this is not de actual opened session"); sessionAlreadyOpened = null; SessionFactoryUtils.closeSession(session); if (log.isDebugEnabled()) { log.debug("Closed Session: " + ObjectUtils.identityToString(session)); } }
From source file:com.bstek.dorado.data.entity.PropertyPathUtils.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static void setValueByPath(EntityDataType dataType, Object object, String propertyPath, Object value) throws Exception { String[] paths = StringUtils.split(propertyPath, '.'); Object currentEntity = object; EntityDataType currentDataType = dataType; for (int i = 0; i < paths.length - 1; i++) { String path = paths[i];//from www. ja v a2 s. c o m Object tempEntity; boolean isMap = currentEntity instanceof Map; if (EntityUtils.isEntity(currentEntity)) { tempEntity = EntityUtils.getValue(currentEntity, path); } else if (currentEntity instanceof Map) { tempEntity = ((Map) currentEntity).get(path); } else { tempEntity = PropertyUtils.getSimpleProperty(currentEntity, path); } if (tempEntity == null) { Class<?> subEntityType = null; if (currentDataType != null) { PropertyDef propertyDef = currentDataType.getPropertyDef(path); if (propertyDef != null) { DataType propertyDataType = propertyDef.getDataType(); if (propertyDataType instanceof EntityDataType) { currentDataType = (EntityDataType) propertyDataType; subEntityType = currentDataType.getCreationType(); if (subEntityType == null) { subEntityType = currentDataType.getMatchType(); } } } } else if (isMap) { tempEntity = new HashMap(); currentDataType = null; } if (tempEntity == null) { if (subEntityType == null) { subEntityType = PropertyUtils.getPropertyType(currentEntity, path); } if (subEntityType.isAssignableFrom(Map.class)) { tempEntity = new HashMap(); } else if (!subEntityType.isInterface()) { tempEntity = subEntityType.newInstance(); } currentDataType = null; } if (tempEntity != null) { if (isMap) { ((Map) currentEntity).put(path, tempEntity); } else { PropertyUtils.setSimpleProperty(currentEntity, path, tempEntity); } } else { throw new IllegalArgumentException("Can not write value to [" + StringUtils.join(paths, '.') + "] on [" + ObjectUtils.identityToString(object) + "]."); } } currentEntity = tempEntity; } String path = paths[paths.length - 1]; if (EntityUtils.isEntity(currentEntity)) { EntityUtils.setValue(currentEntity, path, value); } else if (currentEntity instanceof Map) { ((Map) currentEntity).put(path, value); } else { PropertyUtils.setSimpleProperty(currentEntity, path, value); } }
From source file:mitm.common.hibernate.SessionManagerImpl.java
private void logDebugInfo(String message, Object object) { if (logger.isDebugEnabled()) { logger.debug(message + ". Object: " + ObjectUtils.identityToString(object)); }/*from ww w . j a v a2 s.c o m*/ }
From source file:com.adaptris.core.Channel.java
/** * <p>/*from w w w.ja va2 s . com*/ * Checks that ConnectionErrorHandlers are not sematically equal. * * However, if we have a shared connection where both are actually the same object, * then we should obviously not throw an exception. * </p> */ private void checkConnectionErrorHandlers() throws CoreException { ConnectionErrorHandler cceh = getConsumeConnection().connectionErrorHandler(); ConnectionErrorHandler pceh = getProduceConnection().connectionErrorHandler(); if (cceh != null && pceh != null) { // are they actually the same object? if (!ObjectUtils.identityToString(cceh).equals(ObjectUtils.identityToString(pceh))) { if (!cceh.allowedInConjunctionWith(pceh)) { throw new CoreException("This channel has been configured with 2 ErrorHandlers that are " + "incompatible with each other"); } } } }