本文整理汇总了Java中com.helger.commons.state.EChange类的典型用法代码示例。如果您正苦于以下问题:Java EChange类的具体用法?Java EChange怎么用?Java EChange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EChange类属于com.helger.commons.state包,在下文中一共展示了EChange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateMPC
import com.helger.commons.state.EChange; //导入依赖的package包/类
@Nonnull
public EChange updateMPC (@Nonnull final IMPC aMPC)
{
ValueEnforcer.notNull (aMPC, "MPC");
final MPC aRealMPC = getOfID (aMPC.getID ());
if (aRealMPC == null)
{
AuditHelper.onAuditModifyFailure (MPC.OT, aMPC.getID (), "no-such-id");
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
BusinessObjectHelper.setLastModificationNow (aRealMPC);
internalUpdateItem (aRealMPC);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditModifySuccess (MPC.OT, "all", aRealMPC.getID ());
return EChange.CHANGED;
}
示例2: deleteMPC
import com.helger.commons.state.EChange; //导入依赖的package包/类
@Nonnull
public EChange deleteMPC (@Nullable final String sMPCID)
{
final MPC aDeletedMPC = getOfID (sMPCID);
if (aDeletedMPC == null)
{
AuditHelper.onAuditDeleteFailure (MPC.OT, "no-such-object-id", sMPCID);
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
internalDeleteItem (sMPCID);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditDeleteSuccess (MPC.OT, sMPCID);
return EChange.CHANGED;
}
示例3: deletePMode
import com.helger.commons.state.EChange; //导入依赖的package包/类
@Nonnull
public EChange deletePMode (@Nullable final String sPModeID)
{
final PMode aDeletedPMode = getOfID (sPModeID);
if (aDeletedPMode == null)
{
AuditHelper.onAuditDeleteFailure (PMode.OT, "no-such-object-id", sPModeID);
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
internalDeleteItem (sPModeID);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditDeleteSuccess (PMode.OT, sPModeID);
return EChange.CHANGED;
}
示例4: add
import com.helger.commons.state.EChange; //导入依赖的package包/类
/**
* Add a new variable.
*
* @param sName
* The name of the variable. May neither be <code>null</code> nor
* empty.
* @param sValue
* The value of the variable. May neither be <code>null</code> nor
* empty.
* @return {@link EChange#UNCHANGED} if a variable with the same name is
* already present. Never <code>null</code>.
*/
@Nonnull
public EChange add (@Nonnull @Nonempty final String sName, @Nonnull @Nonempty final String sValue)
{
ValueEnforcer.notEmpty (sName, "Name");
ValueEnforcer.notEmpty (sValue, "Value");
// Prepend the "$" prefix to the variable name
final String sRealName = PSXPathQueryBinding.PARAM_VARIABLE_PREFIX + sName;
if (m_aMap.containsKey (sRealName))
return EChange.UNCHANGED;
// Apply all existing variables to this variable value!
// This ensures that all variables used in variables are resolved correctly
// as long as the order of declaration is correct.
// Additionally this means that the order of the variables in this class is
// irrelevant
final String sRealValue = getAppliedReplacement (sValue);
m_aMap.put (sRealName, sRealValue);
return EChange.CHANGED;
}
示例5: setUndeletion
import com.helger.commons.state.EChange; //导入依赖的package包/类
@Nonnull
public final EChange setUndeletion (@Nonnull final LocalDateTime aUndeletionDT,
@Nonnull @Nonempty final String sUndeletionUserID)
{
ValueEnforcer.notNull (aUndeletionDT, "UndeletionDT");
ValueEnforcer.notEmpty (sUndeletionUserID, "UndeletionUserID");
if (m_aDeletionDT == null)
{
// Object is not deleted and can therefore not be undeleted
return EChange.UNCHANGED;
}
m_aDeletionDT = null;
m_sDeletionUserID = null;
// Last modification AFTER deletion was reverted
setLastModification (aUndeletionDT, sUndeletionUserID);
return EChange.CHANGED;
}
示例6: addAllMapped
import com.helger.commons.state.EChange; //导入依赖的package包/类
/**
* Add all passed elements matching the provided filter after performing a
* mapping using the provided function.
*
* @param aElements
* The elements to be added after mapping. May be <code>null</code>.
* @param aMapper
* The mapping function to be executed for all provided elements. May
* not be <code>null</code>.
* @param aFilter
* The filter to be applied on the mapped element. May be
* <code>null</code>.
* @return {@link EChange#CHANGED} if at least one element was added,
* {@link EChange#UNCHANGED}. Never <code>null</code>.
* @param <SRCTYPE>
* The source type to be mapped from
* @since 8.5.2
*/
@Nonnull
default <SRCTYPE> EChange addAllMapped (@Nullable final SRCTYPE [] aElements,
@Nonnull final Function <? super SRCTYPE, ? extends ELEMENTTYPE> aMapper,
@Nullable final Predicate <? super ELEMENTTYPE> aFilter)
{
ValueEnforcer.notNull (aMapper, "Mapper");
if (aFilter == null)
return addAllMapped (aElements, aMapper);
EChange eChange = EChange.UNCHANGED;
if (aElements != null)
for (final SRCTYPE aValue : aElements)
{
final ELEMENTTYPE aMapped = aMapper.apply (aValue);
if (aFilter.test (aMapped))
eChange = eChange.or (add (aMapped));
}
return eChange;
}
示例7: setAddress
import com.helger.commons.state.EChange; //导入依赖的package包/类
/**
* Set the address part of the email address. Performs a validity check of the
* email address.
*
* @param sAddress
* The address part to be set.
* @return {@link EChange#CHANGED} if the address was valid and different from
* the existing one. Returns {@link EChange#UNCHANGED} if the email
* address was the same as before, or the email address itself was
* invalid.
*/
@Nonnull
public EChange setAddress (@Nullable final String sAddress)
{
final String sRealAddress = EmailAddressHelper.getUnifiedEmailAddress (sAddress);
if (EqualsHelper.equals (sRealAddress, m_sAddress))
return EChange.UNCHANGED;
// Check only without MX record check here, because this is a performance
// bottleneck when having multiple customers
if (sRealAddress != null && !EmailAddressHelper.isValid (sRealAddress))
{
s_aLogger.error ("Found an illegal email address: '" + sRealAddress + "'");
return EChange.UNCHANGED;
}
m_sAddress = sRealAddress;
return EChange.CHANGED;
}
示例8: removeIf
import com.helger.commons.state.EChange; //导入依赖的package包/类
@Nonnull
default EChange removeIf (@Nonnull final Predicate <? super Map.Entry <? extends KEYTYPE, ? extends VALUETYPE>> aFilter)
{
ValueEnforcer.notNull (aFilter, "Filter");
EChange ret = EChange.UNCHANGED;
final Iterator <Map.Entry <KEYTYPE, VALUETYPE>> it = entrySet ().iterator ();
while (it.hasNext ())
{
if (aFilter.test (it.next ()))
{
it.remove ();
ret = EChange.CHANGED;
}
}
return ret;
}
示例9: addNode
import com.helger.commons.state.EChange; //导入依赖的package包/类
@Nonnull
public EChange addNode (@Nonnull final IMutableDirectedGraphNode aNode)
{
ValueEnforcer.notNull (aNode, "Node");
if (!isChangingConnectedObjectsAllowed () && aNode.hasRelations ())
throw new IllegalArgumentException ("The node to be added already has incoming and/or outgoing relations and this is not allowed!");
final String sID = aNode.getID ();
if (m_aNodes.containsKey (sID))
return EChange.UNCHANGED;
m_aNodes.put (sID, aNode);
_invalidateCache ();
return EChange.CHANGED;
}
示例10: onRead
import com.helger.commons.state.EChange; //导入依赖的package包/类
@Override
@Nonnull
protected EChange onRead (@Nonnull final IMicroDocument aDoc)
{
// Read all child elements independent of the name - soft migration
final Class <IMPLTYPE> aDataTypeClass = getDataTypeClass ();
final Wrapper <EChange> aChange = new Wrapper <> (EChange.UNCHANGED);
aDoc.getDocumentElement ().forAllChildElements (m_aReadElementFilter, eItem -> {
final IMPLTYPE aItem = MicroTypeConverter.convertToNative (eItem, aDataTypeClass);
_addItem (aItem, EDAOActionType.CREATE);
if (aItem instanceof IDAOReadChangeAware)
if (((IDAOReadChangeAware) aItem).isReadChanged ())
{
// Remember that something was changed while reading
aChange.set (EChange.CHANGED);
}
});
return aChange.get ();
}
示例11: clearCachedSize
import com.helger.commons.state.EChange; //导入依赖的package包/类
/**
* Remove a single resource from the cache.
*
* @param aRes
* The resource to be removed. May be <code>null</code>.
* @return Never <code>null</code>.
*/
@Nonnull
public EChange clearCachedSize (@Nullable final IReadableResource aRes)
{
if (aRes == null)
return EChange.UNCHANGED;
return m_aRWLock.writeLocked ( () -> {
// Existing resource?
if (m_aImageData.remove (aRes) != null)
return EChange.CHANGED;
// Non-existing resource?
if (m_aNonExistingResources.remove (aRes))
return EChange.CHANGED;
return EChange.UNCHANGED;
});
}
示例12: onRemoveChildAtIndex
import com.helger.commons.state.EChange; //导入依赖的package包/类
@Override
@Nonnull
protected final EChange onRemoveChildAtIndex (@Nonnegative final int nIndex)
{
// Resolve index - may be invalid
final IMicroNode aChildNode = getChildAtIndex (nIndex);
if (aChildNode == null)
return EChange.UNCHANGED;
if (!aChildNode.hasParent ())
throw new MicroException ("Internal inconsistency: the passed child node to be removed has no parent!");
// Main removal
if (m_aChildren.remove (nIndex) != aChildNode)
throw new MicroException ("Internal inconsistency: remove resulted in an illegal object!");
_afterRemoveChildOfThis (aChildNode);
return EChange.CHANGED;
}
示例13: onInit
import com.helger.commons.state.EChange; //导入依赖的package包/类
@Override
@Nonnull
protected EChange onInit ()
{
// Create default MPC
createMPC (new MPC (CAS4.DEFAULT_MPC_ID));
return EChange.CHANGED;
}
示例14: markMPCDeleted
import com.helger.commons.state.EChange; //导入依赖的package包/类
@Nonnull
public EChange markMPCDeleted (@Nullable final String sMPCID)
{
final MPC aDeletedMPC = getOfID (sMPCID);
if (aDeletedMPC == null)
{
AuditHelper.onAuditDeleteFailure (MPC.OT, "no-such-object-id", sMPCID);
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
if (BusinessObjectHelper.setDeletionNow (aDeletedMPC).isUnchanged ())
{
AuditHelper.onAuditDeleteFailure (MPC.OT, "already-deleted", sMPCID);
return EChange.UNCHANGED;
}
internalMarkItemDeleted (aDeletedMPC);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditDeleteSuccess (MPC.OT, sMPCID);
return EChange.CHANGED;
}
示例15: updatePMode
import com.helger.commons.state.EChange; //导入依赖的package包/类
@Nonnull
public EChange updatePMode (@Nonnull final IPMode aPMode)
{
ValueEnforcer.notNull (aPMode, "PMode");
final PMode aRealPMode = getOfID (aPMode.getID ());
if (aRealPMode == null)
{
AuditHelper.onAuditModifyFailure (PMode.OT, aPMode.getID (), "no-such-id");
return EChange.UNCHANGED;
}
m_aRWLock.writeLock ().lock ();
try
{
aRealPMode.setInitiator (aPMode.getInitiator ());
aRealPMode.setResponder (aPMode.getResponder ());
aRealPMode.setAgreement (aPMode.getAgreement ());
aRealPMode.setMEP (aPMode.getMEP ());
aRealPMode.setMEPBinding (aPMode.getMEPBinding ());
aRealPMode.setLeg1 (aPMode.getLeg1 ());
aRealPMode.setLeg2 (aPMode.getLeg2 ());
aRealPMode.setPayloadService (aPMode.getPayloadService ());
aRealPMode.setReceptionAwareness (aPMode.getReceptionAwareness ());
BusinessObjectHelper.setLastModificationNow (aRealPMode);
internalUpdateItem (aRealPMode);
}
finally
{
m_aRWLock.writeLock ().unlock ();
}
AuditHelper.onAuditModifySuccess (PMode.OT, "all", aRealPMode.getID ());
s_aLogger.info ("Updated PMode with ID '" + aPMode.getID () + "'");
return EChange.CHANGED;
}