Advertisement
NickNDS

Plant Model

Jan 19th, 2025
181
0
11 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.75 KB | None | 0 0
  1. package com.cst323activity.model;
  2.  
  3. import org.springframework.stereotype.Component;
  4.  
  5. import jakarta.persistence.Column;
  6. import jakarta.persistence.Entity;
  7. import jakarta.persistence.GeneratedValue;
  8. import jakarta.persistence.GenerationType;
  9. import jakarta.persistence.Table;
  10. import jakarta.persistence.Id;
  11. import jakarta.validation.constraints.NotNull;
  12. import jakarta.validation.constraints.Size;
  13. @Component
  14. @Entity
  15. @Table(name="plants")
  16. public class PlantModel {
  17.     // ---- ATTRIBUTES ----
  18.  
  19.     // Unique Identifier
  20.     @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
  21.     private Long id;
  22.    
  23.     @Column(name="name")
  24.     @NotNull(message="Name is Required.")
  25.     @Size(min=1, max=50, message="Name limit is 50 characters")
  26.     private String name;
  27.  
  28.     @Column(name="scientific_name")
  29.     @NotNull(message="Scientific Name is Required")
  30.     @Size(min=1, max=50, message="Limit is 50 characters")
  31.     private String sciName;
  32.  
  33.     @Column(name="family_name")
  34.     @NotNull(message="Family Name is Required")
  35.     @Size(min=1, max=50, message="Limit is 50 characters")
  36.     private String famName;
  37.  
  38.     @Column(name="description")
  39.     @NotNull(message="Brief description is required")
  40.     @Size(min=1, max=256, message="Limit is 256 characters")
  41.     private String description;
  42.  
  43.  
  44.     //  ---- CONSTRUCTORS ----
  45.    
  46.  
  47.     public PlantModel(Long id,
  48.             @NotNull(message = "Name is Required.") @Size(min = 1, max = 50, message = "Name limit is 50 characters") String name,
  49.             @NotNull(message = "Scientific Name is Required") @Size(min = 1, max = 50, message = "Limit is 50 characters") String sciName,
  50.             @NotNull(message = "Family Name is Required") @Size(min = 1, max = 50, message = "Limit is 50 characters") String famName,
  51.             @NotNull(message = "Brief description is required") @Size(min = 1, max = 256, message = "Limit is 256 characters") String description) {
  52.         this.id = id;
  53.         this.name = name;
  54.         this.sciName = sciName;
  55.         this.famName = famName;
  56.         this.description = description;
  57.     }
  58.    
  59.     public PlantModel()
  60.     {
  61.         this.name = "";
  62.         this.sciName = "";
  63.         this.famName = "";
  64.         this.description = "";
  65.     }
  66.  
  67.     public Long getId() {
  68.         return id;
  69.     }
  70.  
  71.     public void setId(Long id) {
  72.         this.id = id;
  73.     }
  74.  
  75.     public String getName() {
  76.         return name;
  77.     }
  78.  
  79.     public void setName(String name) {
  80.         this.name = name;
  81.     }
  82.  
  83.     public String getSciName() {
  84.         return sciName;
  85.     }
  86.  
  87.     public void setSciName(String sciName) {
  88.         this.sciName = sciName;
  89.     }
  90.  
  91.     public String getFamName() {
  92.         return famName;
  93.     }
  94.  
  95.     public void setFamName(String famName) {
  96.         this.famName = famName;
  97.     }
  98.  
  99.     public String getDescription() {
  100.         return description;
  101.     }
  102.  
  103.     public void setDescription(String description) {
  104.         this.description = description;
  105.     }
  106.    
  107.    
  108. }
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement