Java Code Examples for com.helger.commons.state.EChange#CHANGED
The following examples show how to use
com.helger.commons.state.EChange#CHANGED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicTreeItemWithID.java From ph-commons with Apache License 2.0 | 6 votes |
@Nonnull public final EChange removeChild (@Nullable final KEYTYPE aDataID) { if (aDataID == null) return EChange.UNCHANGED; // Any children present if (m_aChildMap == null) return EChange.UNCHANGED; // Main removal final ITEMTYPE aItem = m_aChildMap.remove (aDataID); if (aItem == null) return EChange.UNCHANGED; if (!m_aChildren.remove (aItem)) throw new IllegalStateException ("Failed to remove item from list: " + aItem); // Notify factory _recursiveRemoveFromFactory (aItem); return EChange.CHANGED; }
Example 2
Source File: MicroElement.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public EChange setNamespaceURI (@Nullable final String sNamespaceURI) { if (EqualsHelper.equals (m_sNamespaceURI, sNamespaceURI)) return EChange.UNCHANGED; m_sNamespaceURI = sNamespaceURI; return EChange.CHANGED; }
Example 3
Source File: AbstractMicroNodeWithChildren.java From ph-commons with Apache License 2.0 | 5 votes |
@Override @Nonnull protected final EChange onRemoveChild (@Nonnull final IMicroNode aChildNode) { if (!aChildNode.hasParent ()) throw new MicroException ("The passed child node to be removed has no parent!"); if (m_aChildren == null || !m_aChildren.remove (aChildNode)) return EChange.UNCHANGED; _afterRemoveChildOfThis (aChildNode); return EChange.CHANGED; }
Example 4
Source File: Expirable.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public EChange setExpirationDateTime (@Nullable final LocalDateTime aExpirationDateTime) { if (EqualsHelper.equals (aExpirationDateTime, m_aExpirationDateTime)) return EChange.UNCHANGED; m_aExpirationDateTime = aExpirationDateTime; return EChange.CHANGED; }
Example 5
Source File: GraphNode.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public EChange removeAllRelations () { if (!hasRelations ()) return EChange.UNCHANGED; m_aRelations = null; return EChange.CHANGED; }
Example 6
Source File: MapBasedXPathVariableResolverQName.java From ph-commons with Apache License 2.0 | 5 votes |
/** * Add all variables from the other variable resolver into this resolver. * * @param aOther * The variable resolver to import the variable from. May not be * <code>null</code>. * @param bOverwrite * if <code>true</code> existing variables will be overwritten with the * new variables, otherwise the old variables are kept. * @return {@link EChange} */ @Nonnull public EChange addAllFrom (@Nonnull final MapBasedXPathVariableResolverQName aOther, final boolean bOverwrite) { ValueEnforcer.notNull (aOther, "Other"); EChange eChange = EChange.UNCHANGED; for (final Map.Entry <QName, Object> aEntry : aOther.m_aMap.entrySet ()) if (bOverwrite || !m_aMap.containsKey (aEntry.getKey ())) { m_aMap.put (aEntry.getKey (), aEntry.getValue ()); eChange = EChange.CHANGED; } return eChange; }
Example 7
Source File: GenericJAXBMarshaller.java From ph-commons with Apache License 2.0 | 5 votes |
/** * Change whether the context cache should be used or not. Since creating the * JAXB context is quite cost intensive it is recommended to leave it enabled. * * @param bUseContextCache * <code>true</code> to use it (default), <code>false</code> if not. * @return {@link EChange} */ @Nonnull public final EChange setUseContextCache (final boolean bUseContextCache) { if (bUseContextCache == m_bUseContextCache) return EChange.UNCHANGED; m_bUseContextCache = bUseContextCache; return EChange.CHANGED; }
Example 8
Source File: MutableShort.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public EChange set (final short nValue) { if (m_nValue == nValue) return EChange.UNCHANGED; m_nValue = nValue; onAfterChange (); return EChange.CHANGED; }
Example 9
Source File: GenericJAXBMarshaller.java From ph-commons with Apache License 2.0 | 5 votes |
/** * Set the indent string to be used for writing JAXB objects. * * @param sIndentString * The indent string to be used. May be <code>null</code>. * @return {@link EChange} * @since 8.5.3 */ @Nonnull public final EChange setIndentString (@Nullable final String sIndentString) { if (EqualsHelper.equals (sIndentString, m_sIndentString)) return EChange.UNCHANGED; m_sIndentString = sIndentString; return EChange.CHANGED; }
Example 10
Source File: MutableByte.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public EChange set (final byte nValue) { if (m_nValue == nValue) return EChange.UNCHANGED; m_nValue = nValue; onAfterChange (); return EChange.CHANGED; }
Example 11
Source File: MutableBoolean.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public EChange set (final boolean bValue) { if (m_bValue == bValue) return EChange.UNCHANGED; m_bValue = bValue; onAfterChange (); return EChange.CHANGED; }
Example 12
Source File: DirectedGraph.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public EChange removeNode (@Nonnull final IMutableDirectedGraphNode aNode) { ValueEnforcer.notNull (aNode, "Node"); if (!isChangingConnectedObjectsAllowed () && aNode.hasRelations ()) throw new IllegalArgumentException ("The node to be removed already has incoming and/or outgoing relations and this is not allowed!"); if (m_aNodes.remove (aNode.getID ()) == null) return EChange.UNCHANGED; _invalidateCache (); return EChange.CHANGED; }
Example 13
Source File: DirectedGraphNode.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public EChange removeAllIncomingRelations () { if (!hasIncomingRelations ()) return EChange.UNCHANGED; m_aIncoming = null; return EChange.CHANGED; }
Example 14
Source File: MapBasedXPathFunctionResolver.java From ph-commons with Apache License 2.0 | 5 votes |
/** * Add all functions from the other function resolver into this resolver. * * @param aOther * The function resolver to import the functions from. May not be * <code>null</code>. * @param bOverwrite * if <code>true</code> existing functions will be overwritten with the * new functions, otherwise the old functions are kept. * @return {@link EChange} */ @Nonnull public EChange addAllFrom (@Nonnull final MapBasedXPathFunctionResolver aOther, final boolean bOverwrite) { ValueEnforcer.notNull (aOther, "Other"); EChange eChange = EChange.UNCHANGED; for (final Map.Entry <XPathFunctionKey, XPathFunction> aEntry : aOther.m_aMap.entrySet ()) if (bOverwrite || !m_aMap.containsKey (aEntry.getKey ())) { m_aMap.put (aEntry.getKey (), aEntry.getValue ()); eChange = EChange.CHANGED; } return eChange; }
Example 15
Source File: AbstractMapBasedMultilingualText.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public final EChange setText (@Nonnull final Locale aContentLocale, @Nullable final String sText) { ValueEnforcer.notNull (aContentLocale, "ContentLocale"); if (texts ().containsKey (aContentLocale)) { // Text for this locale already contained final String sOldText = internalGetText (aContentLocale); // Did anything change? if (EqualsHelper.equals (sOldText, sText)) return EChange.UNCHANGED; if (_beforeChange ().isBreak ()) return EChange.UNCHANGED; internalSetText (aContentLocale, sText); } else { // New text if (_beforeChange ().isBreak ()) return EChange.UNCHANGED; internalAddText (aContentLocale, sText); } _afterChange (); return EChange.CHANGED; }
Example 16
Source File: BasicTreeWithGlobalUniqueID.java From ph-commons with Apache License 2.0 | 5 votes |
@Nonnull public final EChange removeItemWithID (@Nullable final KEYTYPE aDataID) { final ITEMTYPE aItem = getItemWithID (aDataID); if (aItem == null) return EChange.UNCHANGED; final ITEMTYPE aParent = aItem.getParent (); if (aParent == null) throw new IllegalArgumentException ("Cannot remove the root item!"); if (aParent.removeChild (aDataID).isUnchanged ()) throw new IllegalStateException ("Failed to remove child " + aItem + " from parent " + aParent); return EChange.CHANGED; }
Example 17
Source File: GenericJAXBMarshaller.java From ph-commons with Apache License 2.0 | 3 votes |
/** * Set the no namespace schema location to be used for writing JAXB objects. * * @param sNoNamespaceSchemaLocation * The no namespace schema location to be used. May be * <code>null</code>. * @return {@link EChange} * @since 9.0.0 */ @Nonnull public final EChange setNoNamespaceSchemaLocation (@Nullable final String sNoNamespaceSchemaLocation) { if (EqualsHelper.equals (sNoNamespaceSchemaLocation, m_sNoNamespaceSchemaLocation)) return EChange.UNCHANGED; m_sNoNamespaceSchemaLocation = sNoNamespaceSchemaLocation; return EChange.CHANGED; }
Example 18
Source File: ICommonsCollection.java From ph-commons with Apache License 2.0 | 3 votes |
/** * Remove all elements from this collection. This is similar to * {@link #clear()} but it returns a different value whether something was * cleared or not. * * @return {@link EChange#CHANGED} if the collection was not empty and * something was removed, {@link EChange#UNCHANGED} otherwise. * @see #clear() */ @Nonnull default EChange removeAll () { if (isEmpty ()) return EChange.UNCHANGED; clear (); return EChange.CHANGED; }
Example 19
Source File: CollectionHelper.java From ph-commons with Apache License 2.0 | 3 votes |
/** * Remove the element at the specified index from the passed list. This works * if the list is not <code>null</code> and the index is ≥ 0 and < * <code>list.size()</code> * * @param aList * The list to remove an element from. May be <code>null</code>. * @param nIndex * The index to be removed. May be arbitrary. * @return {@link EChange#CHANGED} if removal was successful * @see #removeAndReturnElementAtIndex(List, int) */ @Nonnull public static EChange removeAtIndex (@Nullable final List <?> aList, final int nIndex) { if (aList == null || nIndex < 0 || nIndex >= aList.size ()) return EChange.UNCHANGED; aList.remove (nIndex); return EChange.CHANGED; }
Example 20
Source File: ICommonsMap.java From ph-commons with Apache License 2.0 | 3 votes |
/** * Remove all elements from this collection. This is similar to * {@link #clear()} but it returns a different value whether something was * cleared or not. * * @return {@link EChange#CHANGED} if the collection was not empty and * something was removed, {@link EChange#UNCHANGED} otherwise. * @see #clear() */ @Nonnull default EChange removeAll () { if (isEmpty ()) return EChange.UNCHANGED; clear (); return EChange.CHANGED; }