/** * @return <code>true</code> if auto save is enabled, <code>false</code> * otherwise. */ @MustBeLocked (ELockType.READ) protected final boolean internalIsAutoSaveEnabled () { return m_bAutoSaveEnabled; }
/** * @return <code>true</code> if unsaved changes are present */ @MustBeLocked (ELockType.READ) public final boolean internalHasPendingChanges () { return m_bPendingChanges; }
@MustBeLocked (ELockType.WRITE) public final void internalSetPendingChanges (final boolean bPendingChanges) { m_bPendingChanges = bPendingChanges; }
/** * Create the XML document that should be saved to the file. This method is * only called within a write lock! * * @return The non-<code>null</code> document to write to the file. */ @Nonnull @MustBeLocked (ELockType.WRITE) protected abstract IMicroDocument createWriteData ();
/** * Fill the internal structures with from the passed XML document. This method * is only called within a write lock! * * @param aDoc * The XML document to read from. Never <code>null</code>. * @return {@link EChange#CHANGED} if reading the data changed something in * the internal structures that requires a writing. */ @Nonnull @MustBeLocked (ELockType.WRITE) protected abstract EChange onRead (@Nonnull IMicroDocument aDoc);
@Nonnegative @MustBeLocked (ELockType.READ) protected int internalGetFailedMailCount () { return m_aMap.size (); }
@Nullable @MustBeLocked (ELockType.READ) protected FailedMailData internalGetFailedMailOfID (@Nullable final String sID) { return m_aMap.get (sID); }
/** * Mark as changed - just to make markAsChanged accessible */ @MustBeLocked (ELockType.WRITE) protected void myMarkChanged () { super.markAsChanged (); }
/** * Called after a successful write of the file, if the filename is different * from the previous filename. This can e.g. be used to clear old data. * * @param sPreviousFilename * The previous filename. May be <code>null</code>. * @param sNewFilename * The new filename. Never <code>null</code>. */ @OverrideOnDemand @MustBeLocked (ELockType.WRITE) protected void onFilenameChange (@Nullable final String sPreviousFilename, @Nonnull final String sNewFilename) {}
/** * Mark an item as "no longer deleted" without actually adding it to the map. * This method only triggers the update action but does not alter the item. * Must only be invoked inside a write-lock. * * @param aItem * The item that was marked as "no longer deleted" */ @MustBeLocked (ELockType.WRITE) protected final void internalMarkItemUndeleted (@Nonnull final IMPLTYPE aItem) { internalMarkItemUndeleted (aItem, true); }
/** * Initial read - just to make initialRead accessible * * @throws DAOException * In case of error */ @MustBeLocked (ELockType.WRITE) protected void myInitialRead () throws DAOException { initialRead (); }
@Nonnegative @MustBeLocked (ELockType.READ) private static int _getTotalQueueLength () { int ret = 0; // count over all queues for (final MailQueuePerSMTP aQueue : s_aQueueCache.values ()) ret += aQueue.getQueueLength (); return ret; }
@Override @MustBeLocked (ELockType.WRITE) protected void onRecoveryDelete (@Nonnull final IMPLTYPE aItem) { m_aMap.remove (aItem.getID (), aItem); }
@MustBeLocked (ELockType.READ) protected final boolean internalContainsWithID (@Nullable final String sID) { if (StringHelper.hasNoText (sID)) return false; return m_aMap.containsKey (sID); }
@Nonnull @ReturnsMutableCopy @MustBeLocked (ELockType.READ) protected ICommonsList <FailedMailData> internalGetAllFailedMails () { return m_aMap.copyOfValues (); }
@Nonnull @MustBeLocked (ELockType.WRITE) private ServletStatus _getOrCreateServletStatus (@Nonnull final Class <? extends GenericServlet> aServletClass) { ValueEnforcer.notNull (aServletClass, "Servlet class"); if (Modifier.isAbstract (aServletClass.getModifiers ())) throw new IllegalStateException ("Passed servlet class is abstract: " + aServletClass); final String sKey = _getKey (aServletClass); return m_aMap.computeIfAbsent (sKey, k -> new ServletStatus (aServletClass.getName ())); }
@MustBeLocked (ELockType.WRITE) private void _addItem (@Nonnull final Favorite aFavorite) { ValueEnforcer.notNull (aFavorite, "Favorite"); m_aMap.putSingle (aFavorite.getUserID (), aFavorite); }
@MustBeLocked (ELockType.READ) @CodingStyleguideUnaware protected final Collection <IMPLTYPE> internalGetAllSortedByKey () { return m_aMap.getSortedByKey (Comparator.naturalOrder ()).values (); }
@Override @Nonnull @MustBeLocked (ELockType.READ) protected IMicroDocument createWriteData () { final IMicroDocument aDoc = new MicroDocument (); final IMicroElement eRoot = aDoc.appendElement (ELEMENT_ROOT); for (final IMPLTYPE aItem : internalGetAllSortedByKey ()) eRoot.appendChild (MicroTypeConverter.convertToMicroElement (aItem, ELEMENT_ITEM)); return aDoc; }
@Nonnull @ReturnsMutableCopy @MustBeLocked (ELockType.WRITE) protected ICommonsList <FailedMailData> internalRemoveAll () { final ICommonsList <FailedMailData> aTempList = new CommonsArrayList <> (m_aMap.size ()); if (!m_aMap.isEmpty ()) { aTempList.addAll (m_aMap.values ()); m_aMap.clear (); } return aTempList; }