update project.
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="bin/main" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="gradle_scope" value="main"/>
|
||||||
|
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="bin/main" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="gradle_scope" value="main"/>
|
||||||
|
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-25/"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||||
|
<classpathentry kind="output" path="bin/default"/>
|
||||||
|
</classpath>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -20,4 +20,15 @@
|
|||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
|
<filteredResources>
|
||||||
|
<filter>
|
||||||
|
<id>1771249637326</id>
|
||||||
|
<name></name>
|
||||||
|
<type>30</type>
|
||||||
|
<matcher>
|
||||||
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
|
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
|
</matcher>
|
||||||
|
</filter>
|
||||||
|
</filteredResources>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=25
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=25
|
||||||
|
org.eclipse.jdt.core.compiler.source=25
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
Project is build as gradle root and child projects.
|
||||||
|
Gradle handles build and run of program using AspectJ Java runtime.
|
||||||
|
|
||||||
|
Build Environment:
|
||||||
|
JDK25,
|
||||||
|
Eclipse 4.38 with Gradle Buildship or VSCode with Extension Pack for Java; vscjava.vscode-java-pack( 0.30.5 )
|
||||||
|
AspectJ 1.9.25+
|
||||||
|
OpenJFX (** https://gluonhq.com/products/javafx/ **)
|
||||||
|
This java UI sdk requires you download windows/linux/Mac JMODs libs to your workspace on your host.
|
||||||
|
refer to the launch.json file, and add the directory location for the jmods you downloaded.
|
||||||
|
|
||||||
|
In Eclipse import project as an Gradle Project.
|
||||||
|
|
||||||
|
Tests with ASPECTJ:
|
||||||
|
on windows:
|
||||||
|
gradlew.bat run
|
||||||
|
/ or on linux:
|
||||||
|
sh ./gradlew edu.addressbook.view:run
|
||||||
|
AspectJ Referee component will call the Game plays.
|
||||||
|
|
||||||
|
|
||||||
|
schema
|
||||||
|
|
||||||
|
CREATE TABLE contact (
|
||||||
|
contact_id NUMBER PRIMARY KEY,
|
||||||
|
first_name TEXT,
|
||||||
|
last_name TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE phone (
|
||||||
|
contact_id NUMBER FOREIGN KEY,
|
||||||
|
phone_no TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE emailaddress (
|
||||||
|
contact_id NUMBER FOREIGN KEY,
|
||||||
|
email TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE address (
|
||||||
|
contact_id NUMBER FOREIGN KEY,
|
||||||
|
street TEXT,
|
||||||
|
city TEXT,
|
||||||
|
state TEXT,
|
||||||
|
zip TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE note (
|
||||||
|
contact_id NUMBER FOREIGN KEY,
|
||||||
|
note TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE activity (
|
||||||
|
activity_id NUMBER FOREIGN KEY,
|
||||||
|
activity_type TEXT,
|
||||||
|
activity_note TEXT
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE contact_activity (
|
||||||
|
activity_id NUMBER FOREIGN KEY,
|
||||||
|
contact_id NUMBER FOREIGN KEY
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE friends (
|
||||||
|
contact_id NUMBER FOREIGN KEY,
|
||||||
|
friend_contact_id NUMBER FORIEGN KEY
|
||||||
|
);
|
||||||
|
|
||||||
+32
-18
@@ -4,9 +4,14 @@
|
|||||||
*/
|
*/
|
||||||
package edu.bookocontacts;
|
package edu.bookocontacts;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import edu.bookocontacts.model.Person;
|
||||||
|
import edu.bookocontacts.model.PersonFactory;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
@@ -29,7 +34,9 @@ import javafx.scene.image.ImageView;
|
|||||||
* FXML Controller class
|
* FXML Controller class
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TableViewController implements Initializable {
|
public class ViewController implements Initializable {
|
||||||
|
|
||||||
|
Logger logger = Logger.getLogger(getClass().getName());
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private TableView<Person> personView = new TableView<>();
|
private TableView<Person> personView = new TableView<>();
|
||||||
@@ -53,30 +60,38 @@ public class TableViewController implements Initializable {
|
|||||||
|
|
||||||
private ImageView upImg = new ImageView(new Image("/media/up.png"));
|
private ImageView upImg = new ImageView(new Image("/media/up.png"));
|
||||||
private ImageView downImg = new ImageView(new Image("/media/down.png"));
|
private ImageView downImg = new ImageView(new Image("/media/down.png"));
|
||||||
List<Person> rawPersons = PersonFactory.getAllPersons();
|
|
||||||
ObservableList<Person> persons = FXCollections.observableArrayList(rawPersons);
|
private ObservableList<Person> persons = null;
|
||||||
int pageCount = 5;
|
|
||||||
int itemsPerPage = 4;
|
private int pageCount = 5;
|
||||||
int currentPageIndex = 0;
|
private int itemsPerPage = 4;
|
||||||
boolean order = true;
|
private int currentPageIndex = 0;
|
||||||
|
private boolean order = true;
|
||||||
|
|
||||||
|
private void log(String message){
|
||||||
|
logger.log(Level.FINE, message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the controller class.
|
* Initializes the controller class.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle rb) {
|
public void initialize(URL url, ResourceBundle rb) {
|
||||||
System.out.println("initialize");
|
log("initialize");
|
||||||
|
persons = FXCollections.observableArrayList(PersonFactory.getAllPersons());
|
||||||
|
log(String.format("Person size: %d" , persons.size()));
|
||||||
|
|
||||||
sort();
|
sort();
|
||||||
initializeTable();
|
initializeTable();
|
||||||
pageCount = getPageCount(persons.size(), itemsPerPage);
|
pageCount = getPageCount(persons.size(), itemsPerPage);
|
||||||
|
|
||||||
System.out.println("pageCount=" + pageCount);
|
log("pageCount=" + pageCount);
|
||||||
pagination.setPageCount(pageCount);
|
pagination.setPageCount(pageCount);
|
||||||
|
|
||||||
pagination.currentPageIndexProperty().addListener(new ChangeListener<Number>() {
|
pagination.currentPageIndexProperty().addListener(new ChangeListener<Number>() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
|
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
|
||||||
System.out.println("Pagination Changed from " + oldValue + " , to " + newValue);
|
log("Pagination Changed from " + oldValue + " , to " + newValue);
|
||||||
currentPageIndex = newValue.intValue();
|
currentPageIndex = newValue.intValue();
|
||||||
updatePersonView();
|
updatePersonView();
|
||||||
}
|
}
|
||||||
@@ -101,28 +116,27 @@ public class TableViewController implements Initializable {
|
|||||||
if (order) {
|
if (order) {
|
||||||
Collections.reverse(persons);
|
Collections.reverse(persons);
|
||||||
}
|
}
|
||||||
System.out.println(" order = " + order + "; data = " + persons);
|
log(" order = " + order + "; data = " + persons);
|
||||||
order = !order;
|
order = !order;
|
||||||
id.setGraphic((order) ? upImg : downImg);
|
id.setGraphic((order) ? upImg : downImg);
|
||||||
updatePersonView();
|
updatePersonView();
|
||||||
System.out.println(" comparator called");
|
log(" comparator called");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sort() {
|
private void sort() {
|
||||||
//persons.sort((Person p1, Person p2) -> p1.id.compareTo(p2.id));
|
|
||||||
Collections.sort(persons, new Comparator<Person>() {
|
Collections.sort(persons, new Comparator<Person>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Person t, Person t1) {
|
public int compare(Person t, Person t1) {
|
||||||
System.out.println(" comparator called");
|
log(" comparator called");
|
||||||
return t.getId().compareTo(t1.getId());
|
return t.getId().compareTo(t1.getId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updatePersonView() {
|
public void updatePersonView() {
|
||||||
System.out.println("updatePersonView");
|
log("updatePersonView");
|
||||||
personView.getItems().setAll(persons.subList(currentPageIndex * itemsPerPage, ((currentPageIndex * itemsPerPage + itemsPerPage <= persons.size()) ? currentPageIndex * itemsPerPage + itemsPerPage : persons.size())));
|
personView.getItems().setAll(persons.subList(currentPageIndex * itemsPerPage, ((currentPageIndex * itemsPerPage + itemsPerPage <= persons.size()) ? currentPageIndex * itemsPerPage + itemsPerPage : persons.size())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +149,7 @@ public class TableViewController implements Initializable {
|
|||||||
personViewNameCol.sortTypeProperty().addListener(new ChangeListener<SortType>() {
|
personViewNameCol.sortTypeProperty().addListener(new ChangeListener<SortType>() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1, SortType paramT2) {
|
public void changed(ObservableValue<? extends SortType> paramObservableValue, SortType paramT1, SortType paramT2) {
|
||||||
System.out.println("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2);
|
log("NAME Clicked -- sortType = " + paramT1 + ", SortType=" + paramT2);
|
||||||
id.setGraphic(null);
|
id.setGraphic(null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -164,7 +178,7 @@ public class TableViewController implements Initializable {
|
|||||||
private int getPageCount(int totalCount, int itemsPerPage) {
|
private int getPageCount(int totalCount, int itemsPerPage) {
|
||||||
float floatCount = Float.valueOf(totalCount) / Float.valueOf(itemsPerPage);
|
float floatCount = Float.valueOf(totalCount) / Float.valueOf(itemsPerPage);
|
||||||
int intCount = totalCount / itemsPerPage;
|
int intCount = totalCount / itemsPerPage;
|
||||||
System.out.println("floatCount=" + floatCount + ", intCount=" + intCount);
|
log("floatCount=" + floatCount + ", intCount=" + intCount);
|
||||||
return ((floatCount > intCount) ? ++intCount : intCount);
|
return ((floatCount > intCount) ? ++intCount : intCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
package edu.bookocontacts.model;
|
||||||
|
|
||||||
|
public final class Address{
|
||||||
|
|
||||||
|
String street;
|
||||||
|
String city;
|
||||||
|
String state;
|
||||||
|
String zip;
|
||||||
|
|
||||||
|
public Address() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Address(String street, String city, String state, String zip) {
|
||||||
|
this.street = street;
|
||||||
|
this.city = city;
|
||||||
|
this.state = state;
|
||||||
|
this.zip = zip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStreet() {
|
||||||
|
return street;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStreet(String street) {
|
||||||
|
this.street = street;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCity() {
|
||||||
|
return city;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCity(String city) {
|
||||||
|
this.city = city;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(String state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getZip() {
|
||||||
|
return zip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZip(String zip) {
|
||||||
|
this.zip = zip;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((street == null) ? 0 : street.hashCode());
|
||||||
|
result = prime * result + ((city == null) ? 0 : city.hashCode());
|
||||||
|
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
||||||
|
result = prime * result + ((zip == null) ? 0 : zip.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Address other = (Address) obj;
|
||||||
|
if (street == null) {
|
||||||
|
if (other.street != null)
|
||||||
|
return false;
|
||||||
|
} else if (!street.equals(other.street))
|
||||||
|
return false;
|
||||||
|
if (city == null) {
|
||||||
|
if (other.city != null)
|
||||||
|
return false;
|
||||||
|
} else if (!city.equals(other.city))
|
||||||
|
return false;
|
||||||
|
if (state == null) {
|
||||||
|
if (other.state != null)
|
||||||
|
return false;
|
||||||
|
} else if (!state.equals(other.state))
|
||||||
|
return false;
|
||||||
|
if (zip == null) {
|
||||||
|
if (other.zip != null)
|
||||||
|
return false;
|
||||||
|
} else if (!zip.equals(other.zip))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("{ \"Address\":{");
|
||||||
|
sb.append("\"street\": \"" + street + "\",");
|
||||||
|
sb.append("\"city\": \"" + city + "\",");
|
||||||
|
sb.append("\"state\": \"" + state + "\",");
|
||||||
|
sb.append("\"zip\": \"" + zip + "\"");
|
||||||
|
sb.append("}}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
package edu.bookocontacts.model;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Concrete account data class for account json storage record.
|
||||||
|
* Collects account attributes, and hash instance to enforce uniqueness.
|
||||||
|
*/
|
||||||
|
public class Contact {
|
||||||
|
private Integer contact_id = null;
|
||||||
|
private String phone_number;
|
||||||
|
private Address mailing_address;
|
||||||
|
private EmailAddress email_address;
|
||||||
|
|
||||||
|
public Contact() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Contact(
|
||||||
|
String phone_number,
|
||||||
|
Address mailing_address,
|
||||||
|
EmailAddress email_address) throws IllegalArgumentException {
|
||||||
|
this.phone_number = phone_number;
|
||||||
|
this.mailing_address = mailing_address;
|
||||||
|
this.email_address = email_address;
|
||||||
|
|
||||||
|
if (phone_number == null) {
|
||||||
|
throw new IllegalArgumentException(String.format("%s %s", "Account: requires phone number",
|
||||||
|
mailing_address.toString()));
|
||||||
|
}
|
||||||
|
if (mailing_address == null) {
|
||||||
|
throw new IllegalArgumentException(String.format("%s %s", "Account: requires mailing address",
|
||||||
|
phone_number.substring(phone_number.length() - 4)));
|
||||||
|
}
|
||||||
|
if (email_address == null) {
|
||||||
|
throw new IllegalArgumentException(String.format("%s %s", "Account: requires phone number",
|
||||||
|
mailing_address.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.phone_number = phone_number;
|
||||||
|
this.mailing_address = mailing_address;
|
||||||
|
this.email_address = email_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("{ \"Account\":{");
|
||||||
|
sb.append("\"account_number\": \"").append(contact_id).append("\",");
|
||||||
|
sb.append("\"phone_number\": \"").append(phone_number).append("\",");
|
||||||
|
sb.append("\"mailing_address\": ").append(mailing_address).append(",");
|
||||||
|
sb.append("\"email_address\": ").append(email_address).append(",");
|
||||||
|
sb.append("}}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Write(Contact acct) throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPhone_number() {
|
||||||
|
return phone_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhone_number(String phone_number) {
|
||||||
|
this.phone_number = phone_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Address getMailing_address() {
|
||||||
|
return mailing_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMailing_address(Address mailing_address) {
|
||||||
|
this.mailing_address = mailing_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmailAddress getEmail_address() {
|
||||||
|
return email_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail_address(EmailAddress email_address) {
|
||||||
|
this.email_address = email_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((contact_id == null) ? 0 : contact_id.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
Contact other = (Contact) obj;
|
||||||
|
if (contact_id == null) {
|
||||||
|
if (other.contact_id != null)
|
||||||
|
return false;
|
||||||
|
} else if (!contact_id.equals(other.contact_id))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkValid() throws IllegalArgumentException {
|
||||||
|
if (email_address == null) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format("not valid, email_address %s", this.contact_id));
|
||||||
|
}
|
||||||
|
if (phone_number == null) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format("not valid, phone_number: %s", this.contact_id));
|
||||||
|
}
|
||||||
|
if (getMailing_address() == null) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format("not valid, mailing_address: %s", this.contact_id));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(Contact acct) {
|
||||||
|
this.setEmail_address(acct.email_address);
|
||||||
|
this.setPhone_number(acct.phone_number);
|
||||||
|
this.setMailing_address(acct.mailing_address);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package edu.bookocontacts.model;
|
||||||
|
|
||||||
|
public class EmailAddress{
|
||||||
|
String email_address;
|
||||||
|
|
||||||
|
public EmailAddress(String email_address) {
|
||||||
|
this.email_address = email_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail_address() {
|
||||||
|
return email_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail_address(String email_address) {
|
||||||
|
this.email_address = email_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((email_address == null) ? 0 : email_address.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
EmailAddress other = (EmailAddress) obj;
|
||||||
|
if (email_address == null) {
|
||||||
|
if (other.email_address != null)
|
||||||
|
return false;
|
||||||
|
} else if (!email_address.equals(other.email_address))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("{ \"EmailAddress\":{");
|
||||||
|
sb.append("\"email\": \"" + email_address + "\"");
|
||||||
|
sb.append("}}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
-4
@@ -2,10 +2,7 @@
|
|||||||
* To change this template, choose Tools | Templates
|
* To change this template, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package edu.bookocontacts;
|
package edu.bookocontacts.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
+3
-3
@@ -2,7 +2,7 @@
|
|||||||
* To change this template, choose Tools | Templates
|
* To change this template, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package edu.bookocontacts;
|
package edu.bookocontacts.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -12,7 +12,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class PersonFactory {
|
public class PersonFactory {
|
||||||
static int id=0;
|
static int id=0;
|
||||||
static List getAllPersons() {
|
|
||||||
|
public static List<Person> getAllPersons() {
|
||||||
ArrayList<Person> list = new ArrayList<>();
|
ArrayList<Person> list = new ArrayList<>();
|
||||||
list.add(createPerson("John", 40));
|
list.add(createPerson("John", 40));
|
||||||
list.add(createPerson("Daisy", 21));
|
list.add(createPerson("Daisy", 21));
|
||||||
@@ -28,7 +29,6 @@ public class PersonFactory {
|
|||||||
list.add(createPerson("John", 52));
|
list.add(createPerson("John", 52));
|
||||||
list.add(createPerson("Daisy", 29));
|
list.add(createPerson("Daisy", 29));
|
||||||
list.add(createPerson("Martha Has a very Long Name", 18));
|
list.add(createPerson("Martha Has a very Long Name", 18));
|
||||||
System.out.println("Returning person size: " + list.size());
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package edu.bookocontacts.model;
|
||||||
|
|
||||||
|
public class PhoneNumber {
|
||||||
|
String phone_number;
|
||||||
|
|
||||||
|
public PhoneNumber(String phone_number) {
|
||||||
|
this.phone_number = phone_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getphone_number() {
|
||||||
|
return phone_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setphone_number(String phone_number) {
|
||||||
|
this.phone_number = phone_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((phone_number == null) ? 0 : phone_number.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
PhoneNumber other = (PhoneNumber) obj;
|
||||||
|
if (phone_number == null) {
|
||||||
|
if (other.phone_number != null)
|
||||||
|
return false;
|
||||||
|
} else if (!phone_number.equals(other.getphone_number()))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("{ \"PhoneNumber\":{");
|
||||||
|
sb.append("\"phone\": \"" + phone_number + "\"");
|
||||||
|
sb.append("}}");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<?import javafx.scene.text.Text?>
|
<?import javafx.scene.text.Text?>
|
||||||
|
|
||||||
<AnchorPane id="AnchorPane" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="edu.bookocontacts.TableViewController">
|
<AnchorPane id="AnchorPane" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="edu.bookocontacts.ViewController">
|
||||||
<children>
|
<children>
|
||||||
<TableView fx:id="personView" layoutX="1.0" layoutY="76.0" prefHeight="210.0" prefWidth="478.0">
|
<TableView fx:id="personView" layoutX="1.0" layoutY="76.0" prefHeight="210.0" prefWidth="478.0">
|
||||||
<columns>
|
<columns>
|
||||||
|
|||||||
Reference in New Issue
Block a user