Andrei Branza - replaced tabs si 4 spaces. eliminated not needed clone method in Address class from shallow and deep copy
This commit is contained in:
parent
9a421159ea
commit
65437b41ad
@ -7,19 +7,9 @@ import lombok.*;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class Address implements Cloneable
|
||||
{
|
||||
private String streetName;
|
||||
private String cityName;
|
||||
public class Address implements Cloneable {
|
||||
|
||||
private String streetName;
|
||||
private String cityName;
|
||||
|
||||
@Override
|
||||
public Address clone() {
|
||||
try
|
||||
{
|
||||
return (Address) super.clone();
|
||||
} catch (CloneNotSupportedException cloneException)
|
||||
{
|
||||
throw new RuntimeException(cloneException);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,22 +7,22 @@ import lombok.*;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class Person implements Cloneable
|
||||
{
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private Address address;
|
||||
public class Person implements Cloneable {
|
||||
|
||||
public Person(Person personToBeCloned) {
|
||||
Address addressToBeCloned = personToBeCloned.getAddress();
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private Address address;
|
||||
|
||||
this.firstName = personToBeCloned.getFirstName();
|
||||
this.lastName = personToBeCloned.getLastName();
|
||||
this.address = new Address(addressToBeCloned.getStreetName(), addressToBeCloned.getCityName());
|
||||
}
|
||||
public Person(Person personToBeCloned) {
|
||||
Address addressToBeCloned = personToBeCloned.getAddress();
|
||||
|
||||
@Override
|
||||
public Person clone() {
|
||||
this.firstName = personToBeCloned.getFirstName();
|
||||
this.lastName = personToBeCloned.getLastName();
|
||||
this.address = new Address(addressToBeCloned.getStreetName(), addressToBeCloned.getCityName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Person clone() {
|
||||
return new Person(this);
|
||||
}
|
||||
}
|
||||
|
@ -7,19 +7,9 @@ import lombok.*;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class Address implements Cloneable
|
||||
{
|
||||
private String streetName;
|
||||
private String cityName;
|
||||
public class Address implements Cloneable {
|
||||
|
||||
private String streetName;
|
||||
private String cityName;
|
||||
|
||||
@Override
|
||||
public Address clone() {
|
||||
try
|
||||
{
|
||||
return (Address) super.clone();
|
||||
} catch (CloneNotSupportedException cloneException)
|
||||
{
|
||||
throw new RuntimeException(cloneException);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,14 +7,14 @@ import lombok.*;
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
public class Person implements Cloneable
|
||||
{
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private Address address;
|
||||
public class Person implements Cloneable {
|
||||
|
||||
@Override
|
||||
public Person clone() {
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private Address address;
|
||||
|
||||
@Override
|
||||
public Person clone() {
|
||||
try {
|
||||
return (Person) super.clone();
|
||||
} catch (CloneNotSupportedException cloneException) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user