Class FileDriverMapper

  • All Implemented Interfaces:
    DriverMapper

    public class FileDriverMapper
    extends java.lang.Object
    implements DriverMapper
    The driver mapper implementation Using file to persist driver / offer association. One file by driver (the filename is the driver name). In the file, offers are isolated by delimiter.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addOffersTo​(java.util.List<java.lang.String> offersIdsToAdd, java.lang.String driverName)
      Add list of offers to a driver's offers persisted list (and persists it)
      void addOfferTo​(java.lang.String offerId, java.lang.String driverName)
      Add one offer to a driver's offers persisted list (and persists it)
      static FileDriverMapper getInstance()
      Get the driver mapper instance
      java.util.List<java.lang.String> getOffersFor​(java.lang.String driverName)
      Get persisted offers list for a driver
      void removeOffersTo​(java.util.List<java.lang.String> offersIdsToRemove, java.lang.String driverName)
      Remove list of offers to a driver's offers persisted list (and persist it)
      void removeOfferTo​(java.lang.String offerId, java.lang.String driverName)
      Remove one offer to a driver's offers persisted list (and persists it)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getOffersFor

        public java.util.List<java.lang.String> getOffersFor​(java.lang.String driverName)
                                                      throws StorageDriverMapperException
        Description copied from interface: DriverMapper
        Get persisted offers list for a driver
        Specified by:
        getOffersFor in interface DriverMapper
        Parameters:
        driverName - the driver name
        Returns:
        offers IDs list for driverName or empty list if there is actually no association
        Throws:
        StorageDriverMapperException - if application cannot have information (reading error for example)
      • addOfferTo

        public void addOfferTo​(java.lang.String offerId,
                               java.lang.String driverName)
                        throws StorageDriverMapperException
        Description copied from interface: DriverMapper
        Add one offer to a driver's offers persisted list (and persists it)
        Specified by:
        addOfferTo in interface DriverMapper
        Parameters:
        offerId - the offer ID to append and persist
        driverName - the driver name
        Throws:
        StorageDriverMapperException - if application cannot have information (writing error for example)
      • addOffersTo

        public void addOffersTo​(java.util.List<java.lang.String> offersIdsToAdd,
                                java.lang.String driverName)
                         throws StorageDriverMapperException
        Description copied from interface: DriverMapper
        Add list of offers to a driver's offers persisted list (and persists it)
        Specified by:
        addOffersTo in interface DriverMapper
        Parameters:
        offersIdsToAdd - the offers IDs list to append and persist
        driverName - the driver name
        Throws:
        StorageDriverMapperException - if application cannot have information (writing error for example)
      • removeOfferTo

        public void removeOfferTo​(java.lang.String offerId,
                                  java.lang.String driverName)
                           throws StorageDriverMapperException
        Description copied from interface: DriverMapper
        Remove one offer to a driver's offers persisted list (and persists it)
        Specified by:
        removeOfferTo in interface DriverMapper
        Parameters:
        offerId - the offer ID to remove and persist
        driverName - the driver name
        Throws:
        StorageDriverMapperException - if application cannot have information (writing error for example)
      • removeOffersTo

        public void removeOffersTo​(java.util.List<java.lang.String> offersIdsToRemove,
                                   java.lang.String driverName)
                            throws StorageDriverMapperException
        Description copied from interface: DriverMapper
        Remove list of offers to a driver's offers persisted list (and persist it)
        Specified by:
        removeOffersTo in interface DriverMapper
        Parameters:
        offersIdsToRemove - the offers IDs list to remove and persist
        driverName - the driver name
        Throws:
        StorageDriverMapperException - if application cannot have information (writing error for example)