Class DatabaseBean

java.lang.Object
org.deltava.beans.DatabaseBean
All Implemented Interfaces:
Serializable, Comparable<Object>, IDBean, Cacheable
Direct Known Subclasses:
ACARSLogEntry, ACARSMapEntry, Accomplishment, AddressValidation, ApplicantData, ArchivedRoute, ArchiveMetadata, AssignmentInfo, BriefingPackage, Certificate, CertificationRequirement, CharterRequest, Comment, Course, DatabaseBlobBean, DispatchLogEntry, DispatchScheduleEntry, DispatchStatistics, EliteLifetimeStatus, EliteStatus, EMailDelivery, Feedback, Flight, FlightEliteScore, FlightHistoryEntry, FlightRoute, FrameRates, IMAPConfiguration, InactivityPurge, InstructionBusy, InstructionFlight, InstructionSession, IPLocation, Issue, Issue, JobPosting, LandingStatistics, LinkedImage, LoginAddress, MembershipTotals, Message, MessageThread, Nomination, NominationComment, PollOption, PollVote, PushEndpoint, Resource, Route, Signup, StatusUpdate, SystemInformation, TakeoffLanding, Test, ThreadNotifications, ThreadUpdate, TouchdownData, TransferRequest, UserData, Warning, YearlyTotal

public abstract class DatabaseBean extends Object implements IDBean, Cacheable, Comparable<Object>
A common abstract class for beans stored in the database with a numeric primary key.
Since:
1.0
Version:
11.0
Author:
Luke
See Also:
  • Constructor Details

    • DatabaseBean

      public DatabaseBean()
  • Method Details

    • getID

      public int getID()
      Description copied from interface: IDBean
      Returns the database ID of this object.
      Specified by:
      getID in interface IDBean
      Returns:
      the database ID
    • getHexID

      public String getHexID()
      Description copied from interface: IDBean
      Returns the hexadecimal database ID of this object.
      Specified by:
      getHexID in interface IDBean
      Returns:
      the hexadecimal formatted database ID, or an empty string if zero
    • setID

      public void setID(int id)
      Update the database row ID of this bean. This typically will only be called by a DAO
      Parameters:
      id - The primary key of the entry in the database that corresponds to this object.
      Throws:
      IllegalArgumentException - if the database ID is negative
      IllegalStateException - if we are attempting to change the database ID
      See Also:
    • validateID

      public static void validateID(int oldID, int newID) throws IllegalArgumentException, IllegalStateException
      Validates a database ID. Used to enforce database ID behavior - that the ID cannot be zero or negative, and it cannot be updated once set.
      Parameters:
      oldID - the old database ID
      newID - the new database ID
      Throws:
      IllegalArgumentException - if the database ID is negative or zero
      IllegalStateException - if we are attempting to change the database ID
    • validateID

      public static void validateID(int oldID, int newID, boolean allowZero) throws IllegalArgumentException, IllegalStateException
      Validates a database ID. Used to enforce database ID behavior - that the ID cannot be zero or negative, and it cannot be updated once set.
      Parameters:
      oldID - the old database ID
      newID - the new database ID
      allowZero - TRUE to allow setting the ID to zero, otherwise FALSE
      Throws:
      IllegalArgumentException - if the database ID is negative (or zero if allowZero is FALSE)
      IllegalStateException - if we are attempting to change the database ID
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(Object o)
      Specified by:
      compareTo in interface Comparable<Object>
    • cacheKey

      public Object cacheKey()
      Description copied from interface: Cacheable
      Returns the cache key for this object. Caches call this method when adding the object.
      Specified by:
      cacheKey in interface Cacheable
      Returns:
      the cache key for the object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object