本文整理汇总了Java中com.helger.commons.equals.EqualsHelper.identityEqual方法的典型用法代码示例。如果您正苦于以下问题:Java EqualsHelper.identityEqual方法的具体用法?Java EqualsHelper.identityEqual怎么用?Java EqualsHelper.identityEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.helger.commons.equals.EqualsHelper
的用法示例。
在下文中一共展示了EqualsHelper.identityEqual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: forEach
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
public void forEach (@Nonnull final IConsumer <T> aConsumer)
{
if (m_bHasFreeKey)
aConsumer.accept (FREE_KEY, m_aFreeValue);
final int nLen = m_aKeys.length;
for (int i = 0; i < nLen; ++i)
{
final int nKey = m_aKeys[i];
if (nKey != FREE_KEY)
{
final T aValue = m_aValues[i];
if (!EqualsHelper.identityEqual (aValue, m_aNoValue))
aConsumer.accept (nKey, aValue);
}
}
}
示例2: birthdayCompare
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
/**
* Compare two dates by birthday. This means, the dates are only compared by
* day and month, and <b>not</b> by year!
*
* @param aDate1
* First date. May be <code>null</code>.
* @param aDate2
* Second date. May be <code>null</code>.
* @return same as {@link Comparator#compare(Object, Object)}
*/
public static int birthdayCompare (@Nullable final LocalDate aDate1, @Nullable final LocalDate aDate2)
{
if (EqualsHelper.identityEqual (aDate1, aDate2))
return 0;
if (aDate1 == null)
return -1;
if (aDate2 == null)
return 1;
// first compare month
int ret = aDate1.getMonth ().compareTo (aDate2.getMonth ());
if (ret == 0)
{
// on equal month, compare day of month
ret = aDate1.getDayOfMonth () - aDate2.getDayOfMonth ();
}
return ret;
}
示例3: _traverseDFS
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
private void _traverseDFS (@Nonnull final IMutableGraphNode aStartNode,
@Nonnull final ICommonsList <IMutableGraphNode> aList)
{
m_aHandledObjects.add (aStartNode.getID ());
aList.add (aStartNode);
for (final IMutableGraphRelation aRelation : aStartNode.getAllRelations ())
{
final boolean bNewRelation = m_aHandledObjects.add (aRelation.getID ());
for (final IMutableGraphNode aNode : aRelation.getAllConnectedNodes ())
if (!EqualsHelper.identityEqual (aNode, aStartNode))
{
if (!m_aHandledObjects.contains (aNode.getID ()))
_traverseDFS (aNode, aList);
else
{
// If an unexplored edge leads to a node visited before, then the
// graph contains a cycle.
if (bNewRelation)
m_bHasCycles = true;
}
}
}
}
示例4: drainQueue
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
@Nonnull
@ReturnsMutableCopy
public final ICommonsList <DATATYPE> drainQueue ()
{
// Drain all objects to this queue
final ICommonsList <Object> aDrainedToList = new CommonsArrayList <> ();
m_aRWLock.writeLocked ( () -> m_aQueue.drainTo (aDrainedToList));
// Change data type
final ICommonsList <DATATYPE> ret = new CommonsArrayList <> ();
for (final Object aObj : aDrainedToList)
if (!EqualsHelper.identityEqual (aObj, STOP_QUEUE_OBJECT))
ret.add (GenericReflection.uncheckedCast (aObj));
else
{
// Re-add the stop object, because loops in derived classes rely on this
// object
m_aRWLock.writeLocked ( () -> m_aQueue.add (aObj));
}
return ret;
}
示例5: getPathToNode
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
/**
* Get the path from root node to the passed node. This includes all nodes up
* to the document node!
*
* @param aNode
* The node to start. May not be <code>null</code>.
* @param sSep
* The separator string to use. May not be <code>null</code>.
* @return The path to the node.
*/
@Nonnull
@SuppressFBWarnings ("IL_INFINITE_LOOP")
public static String getPathToNode (@Nonnull final Node aNode, @Nonnull final String sSep)
{
ValueEnforcer.notNull (aNode, "Node");
ValueEnforcer.notNull (sSep, "Separator");
final StringBuilder aRet = new StringBuilder ();
Node aCurNode = aNode;
while (aCurNode != null)
{
final StringBuilder aName = new StringBuilder (aCurNode.getNodeName ());
if (aCurNode.getNodeType () == Node.ELEMENT_NODE && aCurNode.getParentNode () != null)
{
// get index of my current element
final Element aCurElement = (Element) aCurNode;
int nIndex = 0;
// For all elements of the parent node
for (final Element x : new ChildElementIterator (aCurNode.getParentNode ()))
{
if (EqualsHelper.identityEqual (x, aCurNode))
break;
if (x.getTagName ().equals (aCurElement.getTagName ()))
++nIndex;
}
aName.append ('[').append (nIndex).append (']');
}
aRet.insert (0, sSep).insert (0, aName);
// goto parent
aCurNode = aCurNode.getParentNode ();
}
return aRet.toString ();
}
示例6: isSameOrChildOf
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
@SuppressFBWarnings ("IL_INFINITE_LOOP")
public final boolean isSameOrChildOf (@Nonnull final ITEMTYPE aParent)
{
ValueEnforcer.notNull (aParent, "Parent");
ITreeItem <DATATYPE, ITEMTYPE> aCur = this;
while (aCur != null)
{
// Do not use "equals" because it recursively compares all children!
if (EqualsHelper.identityEqual (aCur, aParent))
return true;
aCur = aCur.getParent ();
}
return false;
}
示例7: isSameOrChildOf
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
@SuppressFBWarnings ("IL_INFINITE_LOOP")
public final boolean isSameOrChildOf (@Nonnull final ITEMTYPE aParent)
{
ValueEnforcer.notNull (aParent, "Parent");
ITreeItemWithID <KEYTYPE, DATATYPE, ITEMTYPE> aCur = this;
while (aCur != null)
{
// Do not use "equals" because it recursively compares all children!
if (EqualsHelper.identityEqual (aCur, aParent))
return true;
aCur = aCur.getParent ();
}
return false;
}
示例8: getMostSevere
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
@Nullable
static IErrorLevel getMostSevere (@Nullable final IErrorLevel aLevel1, @Nullable final IErrorLevel aLevel2)
{
if (EqualsHelper.identityEqual (aLevel1, aLevel2))
return aLevel1;
if (aLevel1 == null)
return aLevel2;
if (aLevel2 == null)
return aLevel1;
return aLevel1.isGT (aLevel2) ? aLevel1 : aLevel2;
}
示例9: compare
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
@SuppressFBWarnings ({ "ES_COMPARING_PARAMETER_STRING_WITH_EQ" })
public static int compare (@Nullable final String sStr1,
@Nullable final String sStr2,
@Nonnull final Collator aCollator,
final boolean bNullValuesComeFirst)
{
if (EqualsHelper.identityEqual (sStr1, sStr2))
return 0;
if (sStr1 == null)
return bNullValuesComeFirst ? -1 : +1;
if (sStr2 == null)
return bNullValuesComeFirst ? +1 : -1;
return aCollator.compare (sStr1, sStr2);
}
示例10: compareIgnoreCase
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
@SuppressFBWarnings ({ "ES_COMPARING_PARAMETER_STRING_WITH_EQ" })
public static int compareIgnoreCase (@Nullable final String sStr1,
@Nullable final String sStr2,
final boolean bNullValuesComeFirst)
{
if (EqualsHelper.identityEqual (sStr1, sStr2))
return 0;
if (sStr1 == null)
return bNullValuesComeFirst ? -1 : +1;
if (sStr2 == null)
return bNullValuesComeFirst ? +1 : -1;
return sStr1.compareToIgnoreCase (sStr2);
}
示例11: _getOld
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
@Nullable
private T _getOld (final T aValue)
{
return EqualsHelper.identityEqual (aValue, m_aNoValue) ? null : aValue;
}
示例12: getPathToNode2
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
/**
* Get the path from root node to the passed node. This includes all nodes but
* excluding the document node!
*
* @param aNode
* The node to start. May not be <code>null</code>.
* @param sSep
* The separator string to use. May not be <code>null</code>.
* @return The path to the node.
*/
@Nonnull
public static String getPathToNode2 (@Nonnull final Node aNode, @Nonnull final String sSep)
{
ValueEnforcer.notNull (aNode, "Node");
ValueEnforcer.notNull (sSep, "Separator");
final StringBuilder aRet = new StringBuilder ();
Node aCurNode = aNode;
while (aCurNode != null)
{
if (aCurNode.getNodeType () == Node.DOCUMENT_NODE && aRet.length () > 0)
{
// Avoid printing the content of the document node, if something else is
// already present
// Add leading separator
aRet.insert (0, sSep);
break;
}
final StringBuilder aName = new StringBuilder (aCurNode.getNodeName ());
// Attribute nodes don't have a parent node, so it is not possible to
// construct the path
if (aCurNode.getNodeType () == Node.ELEMENT_NODE &&
aCurNode.getParentNode () != null &&
aCurNode.getParentNode ().getNodeType () == Node.ELEMENT_NODE)
{
// get index of current element in parent element
final Element aCurElement = (Element) aCurNode;
int nIndex = 0;
int nMatchingIndex = -1;
for (final Element x : new ChildElementIterator (aCurNode.getParentNode ()))
{
if (EqualsHelper.identityEqual (x, aCurNode))
nMatchingIndex = nIndex;
if (x.getTagName ().equals (aCurElement.getTagName ()))
++nIndex;
}
if (nMatchingIndex < 0)
throw new IllegalStateException ("Failed to find Node at parent");
if (nIndex > 1)
{
// Append index only, if more than one element is present
aName.append ('[').append (nMatchingIndex).append (']');
}
}
if (aRet.length () > 0)
{
// Avoid trailing separator
aRet.insert (0, sSep);
}
aRet.insert (0, aName);
// goto parent
aCurNode = aCurNode.getParentNode ();
}
return aRet.toString ();
}
示例13: _getObjectValue
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
@Nonnull
private String _getObjectValue (@Nullable final Object aValue)
{
return aValue == null ? CONSTANT_NULL
: EqualsHelper.identityEqual (aValue, m_aSrc) ? CONSTANT_THIS : aValue.toString ();
}
示例14: collect
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
/**
* This method starts the collector by taking objects from the internal
* {@link BlockingQueue}. So this method blocks and must be invoked from a
* separate thread. This method runs until {@link #stopQueuingNewObjects()} is
* new called and the queue is empty.
*
* @throws IllegalStateException
* if no performer is set - see
* {@link #setPerformer(IConcurrentPerformer)}
*/
public final void collect ()
{
if (m_aPerformer == null)
throw new IllegalStateException ("No performer set!");
try
{
// The temporary list that contains all objects to be delivered
final ICommonsList <DATATYPE> aObjectsToPerform = new CommonsArrayList <> ();
boolean bQueueIsStopped = false;
while (true)
{
// Block until the first object is in the queue
Object aCurrentObject = m_aQueue.take ();
if (EqualsHelper.identityEqual (aCurrentObject, STOP_QUEUE_OBJECT))
break;
// add current object
aObjectsToPerform.add (GenericReflection.uncheckedCast (aCurrentObject));
// take all messages that are in the queue and handle them at once.
// Handle at last m_nMaxPerformSize objects
while (aObjectsToPerform.size () < m_nMaxPerformCount && !m_aQueue.isEmpty ())
{
// Explicitly handle the "stop queue message" (using "=="!!!)
aCurrentObject = m_aQueue.take ();
if (EqualsHelper.identityEqual (aCurrentObject, STOP_QUEUE_OBJECT))
{
bQueueIsStopped = true;
break;
}
// add current object
aObjectsToPerform.add (GenericReflection.uncheckedCast (aCurrentObject));
}
_perform (aObjectsToPerform);
// In case we received a stop message while getting the bulk messages
// above -> break the loop manually
// Note: do not include in while-loop above because the conditions may
// not execute in the correct order since "take" is blocking!
if (bQueueIsStopped)
break;
}
// perform any remaining actions
_perform (aObjectsToPerform);
}
catch (final Throwable t)
{
s_aLogger.error ("Error taking elements from queue - queue has been interrupted!!!", t);
}
}
示例15: isArrayEquals
import com.helger.commons.equals.EqualsHelper; //导入方法依赖的package包/类
/**
* Recursive equal comparison for arrays.
*
* @param aHeadArray
* First array. May be <code>null</code>.
* @param aTailArray
* Second array. May be <code>null</code>.
* @return <code>true</code> only if the arrays and all contained elements are
* recursively equal.
*/
public static boolean isArrayEquals (@Nullable final Object aHeadArray, @Nullable final Object aTailArray)
{
// Same objects?
if (EqualsHelper.identityEqual (aHeadArray, aTailArray))
return true;
// Any of the null -> different because they are not both null
if (aHeadArray == null || aTailArray == null)
return false;
// If any of the passed object is not an array -> not equal as an array,
// even if they are equal!
if (!isArray (aHeadArray) || !isArray (aTailArray))
return false;
// Different component type?
if (!aHeadArray.getClass ().getComponentType ().equals (aTailArray.getClass ().getComponentType ()))
return false;
// Different length?
final int nLength = Array.getLength (aHeadArray);
if (nLength != Array.getLength (aTailArray))
return false;
// Compare step by step
for (int i = 0; i < nLength; i++)
{
final Object aItem1 = Array.get (aHeadArray, i);
final Object aItem2 = Array.get (aTailArray, i);
if (isArray (aItem1) && isArray (aItem2))
{
// Recursive call
if (!isArrayEquals (aItem1, aItem2))
return false;
}
else
{
// Use equals implementation
if (!EqualsHelper.equals (aItem1, aItem2))
return false;
}
}
// No differences found!
return true;
}