org.example.country.report.entities

Class Country

  • java.lang.Object
    • org.example.country.report.entities.Country
  • All Implemented Interfaces:
    java.io.Serializable


    public class Country
    extends java.lang.Object
    implements java.io.Serializable
    This is the entity class to hold the Country data from DB2.
    This class hold the results of this SQL:
     SELECT country.code as Code, country.name as Name,
       country.continent as Continent, city.name as Capital 
             FROM jearl.countries AS country 
       JOIN jearl.cities AS city 
       ON country.capital = city.id 
             WHERE country.continent = ? 
             ORDER BY Name
     
    Since:
    1.0
    Version:
    2.0
    Author:
    Jonathan Earl
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      Country()
      Constructing a default Country.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean equals(java.lang.Object obj)
      This is the equals method for the Country class.
      java.lang.String getCapital()
      This return the Country Capital.
      java.lang.String getCode()
      This return the Country Code.
      java.lang.String getContinent()
      This return the Country Continent.
      java.lang.String getName()
      This return the Country Name.
      int hashCode()
      This is the hashCode method for the Country class.
      void setCapital(java.lang.String capital)
      This set the Country Capital.
      void setCode(java.lang.String code)
      This set the Country Code.
      void setContinent(java.lang.String continent)
      This set the Country Continent.
      void setName(java.lang.String name)
      This set the Country Name.
      java.lang.String toString()
      This is the toString for the Country class.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Country

        public Country()
        Constructing a default Country.
        The initial values are:
        • code: ABW
        • name: Aruba
        • capital: Oranjestad
        • continent: North America
    • Method Detail

      • getCode

        public java.lang.String getCode()
        This return the Country Code.
        Returns:
        the Country code
      • setCode

        public void setCode(java.lang.String code)
        This set the Country Code.
        The rules are:
        • The code must not null.
        • The code must not empty.
        • The code must be 3 chars in length.
        • The code will be converted to upper case.
        Parameters:
        code - the code input value
        Throws:
        java.lang.IllegalArgumentException - if the input code is invalid
      • getName

        public java.lang.String getName()
        This return the Country Name.
        Returns:
        the Country name
      • setName

        public void setName(java.lang.String name)
        This set the Country Name.
        The rules are:
        • The name must not null.
        • The name must not empty.
        • The name must be 52 chars or less in length.
        Parameters:
        name - input value to set
        Throws:
        java.lang.IllegalArgumentException - if the input name is invalid
      • getCapital

        public java.lang.String getCapital()
        This return the Country Capital.
        Returns:
        the Country capital
      • setCapital

        public void setCapital(java.lang.String capital)
        This set the Country Capital.
        The rules are:
        • The capital must not null.
        • The capital must not empty.
        • The capital must be 35 chars or less in length.
        Parameters:
        capital - input value to set
        Throws:
        java.lang.IllegalArgumentException - if the input capital is invalid
      • getContinent

        public java.lang.String getContinent()
        This return the Country Continent.
        Returns:
        the Country continent
      • setContinent

        public void setContinent(java.lang.String continent)
        This set the Country Continent.
        The rules are:
        • The continent must not null.
        • The continent must not empty.
        • The continent must be 20 chars or less in length.
        • The continent must be in this list:
          • Africa
          • Antarctica
          • Asia
          • Europe
          • North America
          • Oceania
          • South America
        Parameters:
        continent - input value to set
        Throws:
        java.lang.IllegalArgumentException - if the input continent is invalid
      • toString

        public java.lang.String toString()
        This is the toString for the Country class.
        It returns:
        Country [code=xxx, name=xxx, capital=xxx, continent=xxx]
        Overrides:
        toString in class java.lang.Object
        Returns:
        the Country object as a String.
      • hashCode

        public int hashCode()
        This is the hashCode method for the Country class.
        It uses:
        • code
        • name
        • capital
        • continent
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the generated hashCode
      • equals

        public boolean equals(java.lang.Object obj)
        This is the equals method for the Country class.
        It uses:
        • code
        • name
        • capital
        • continent
        Overrides:
        equals in class java.lang.Object
        Returns:
        true of all the compared fields are equal