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
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@ToString
|
@ToString
|
||||||
public class Address implements Cloneable
|
public class Address implements Cloneable {
|
||||||
{
|
|
||||||
private String streetName;
|
private String streetName;
|
||||||
private String cityName;
|
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
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@ToString
|
@ToString
|
||||||
public class Person implements Cloneable
|
public class Person implements Cloneable {
|
||||||
{
|
|
||||||
private String firstName;
|
|
||||||
private String lastName;
|
|
||||||
private Address address;
|
|
||||||
|
|
||||||
public Person(Person personToBeCloned) {
|
private String firstName;
|
||||||
Address addressToBeCloned = personToBeCloned.getAddress();
|
private String lastName;
|
||||||
|
private Address address;
|
||||||
|
|
||||||
this.firstName = personToBeCloned.getFirstName();
|
public Person(Person personToBeCloned) {
|
||||||
this.lastName = personToBeCloned.getLastName();
|
Address addressToBeCloned = personToBeCloned.getAddress();
|
||||||
this.address = new Address(addressToBeCloned.getStreetName(), addressToBeCloned.getCityName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
this.firstName = personToBeCloned.getFirstName();
|
||||||
public Person clone() {
|
this.lastName = personToBeCloned.getLastName();
|
||||||
|
this.address = new Address(addressToBeCloned.getStreetName(), addressToBeCloned.getCityName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Person clone() {
|
||||||
return new Person(this);
|
return new Person(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,19 +7,9 @@ import lombok.*;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@ToString
|
@ToString
|
||||||
public class Address implements Cloneable
|
public class Address implements Cloneable {
|
||||||
{
|
|
||||||
private String streetName;
|
private String streetName;
|
||||||
private String cityName;
|
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
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@ToString
|
@ToString
|
||||||
public class Person implements Cloneable
|
public class Person implements Cloneable {
|
||||||
{
|
|
||||||
private String firstName;
|
|
||||||
private String lastName;
|
|
||||||
private Address address;
|
|
||||||
|
|
||||||
@Override
|
private String firstName;
|
||||||
public Person clone() {
|
private String lastName;
|
||||||
|
private Address address;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Person clone() {
|
||||||
try {
|
try {
|
||||||
return (Person) super.clone();
|
return (Person) super.clone();
|
||||||
} catch (CloneNotSupportedException cloneException) {
|
} catch (CloneNotSupportedException cloneException) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user