diff --git a/src/main/java/ezvcard/VCard.java b/src/main/java/ezvcard/VCard.java index cb0c8f8c1..eab9debf5 100644 --- a/src/main/java/ezvcard/VCard.java +++ b/src/main/java/ezvcard/VCard.java @@ -4715,4 +4715,13 @@ static String generateAltId(Collection properties) { } return altId + ""; } + + public VCard deepCopy() { + VCard that = new VCard(); + that.version = this.version; + for (final VCardProperty property : getProperties()) { + that.addProperty(property.deepCopy()); + } + return that; + } } \ No newline at end of file diff --git a/src/main/java/ezvcard/ValidationWarnings.java b/src/main/java/ezvcard/ValidationWarnings.java index facd007a1..dc9cef97a 100644 --- a/src/main/java/ezvcard/ValidationWarnings.java +++ b/src/main/java/ezvcard/ValidationWarnings.java @@ -1,10 +1,7 @@ package ezvcard; import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; import ezvcard.property.VCardProperty; diff --git a/src/main/java/ezvcard/property/Address.java b/src/main/java/ezvcard/property/Address.java index b2b91cddd..28b288119 100644 --- a/src/main/java/ezvcard/property/Address.java +++ b/src/main/java/ezvcard/property/Address.java @@ -95,6 +95,19 @@ public class Address extends VCardProperty implements HasAltId { private String postalCode; private String country; + @Override public Address deepCopy() { + Address that = new Address(); + this.copyTo(that); + that.poBox = this.poBox; + that.extendedAddress = this.extendedAddress; + that.streetAddress = this.streetAddress; + that.locality = this.locality; + that.region = this.region; + that.postalCode = this.postalCode; + that.country = this.country; + return that; + } + /** * Gets the P.O. (post office) box. * @return the P.O. box or null if not set diff --git a/src/main/java/ezvcard/property/Agent.java b/src/main/java/ezvcard/property/Agent.java index 6d873bac7..3fbf7fbdf 100644 --- a/src/main/java/ezvcard/property/Agent.java +++ b/src/main/java/ezvcard/property/Agent.java @@ -104,6 +104,14 @@ public Agent() { //empty } + public Agent deepCopy() { + Agent that = new Agent(); + this.copyTo(that); + that.url = this.url; + that.vcard = this.vcard; + return that; + } + /** * Creates an agent property. * @param url a URL pointing to the agent's information diff --git a/src/main/java/ezvcard/property/Anniversary.java b/src/main/java/ezvcard/property/Anniversary.java index defc5904f..4fa0d197e 100644 --- a/src/main/java/ezvcard/property/Anniversary.java +++ b/src/main/java/ezvcard/property/Anniversary.java @@ -110,6 +110,12 @@ public Anniversary(Date date) { super(date); } + @Override public Anniversary deepCopy() { + Anniversary that = new Anniversary(this.getDate()); + copyTo(that); + return that; + } + /** * Creates an anniversary property. * @param date the anniversary date diff --git a/src/main/java/ezvcard/property/BinaryProperty.java b/src/main/java/ezvcard/property/BinaryProperty.java index 3413a372d..de21751fe 100644 --- a/src/main/java/ezvcard/property/BinaryProperty.java +++ b/src/main/java/ezvcard/property/BinaryProperty.java @@ -62,6 +62,14 @@ public abstract class BinaryProperty extends VCard */ protected T contentType; + @Override public abstract BinaryProperty deepCopy(); + + protected void copyTo(BinaryProperty that) { + that.data = this.data.clone(); + that.url = this.url; + that.contentType = this.contentType; + } + public BinaryProperty() { //empty } diff --git a/src/main/java/ezvcard/property/Birthday.java b/src/main/java/ezvcard/property/Birthday.java index 7cc512450..9828b7152 100644 --- a/src/main/java/ezvcard/property/Birthday.java +++ b/src/main/java/ezvcard/property/Birthday.java @@ -106,6 +106,13 @@ public Birthday(Date date) { super(date); } + @Override + public Birthday deepCopy() { + Birthday that = new Birthday(this.getDate()); + copyTo(that); + return that; + } + /** * Creates a birthday property. * @param date the birthday diff --git a/src/main/java/ezvcard/property/Birthplace.java b/src/main/java/ezvcard/property/Birthplace.java index 5397715d5..9c63f15e0 100644 --- a/src/main/java/ezvcard/property/Birthplace.java +++ b/src/main/java/ezvcard/property/Birthplace.java @@ -97,6 +97,13 @@ public Birthplace() { super(); } + @Override + public Birthplace deepCopy() { + Birthplace that = new Birthplace(); + copyTo(that); + return that; + } + /** * Creates a new birthplace property. * @param latitude the latitude coordinate of the place diff --git a/src/main/java/ezvcard/property/CalendarRequestUri.java b/src/main/java/ezvcard/property/CalendarRequestUri.java index adfe77311..264e56d80 100755 --- a/src/main/java/ezvcard/property/CalendarRequestUri.java +++ b/src/main/java/ezvcard/property/CalendarRequestUri.java @@ -70,6 +70,13 @@ public CalendarRequestUri(String uri) { } @Override + public CalendarRequestUri deepCopy() { + CalendarRequestUri that = new CalendarRequestUri(value); + copyTo(that); + return that; + } + + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V4_0); } diff --git a/src/main/java/ezvcard/property/CalendarUri.java b/src/main/java/ezvcard/property/CalendarUri.java index 0cc52825e..d438f299b 100755 --- a/src/main/java/ezvcard/property/CalendarUri.java +++ b/src/main/java/ezvcard/property/CalendarUri.java @@ -68,6 +68,13 @@ public CalendarUri(String uri) { super(uri); } + @Override + public CalendarUri deepCopy() { + CalendarUri that = new CalendarUri(value); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V4_0); diff --git a/src/main/java/ezvcard/property/Categories.java b/src/main/java/ezvcard/property/Categories.java index f037bbd56..dccbefdb5 100644 --- a/src/main/java/ezvcard/property/Categories.java +++ b/src/main/java/ezvcard/property/Categories.java @@ -63,6 +63,13 @@ * @author Michael Angstadt */ public class Categories extends TextListProperty implements HasAltId { + @Override + public Categories deepCopy() { + Categories that = new Categories(); + copyTo(that); + return that; + } + @Override public List getPids() { return super.getPids(); diff --git a/src/main/java/ezvcard/property/Classification.java b/src/main/java/ezvcard/property/Classification.java index 7dc82813b..3eaa80bfb 100644 --- a/src/main/java/ezvcard/property/Classification.java +++ b/src/main/java/ezvcard/property/Classification.java @@ -68,6 +68,13 @@ public Classification(String classValue) { super(classValue); } + @Override + public Classification deepCopy() { + Classification that = new Classification(this.getValue()); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V3_0); diff --git a/src/main/java/ezvcard/property/ClientPidMap.java b/src/main/java/ezvcard/property/ClientPidMap.java index 17909f170..e418c6a55 100644 --- a/src/main/java/ezvcard/property/ClientPidMap.java +++ b/src/main/java/ezvcard/property/ClientPidMap.java @@ -104,6 +104,13 @@ public ClientPidMap(Integer pid, String uri) { this.uri = uri; } + @Override + public ClientPidMap deepCopy() { + ClientPidMap that = new ClientPidMap(pid, uri); + copyTo(that); + return that; + } + /** * Generates a CLIENTPIDMAP type that contains a random UID URI. * @param pid the PID diff --git a/src/main/java/ezvcard/property/DateOrTimeProperty.java b/src/main/java/ezvcard/property/DateOrTimeProperty.java index 89d2c7e0a..64d758030 100644 --- a/src/main/java/ezvcard/property/DateOrTimeProperty.java +++ b/src/main/java/ezvcard/property/DateOrTimeProperty.java @@ -49,6 +49,23 @@ public class DateOrTimeProperty extends VCardProperty implements HasAltId { private PartialDate partialDate; private boolean dateHasTime; + private DateOrTimeProperty() {} + + @Override + public DateOrTimeProperty deepCopy() { + DateOrTimeProperty that = new DateOrTimeProperty(); + copyTo(that); + return that; + } + + protected void copyTo(final DateOrTimeProperty that) { + super.copyTo(that); + that.text = this.text; + that.date = new Date(this.date.getTime()); + that.partialDate = this.partialDate; // immutable + that.dateHasTime = this.dateHasTime; + } + /** * Creates a date-and-or-time property. * @param date the date value diff --git a/src/main/java/ezvcard/property/Deathdate.java b/src/main/java/ezvcard/property/Deathdate.java index ec3fc9a18..e3597bb12 100644 --- a/src/main/java/ezvcard/property/Deathdate.java +++ b/src/main/java/ezvcard/property/Deathdate.java @@ -110,6 +110,13 @@ public Deathdate(Date date) { super(date); } + @Override + public Deathdate deepCopy() { + Deathdate that = new Deathdate(getDate()); + copyTo(that); + return that; + } + /** * Creates a deathdate property. * @param date the deathdate diff --git a/src/main/java/ezvcard/property/Deathplace.java b/src/main/java/ezvcard/property/Deathplace.java index 8259a6ce0..69b1592dd 100644 --- a/src/main/java/ezvcard/property/Deathplace.java +++ b/src/main/java/ezvcard/property/Deathplace.java @@ -97,6 +97,13 @@ public Deathplace() { super(); } + @Override + public Deathplace deepCopy() { + Deathplace that = new Deathplace(); + copyTo(that); + return that; + } + /** * Creates a new deathplace property. * @param latitude the latitude coordinate of the place diff --git a/src/main/java/ezvcard/property/Email.java b/src/main/java/ezvcard/property/Email.java index 30b73c143..9317a3b28 100644 --- a/src/main/java/ezvcard/property/Email.java +++ b/src/main/java/ezvcard/property/Email.java @@ -77,6 +77,13 @@ public Email(String email) { super(email); } + @Override + public Email deepCopy() { + Email that = new Email(getValue()); + copyTo(that); + return that; + } + /** * Gets all the TYPE parameters. * @return the TYPE parameters or empty set if there are none diff --git a/src/main/java/ezvcard/property/Expertise.java b/src/main/java/ezvcard/property/Expertise.java index c2650d8fd..7d925e422 100644 --- a/src/main/java/ezvcard/property/Expertise.java +++ b/src/main/java/ezvcard/property/Expertise.java @@ -75,6 +75,13 @@ public Expertise(String skill) { } @Override + public Expertise deepCopy() { + Expertise that = new Expertise(getValue()); + copyTo(that); + return that; + } + + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V4_0); } diff --git a/src/main/java/ezvcard/property/FormattedName.java b/src/main/java/ezvcard/property/FormattedName.java index c27757a49..bc4843f25 100644 --- a/src/main/java/ezvcard/property/FormattedName.java +++ b/src/main/java/ezvcard/property/FormattedName.java @@ -64,6 +64,13 @@ public FormattedName(String name) { super(name); } + @Override + public FormattedName deepCopy() { + FormattedName that = new FormattedName(getValue()); + copyTo(that); + return that; + } + /** * Gets the TYPE parameter. *

diff --git a/src/main/java/ezvcard/property/FreeBusyUrl.java b/src/main/java/ezvcard/property/FreeBusyUrl.java index d37b11358..a3eb330d8 100644 --- a/src/main/java/ezvcard/property/FreeBusyUrl.java +++ b/src/main/java/ezvcard/property/FreeBusyUrl.java @@ -68,6 +68,13 @@ public FreeBusyUrl(String uri) { super(uri); } + @Override + public FreeBusyUrl deepCopy() { + FreeBusyUrl that = new FreeBusyUrl(getValue()); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V4_0); diff --git a/src/main/java/ezvcard/property/Gender.java b/src/main/java/ezvcard/property/Gender.java index 5254bc30e..cace890b5 100755 --- a/src/main/java/ezvcard/property/Gender.java +++ b/src/main/java/ezvcard/property/Gender.java @@ -95,6 +95,14 @@ public Gender(String gender) { this.gender = gender; } + @Override + public Gender deepCopy() { + Gender that = new Gender(gender); + copyTo(that); + that.text = this.text; + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V4_0); diff --git a/src/main/java/ezvcard/property/Geo.java b/src/main/java/ezvcard/property/Geo.java index 1f73a3b11..a20d5e2a5 100644 --- a/src/main/java/ezvcard/property/Geo.java +++ b/src/main/java/ezvcard/property/Geo.java @@ -97,6 +97,13 @@ public Geo(Double latitude, Double longitude) { this(new GeoUri.Builder(latitude, longitude).build()); } + @Override + public Geo deepCopy() { + Geo that = new Geo(this.uri); + copyTo(that); + return that; + } + /** * Creates a geo property. * @param uri the geo URI diff --git a/src/main/java/ezvcard/property/Hobby.java b/src/main/java/ezvcard/property/Hobby.java index 3a6bd1e55..abfe90b62 100644 --- a/src/main/java/ezvcard/property/Hobby.java +++ b/src/main/java/ezvcard/property/Hobby.java @@ -74,6 +74,13 @@ public Hobby(String hobby) { super(hobby); } + @Override + public Hobby deepCopy() { + Hobby that = new Hobby(getValue()); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V4_0); diff --git a/src/main/java/ezvcard/property/ImageProperty.java b/src/main/java/ezvcard/property/ImageProperty.java index b341106a3..d4a104113 100644 --- a/src/main/java/ezvcard/property/ImageProperty.java +++ b/src/main/java/ezvcard/property/ImageProperty.java @@ -40,6 +40,16 @@ * @author Michael Angstadt */ public class ImageProperty extends BinaryProperty { + + protected ImageProperty() {} + + @Override + public ImageProperty deepCopy() { + ImageProperty that = new ImageProperty(); + copyTo(that); + return that; + } + /** * Creates an image property. * @param url the URL to the image diff --git a/src/main/java/ezvcard/property/Impp.java b/src/main/java/ezvcard/property/Impp.java index 223c9b0e7..43ddd9430 100644 --- a/src/main/java/ezvcard/property/Impp.java +++ b/src/main/java/ezvcard/property/Impp.java @@ -84,6 +84,13 @@ public class Impp extends VCardProperty implements HasAltId { private URI uri; + @Override + public Impp deepCopy() { + Impp that = new Impp(this.uri); + copyTo(that); + return that; + } + /** * Creates an IMPP property. Note that this class has static factory methods * for creating IMPP properties of common IM protocols. diff --git a/src/main/java/ezvcard/property/Interest.java b/src/main/java/ezvcard/property/Interest.java index ba4975409..47c497540 100644 --- a/src/main/java/ezvcard/property/Interest.java +++ b/src/main/java/ezvcard/property/Interest.java @@ -74,6 +74,13 @@ public Interest(String interest) { super(interest); } + @Override + public Interest deepCopy() { + Interest that = new Interest(getValue()); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V4_0); diff --git a/src/main/java/ezvcard/property/Key.java b/src/main/java/ezvcard/property/Key.java index 0a692a2ad..7fcc16132 100644 --- a/src/main/java/ezvcard/property/Key.java +++ b/src/main/java/ezvcard/property/Key.java @@ -113,6 +113,14 @@ public Key() { super(); } + @Override + public Key deepCopy() { + Key that = new Key(); + copyTo(that); + that.text = this.text; + return that; + } + /** * Creates a key property. * @param data the binary data diff --git a/src/main/java/ezvcard/property/Kind.java b/src/main/java/ezvcard/property/Kind.java index 1f4e6124c..48d275207 100644 --- a/src/main/java/ezvcard/property/Kind.java +++ b/src/main/java/ezvcard/property/Kind.java @@ -91,6 +91,13 @@ public Kind(String kind) { super(kind); } + @Override + public Kind deepCopy() { + Kind that = new Kind(getValue()); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V4_0); diff --git a/src/main/java/ezvcard/property/Label.java b/src/main/java/ezvcard/property/Label.java index a4fa3401a..a83790163 100644 --- a/src/main/java/ezvcard/property/Label.java +++ b/src/main/java/ezvcard/property/Label.java @@ -88,6 +88,14 @@ public Label(String label) { super(label); } + + @Override + public Label deepCopy() { + Label that = new Label(getValue()); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V2_1, VCardVersion.V3_0); diff --git a/src/main/java/ezvcard/property/Language.java b/src/main/java/ezvcard/property/Language.java index 5d65f8a1b..66573793a 100644 --- a/src/main/java/ezvcard/property/Language.java +++ b/src/main/java/ezvcard/property/Language.java @@ -74,6 +74,13 @@ public Language(String language) { super(language); } + @Override + public Language deepCopy() { + Language that = new Language(getValue()); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V4_0); diff --git a/src/main/java/ezvcard/property/ListProperty.java b/src/main/java/ezvcard/property/ListProperty.java index f5858d1b9..5a62a72d9 100644 --- a/src/main/java/ezvcard/property/ListProperty.java +++ b/src/main/java/ezvcard/property/ListProperty.java @@ -44,6 +44,18 @@ public class ListProperty extends VCardProperty { protected List values = new ArrayList(); + @Override + public ListProperty deepCopy() { + ListProperty that = new ListProperty(); + copyTo(that); + return that; + } + + protected void copyTo(final ListProperty that) { + copyTo(that); + that.values = new ArrayList(this.values); + } + /** * Gest the list of values. * @return the list of values diff --git a/src/main/java/ezvcard/property/Logo.java b/src/main/java/ezvcard/property/Logo.java index f7273670d..573577292 100644 --- a/src/main/java/ezvcard/property/Logo.java +++ b/src/main/java/ezvcard/property/Logo.java @@ -98,6 +98,14 @@ public Logo(String url, ImageType type) { super(url, type); } + private Logo() {} + + @Override + public Logo deepCopy() { + Logo that = new Logo(); + copyTo(that); + return that; + } /** * Creates a logo property. * @param data the binary data of the logo diff --git a/src/main/java/ezvcard/property/Mailer.java b/src/main/java/ezvcard/property/Mailer.java index 0f1b68a62..599014231 100644 --- a/src/main/java/ezvcard/property/Mailer.java +++ b/src/main/java/ezvcard/property/Mailer.java @@ -67,6 +67,13 @@ public Mailer(String emailClient) { super(emailClient); } + @Override + public Mailer deepCopy() { + Mailer that = new Mailer(getValue()); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V2_1, VCardVersion.V3_0); diff --git a/src/main/java/ezvcard/property/Member.java b/src/main/java/ezvcard/property/Member.java index 220c0e218..9d14d6bd9 100644 --- a/src/main/java/ezvcard/property/Member.java +++ b/src/main/java/ezvcard/property/Member.java @@ -80,6 +80,13 @@ public Member(String uri) { super(uri); } + @Override + public Member deepCopy() { + Member that = new Member(getValue()); + copyTo(that); + return that; + } + /** * Creates a member property whose value is an email address. * @param email the email address diff --git a/src/main/java/ezvcard/property/Nickname.java b/src/main/java/ezvcard/property/Nickname.java index e20fbed75..4dcc65a6e 100644 --- a/src/main/java/ezvcard/property/Nickname.java +++ b/src/main/java/ezvcard/property/Nickname.java @@ -68,6 +68,13 @@ public Set _supportedVersions() { return EnumSet.of(VCardVersion.V3_0, VCardVersion.V4_0); } + @Override + public Nickname deepCopy() { + Nickname that = new Nickname(); + copyTo(that); + return that; + } + /** * Gets the TYPE parameter. *

diff --git a/src/main/java/ezvcard/property/Note.java b/src/main/java/ezvcard/property/Note.java index 794dc69f6..2d1433476 100644 --- a/src/main/java/ezvcard/property/Note.java +++ b/src/main/java/ezvcard/property/Note.java @@ -64,6 +64,13 @@ public Note(String note) { super(note); } + @Override + public Note deepCopy() { + Note that = new Note(this.value); + copyTo(that); + return that; + } + @Override public List getPids() { return super.getPids(); diff --git a/src/main/java/ezvcard/property/OrgDirectory.java b/src/main/java/ezvcard/property/OrgDirectory.java index 8429e243d..9eb408270 100644 --- a/src/main/java/ezvcard/property/OrgDirectory.java +++ b/src/main/java/ezvcard/property/OrgDirectory.java @@ -68,6 +68,13 @@ public OrgDirectory(String uri) { super(uri); } + @Override + public OrgDirectory deepCopy() { + OrgDirectory that = new OrgDirectory(getValue()); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V4_0); diff --git a/src/main/java/ezvcard/property/Organization.java b/src/main/java/ezvcard/property/Organization.java index cecc197c5..6ea237b33 100644 --- a/src/main/java/ezvcard/property/Organization.java +++ b/src/main/java/ezvcard/property/Organization.java @@ -67,6 +67,13 @@ public String getLanguage() { return super.getLanguage(); } + @Override + public Organization deepCopy() { + Organization that = new Organization(); + copyTo(that); + return that; + } + @Override public void setLanguage(String language) { super.setLanguage(language); diff --git a/src/main/java/ezvcard/property/Photo.java b/src/main/java/ezvcard/property/Photo.java index 5ac73ecd4..f9fe95946 100644 --- a/src/main/java/ezvcard/property/Photo.java +++ b/src/main/java/ezvcard/property/Photo.java @@ -98,6 +98,13 @@ public Photo(String url, ImageType type) { super(url, type); } + @Override + public Photo deepCopy() { + Photo that = new Photo(getUrl(), getContentType()); + copyTo(that); + return that; + } + /** * Creates a photo property. * @param data the binary data of the photo diff --git a/src/main/java/ezvcard/property/PlaceProperty.java b/src/main/java/ezvcard/property/PlaceProperty.java index 1adcef4e8..2b40df3a6 100644 --- a/src/main/java/ezvcard/property/PlaceProperty.java +++ b/src/main/java/ezvcard/property/PlaceProperty.java @@ -55,6 +55,19 @@ public PlaceProperty() { //empty } + @Override public PlaceProperty deepCopy() { + PlaceProperty that = new PlaceProperty(); + copyTo(that); + return that; + } + + protected void copyTo(final PlaceProperty that) { + super.copyTo(that); + that.geoUri = this.geoUri; // immutable + that.uri = this.uri; + that.text = this.text; + } + /** * Creates a new place property. * @param latitude the latitude coordinate of the place diff --git a/src/main/java/ezvcard/property/ProductId.java b/src/main/java/ezvcard/property/ProductId.java index a6522f6b0..b7c411caa 100644 --- a/src/main/java/ezvcard/property/ProductId.java +++ b/src/main/java/ezvcard/property/ProductId.java @@ -67,6 +67,13 @@ public ProductId(String prodId) { super(prodId); } + @Override + public ProductId deepCopy() { + ProductId that = new ProductId(getValue()); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V3_0, VCardVersion.V4_0); diff --git a/src/main/java/ezvcard/property/Profile.java b/src/main/java/ezvcard/property/Profile.java index ca0fc7980..ce81498ec 100644 --- a/src/main/java/ezvcard/property/Profile.java +++ b/src/main/java/ezvcard/property/Profile.java @@ -66,6 +66,13 @@ public Profile() { super("VCARD"); } + @Override + public Profile deepCopy() { + Profile that = new Profile(); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V3_0); diff --git a/src/main/java/ezvcard/property/RawProperty.java b/src/main/java/ezvcard/property/RawProperty.java index a276ada5c..4d74ca4fd 100644 --- a/src/main/java/ezvcard/property/RawProperty.java +++ b/src/main/java/ezvcard/property/RawProperty.java @@ -49,6 +49,13 @@ public RawProperty(String propertyName, String value) { this(propertyName, value, null); } + @Override + public RawProperty deepCopy() { + RawProperty that = new RawProperty(this.propertyName, this.value); + copyTo(that); + return that; + } + /** * Creates a raw property. * @param propertyName the property name (e.g. "X-GENDER") diff --git a/src/main/java/ezvcard/property/Related.java b/src/main/java/ezvcard/property/Related.java index 34251cbe6..ae69a93b7 100644 --- a/src/main/java/ezvcard/property/Related.java +++ b/src/main/java/ezvcard/property/Related.java @@ -89,6 +89,15 @@ public Related() { //empty } + @Override + public Related deepCopy() { + Related that = new Related(); + copyTo(that); + that.uri = this.uri; + that.text = this.text; + return that; + } + /** * Creates a related property. * @param uri the URI representing the person diff --git a/src/main/java/ezvcard/property/Revision.java b/src/main/java/ezvcard/property/Revision.java index 4f0b3cd91..fe309361d 100644 --- a/src/main/java/ezvcard/property/Revision.java +++ b/src/main/java/ezvcard/property/Revision.java @@ -64,6 +64,13 @@ public Revision(Date date) { super(date); } + @Override + public Revision deepCopy() { + Revision that = new Revision(new Date(getValue().getTime())); + copyTo(that); + return that; + } + /** * Creates a revision property whose value is the current time. * @return the property diff --git a/src/main/java/ezvcard/property/Role.java b/src/main/java/ezvcard/property/Role.java index 8a8965ced..48051e3f0 100644 --- a/src/main/java/ezvcard/property/Role.java +++ b/src/main/java/ezvcard/property/Role.java @@ -64,6 +64,13 @@ public Role(String role) { super(role); } + @Override + public Role deepCopy() { + Role that = new Role(getValue()); + copyTo(that); + return that; + } + @Override public String getLanguage() { return super.getLanguage(); diff --git a/src/main/java/ezvcard/property/SimpleProperty.java b/src/main/java/ezvcard/property/SimpleProperty.java index 782f2bcef..016e3fcef 100644 --- a/src/main/java/ezvcard/property/SimpleProperty.java +++ b/src/main/java/ezvcard/property/SimpleProperty.java @@ -51,6 +51,13 @@ public SimpleProperty(T value) { this.value = value; } + @Override + public SimpleProperty deepCopy() { + SimpleProperty that = new SimpleProperty(value); + copyTo(that); + return that; + } + /** * Gets the value of this property. * @return the value or null if not set diff --git a/src/main/java/ezvcard/property/SortString.java b/src/main/java/ezvcard/property/SortString.java index ea91928a8..b4584ff3f 100644 --- a/src/main/java/ezvcard/property/SortString.java +++ b/src/main/java/ezvcard/property/SortString.java @@ -92,6 +92,13 @@ public SortString(String sortString) { super(sortString); } + @Override + public SortString deepCopy() { + SortString that = new SortString(getValue()); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V3_0); diff --git a/src/main/java/ezvcard/property/Sound.java b/src/main/java/ezvcard/property/Sound.java index ab9098acf..ef79d7bca 100644 --- a/src/main/java/ezvcard/property/Sound.java +++ b/src/main/java/ezvcard/property/Sound.java @@ -98,6 +98,13 @@ public Sound(String url, SoundType type) { super(url, type); } + @Override + public Sound deepCopy() { + Sound that = new Sound(getUrl(), getContentType()); + copyTo(that); + return that; + } + /** * Creates a sound property. * @param data the binary data of the sound file diff --git a/src/main/java/ezvcard/property/Source.java b/src/main/java/ezvcard/property/Source.java index 0e8a37cf4..2a14b96eb 100644 --- a/src/main/java/ezvcard/property/Source.java +++ b/src/main/java/ezvcard/property/Source.java @@ -65,6 +65,13 @@ public Source(String url) { super(url); } + @Override + public Source deepCopy() { + Source that = new Source(getValue()); + copyTo(that); + return that; + } + @Override public List getPids() { return super.getPids(); diff --git a/src/main/java/ezvcard/property/SourceDisplayText.java b/src/main/java/ezvcard/property/SourceDisplayText.java index ac03efc52..315b4b12c 100644 --- a/src/main/java/ezvcard/property/SourceDisplayText.java +++ b/src/main/java/ezvcard/property/SourceDisplayText.java @@ -67,6 +67,13 @@ public SourceDisplayText(String displayText) { super(displayText); } + @Override + public SourceDisplayText deepCopy() { + SourceDisplayText that = new SourceDisplayText(getValue()); + copyTo(that); + return that; + } + @Override public Set _supportedVersions() { return EnumSet.of(VCardVersion.V3_0); diff --git a/src/main/java/ezvcard/property/StructuredName.java b/src/main/java/ezvcard/property/StructuredName.java index 40e6b98b0..ec492bb29 100644 --- a/src/main/java/ezvcard/property/StructuredName.java +++ b/src/main/java/ezvcard/property/StructuredName.java @@ -69,6 +69,18 @@ public class StructuredName extends VCardProperty implements HasAltId { private List prefixes = new ArrayList(); private List suffixes = new ArrayList(); + @Override + public StructuredName deepCopy() { + StructuredName that = new StructuredName(); + copyTo(that); + that.family = this.family; + that.given = this.given; + that.additional = new ArrayList(this.additional); + that.prefixes = new ArrayList(this.prefixes); + that.suffixes = new ArrayList(this.suffixes); + return that; + } + /** * Gets the family name (aka "last name"). * @return the family name or null if not set diff --git a/src/main/java/ezvcard/property/Telephone.java b/src/main/java/ezvcard/property/Telephone.java index 6e07bd4a7..551c1cf68 100644 --- a/src/main/java/ezvcard/property/Telephone.java +++ b/src/main/java/ezvcard/property/Telephone.java @@ -77,6 +77,15 @@ public class Telephone extends VCardProperty implements HasAltId { private String text; private TelUri uri; + @Override + public Telephone deepCopy() { + Telephone that = new Telephone(text); + copyTo(that); + that.text = this.text; + that.uri = this.uri; + return that; + } + /** * Creates a telephone property. * @param text the telephone number (e.g. "(123) 555-6789") diff --git a/src/main/java/ezvcard/property/TextListProperty.java b/src/main/java/ezvcard/property/TextListProperty.java index cda1d8821..a173d6ea4 100644 --- a/src/main/java/ezvcard/property/TextListProperty.java +++ b/src/main/java/ezvcard/property/TextListProperty.java @@ -34,5 +34,11 @@ * @author Michael Angstadt */ public class TextListProperty extends ListProperty { - //empty + + @Override + public TextListProperty deepCopy() { + TextListProperty that = new TextListProperty(); + copyTo(that); + return that; + } } diff --git a/src/main/java/ezvcard/property/TextProperty.java b/src/main/java/ezvcard/property/TextProperty.java index f273fda5f..d08533303 100644 --- a/src/main/java/ezvcard/property/TextProperty.java +++ b/src/main/java/ezvcard/property/TextProperty.java @@ -41,4 +41,11 @@ public class TextProperty extends SimpleProperty { public TextProperty(String value) { super(value); } + + @Override + public TextProperty deepCopy() { + TextProperty that = new TextProperty(getValue()); + copyTo(that); + return that; + } } diff --git a/src/main/java/ezvcard/property/Timezone.java b/src/main/java/ezvcard/property/Timezone.java index 8a8fe8fb4..155e9964b 100644 --- a/src/main/java/ezvcard/property/Timezone.java +++ b/src/main/java/ezvcard/property/Timezone.java @@ -73,6 +73,13 @@ public class Timezone extends VCardProperty implements HasAltId { private UtcOffset offset; private String text; + @Override + public Timezone deepCopy() { + Timezone that = new Timezone(offset, text); + copyTo(that); + return that; + } + /** * Creates a timezone property. * @param text a free-form string representing the timezone, preferably a diff --git a/src/main/java/ezvcard/property/Title.java b/src/main/java/ezvcard/property/Title.java index 33b1f7b3a..c18419bae 100644 --- a/src/main/java/ezvcard/property/Title.java +++ b/src/main/java/ezvcard/property/Title.java @@ -65,6 +65,13 @@ public Title(String title) { super(title); } + @Override + public Title deepCopy() { + Title that = new Title(getValue()); + copyTo(that); + return that; + } + @Override public String getLanguage() { return super.getLanguage(); diff --git a/src/main/java/ezvcard/property/Uid.java b/src/main/java/ezvcard/property/Uid.java index 15b77f5d7..a013463a1 100644 --- a/src/main/java/ezvcard/property/Uid.java +++ b/src/main/java/ezvcard/property/Uid.java @@ -68,6 +68,13 @@ public Uid(String uid) { super(uid); } + @Override + public Uid deepCopy() { + Uid that = new Uid(getValue()); + copyTo(that); + return that; + } + /** * Creates a UID property that contains a random UUID URI. * @return the property diff --git a/src/main/java/ezvcard/property/UriProperty.java b/src/main/java/ezvcard/property/UriProperty.java index 0b8b41330..f71c0775b 100644 --- a/src/main/java/ezvcard/property/UriProperty.java +++ b/src/main/java/ezvcard/property/UriProperty.java @@ -41,4 +41,11 @@ public class UriProperty extends TextProperty { public UriProperty(String uri) { super(uri); } + + @Override + public UriProperty deepCopy() { + UriProperty that = new UriProperty(getValue()); + copyTo(that); + return that; + } } diff --git a/src/main/java/ezvcard/property/Url.java b/src/main/java/ezvcard/property/Url.java index f269da1d2..40fcb9a91 100644 --- a/src/main/java/ezvcard/property/Url.java +++ b/src/main/java/ezvcard/property/Url.java @@ -64,6 +64,13 @@ public Url(String url) { super(url); } + @Override + public Url deepCopy() { + Url that = new Url(getValue()); + copyTo(that); + return that; + } + /** * Gets the MEDIATYPE parameter. *

diff --git a/src/main/java/ezvcard/property/VCardProperty.java b/src/main/java/ezvcard/property/VCardProperty.java index 59ad6c0e9..017fab35d 100644 --- a/src/main/java/ezvcard/property/VCardProperty.java +++ b/src/main/java/ezvcard/property/VCardProperty.java @@ -10,6 +10,7 @@ import ezvcard.VCardVersion; import ezvcard.Warning; import ezvcard.parameter.VCardParameters; +import lombok.*; /* Copyright (c) 2012-2015, Michael Angstadt @@ -336,4 +337,19 @@ Integer getIndex() { void setIndex(Integer index) { parameters.setIndex(index); } + + /** + * Returns a deep copy of this property such that + * that.deepCopy().equals(that), and modifications made + * to the copy are not shared by the copied instance. + */ + public abstract VCardProperty deepCopy(); + + /** + * helper method for implementors of deepCopy(). + */ + protected void copyTo(VCardProperty that) { + that.group = this.group; + that.parameters = new VCardParameters(this.parameters); + } } \ No newline at end of file diff --git a/src/main/java/ezvcard/property/Xml.java b/src/main/java/ezvcard/property/Xml.java index 883fd73c6..4a6d44124 100644 --- a/src/main/java/ezvcard/property/Xml.java +++ b/src/main/java/ezvcard/property/Xml.java @@ -75,6 +75,13 @@ public Xml(String xml) throws SAXException { this(XmlUtils.toDocument(xml)); } + @Override + public Xml deepCopy() { + Xml that = new Xml(getValue()); + copyTo(that); + return that; + } + /** * Creates an XML property. * @param element the XML element to use as the property's value (the diff --git a/src/test/java/ezvcard/VCardTest.java b/src/test/java/ezvcard/VCardTest.java index 5b5ec5471..d51fb24f7 100644 --- a/src/test/java/ezvcard/VCardTest.java +++ b/src/test/java/ezvcard/VCardTest.java @@ -242,6 +242,13 @@ public String getAltId() { public void setAltId(String altId) { this.altId = altId; } + + @Override + public VCardProperty deepCopy() { + HasAltIdImpl that = new HasAltIdImpl(altId); + copyTo(that); + return that; + } } private class VCardPropertyImpl extends VCardProperty { @@ -254,5 +261,14 @@ public void _validate(List warnings, VCardVersion version, VCard vcard) validateVCard = vcard; warnings.add(new Warning(0)); } + + @Override + public VCardProperty deepCopy() { + VCardPropertyImpl that = new VCardPropertyImpl(); + copyTo(that); + that.validateVersion = this.validateVersion; + that.validateVCard = this.validateVCard.deepCopy(); + return that; + } } } diff --git a/src/test/java/ezvcard/ValidationWarningsTest.java b/src/test/java/ezvcard/ValidationWarningsTest.java index 78dc2b921..932f115c7 100644 --- a/src/test/java/ezvcard/ValidationWarningsTest.java +++ b/src/test/java/ezvcard/ValidationWarningsTest.java @@ -90,14 +90,23 @@ public void toString_() { } private class TestProperty1 extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return new TestProperty1(); + } } private class TestProperty2 extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return new TestProperty1(); + } } private class TestProperty3 extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return new TestProperty1(); + } } } diff --git a/src/test/java/ezvcard/io/AgeType.java b/src/test/java/ezvcard/io/AgeType.java index 85d44d402..f69636929 100644 --- a/src/test/java/ezvcard/io/AgeType.java +++ b/src/test/java/ezvcard/io/AgeType.java @@ -49,6 +49,11 @@ public AgeType(int age) { this.age = age; } + @Override + public VCardProperty deepCopy() { + return new AgeType(age); + } + public static class AgeScribe extends VCardPropertyScribe { public AgeScribe() { super(AgeType.class, "X-AGE"); diff --git a/src/test/java/ezvcard/io/LuckyNumType.java b/src/test/java/ezvcard/io/LuckyNumType.java index 02e4c6096..292aa84c3 100644 --- a/src/test/java/ezvcard/io/LuckyNumType.java +++ b/src/test/java/ezvcard/io/LuckyNumType.java @@ -56,6 +56,13 @@ public LuckyNumType(int luckyNum) { this.luckyNum = luckyNum; } + @Override + public VCardProperty deepCopy() { + LuckyNumType that = new LuckyNumType(luckyNum); + copyTo(that); + return that; + } + public static class LuckyNumScribe extends VCardPropertyScribe { public LuckyNumScribe() { super(LuckyNumType.class, "X-LUCKY-NUM", new QName("http://luckynum.com", "lucky-num")); diff --git a/src/test/java/ezvcard/io/MyFormattedNameType.java b/src/test/java/ezvcard/io/MyFormattedNameType.java index e6e70b781..f2b8320e4 100644 --- a/src/test/java/ezvcard/io/MyFormattedNameType.java +++ b/src/test/java/ezvcard/io/MyFormattedNameType.java @@ -50,6 +50,13 @@ public MyFormattedNameType(String value) { this.value = value; } + @Override + public MyFormattedNameType deepCopy() { + MyFormattedNameType that = new MyFormattedNameType(value); + copyTo(that); + return that; + } + public static class MyFormattedNameScribe extends VCardPropertyScribe { public MyFormattedNameScribe() { super(MyFormattedNameType.class, "FN"); diff --git a/src/test/java/ezvcard/io/SalaryType.java b/src/test/java/ezvcard/io/SalaryType.java index 594005c93..c6e35b535 100644 --- a/src/test/java/ezvcard/io/SalaryType.java +++ b/src/test/java/ezvcard/io/SalaryType.java @@ -50,6 +50,11 @@ public SalaryType(int salary) { this.salary = salary; } + @Override + public VCardProperty deepCopy() { + return new SalaryType(salary); + } + public static class SalaryScribe extends VCardPropertyScribe { public SalaryScribe() { super(SalaryType.class, "X-SALARY"); diff --git a/src/test/java/ezvcard/io/StreamWriterTest.java b/src/test/java/ezvcard/io/StreamWriterTest.java index e9ef7c977..d0d618ae3 100644 --- a/src/test/java/ezvcard/io/StreamWriterTest.java +++ b/src/test/java/ezvcard/io/StreamWriterTest.java @@ -310,6 +310,9 @@ public void close() throws IOException { } private class TestProperty extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return this; + } } } diff --git a/src/test/java/ezvcard/io/json/JCardReaderTest.java b/src/test/java/ezvcard/io/json/JCardReaderTest.java index 7f46a87fb..b2eb21e38 100644 --- a/src/test/java/ezvcard/io/json/JCardReaderTest.java +++ b/src/test/java/ezvcard/io/json/JCardReaderTest.java @@ -427,6 +427,11 @@ private static class TypeForTesting extends VCardProperty { public TypeForTesting(JCardValue value) { this.value = value; } + + @Override + public VCardProperty deepCopy() { + return new TypeForTesting(value); + } } private static class TypeForTestingScribe extends VCardPropertyScribe { diff --git a/src/test/java/ezvcard/io/json/JCardWriterTest.java b/src/test/java/ezvcard/io/json/JCardWriterTest.java index 9f959b0ad..5daac497e 100644 --- a/src/test/java/ezvcard/io/json/JCardWriterTest.java +++ b/src/test/java/ezvcard/io/json/JCardWriterTest.java @@ -383,6 +383,11 @@ private static class TestProperty extends VCardProperty { public TestProperty(JCardValue value) { this.value = value; } + + @Override + public VCardProperty deepCopy() { + return new TestProperty(value); + } } private static class TestScribe extends VCardPropertyScribe { diff --git a/src/test/java/ezvcard/io/scribe/BinaryPropertyScribeTest.java b/src/test/java/ezvcard/io/scribe/BinaryPropertyScribeTest.java index 7cdaf9276..5bcd747a7 100644 --- a/src/test/java/ezvcard/io/scribe/BinaryPropertyScribeTest.java +++ b/src/test/java/ezvcard/io/scribe/BinaryPropertyScribeTest.java @@ -328,6 +328,11 @@ protected BinaryTypeImpl _newInstance(byte[] data, ImageType contentType) { } private static class BinaryTypeImpl extends BinaryProperty { + @Override + public BinaryProperty deepCopy() { + return new BinaryTypeImpl(); + } + public BinaryTypeImpl() { super((String) null, null); } diff --git a/src/test/java/ezvcard/io/scribe/SimplePropertyScribeTest.java b/src/test/java/ezvcard/io/scribe/SimplePropertyScribeTest.java index 4653e1a11..ebee4db23 100644 --- a/src/test/java/ezvcard/io/scribe/SimplePropertyScribeTest.java +++ b/src/test/java/ezvcard/io/scribe/SimplePropertyScribeTest.java @@ -115,6 +115,11 @@ private static class TestProperty extends VCardProperty { public TestProperty(String value) { this.value = value; } + + @Override + public VCardProperty deepCopy() { + return new TestProperty(value); + } } private Check hasText(final String text) { diff --git a/src/test/java/ezvcard/io/scribe/VCardPropertyScribeTest.java b/src/test/java/ezvcard/io/scribe/VCardPropertyScribeTest.java index bc00cf0cc..6090221b7 100644 --- a/src/test/java/ezvcard/io/scribe/VCardPropertyScribeTest.java +++ b/src/test/java/ezvcard/io/scribe/VCardPropertyScribeTest.java @@ -516,5 +516,10 @@ public TestProperty(String value, VCardDataType parsedDataType) { this.value = value; this.parsedDataType = parsedDataType; } + + @Override + public VCardProperty deepCopy() { + return new TestProperty(value, parsedDataType); + } } } diff --git a/src/test/java/ezvcard/io/text/VCardReaderTest.java b/src/test/java/ezvcard/io/text/VCardReaderTest.java index 151f9ff78..707eff11d 100644 --- a/src/test/java/ezvcard/io/text/VCardReaderTest.java +++ b/src/test/java/ezvcard/io/text/VCardReaderTest.java @@ -539,6 +539,14 @@ public void nestedVCard_missing_vcard() throws Throwable { private static class Nested extends VCardProperty { private VCard vcard = new VCard(); //init this to a new VCard instance to test for the fact that this should be set to null + + @Override + public VCardProperty deepCopy() { + Nested that = new Nested(); + copyTo(that); + that.vcard = vcard.deepCopy(); + return that; + } } private static class NestedScribe extends VCardPropertyScribe { @@ -837,7 +845,10 @@ public void property_warning() throws Exception { } private static class WarningsProperty extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return new WarningsProperty(); + } } private static class WarningsScribe extends VCardPropertyScribe { @@ -984,6 +995,11 @@ private static class ValueProp extends VCardProperty { public ValueProp(VCardDataType dataType) { this.dataType = dataType; } + + @Override + public VCardProperty deepCopy() { + return new ValueProp(dataType); + } } private static class ValueScribe extends VCardPropertyScribe { diff --git a/src/test/java/ezvcard/io/text/VCardWriterTest.java b/src/test/java/ezvcard/io/text/VCardWriterTest.java index c0ae1fae3..734b8c94e 100644 --- a/src/test/java/ezvcard/io/text/VCardWriterTest.java +++ b/src/test/java/ezvcard/io/text/VCardWriterTest.java @@ -367,16 +367,28 @@ protected T _parseText(String value, VCardDataType dataType, VCardVersion versio } class DateProperty extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return this; + } } class DateTimeProperty extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return this; + } } class TimeProperty extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return this; + } } class DateAndOrTimeProperty extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return this; + } } VCard vcard = new VCard(); diff --git a/src/test/java/ezvcard/io/xml/XCardDocumentTest.java b/src/test/java/ezvcard/io/xml/XCardDocumentTest.java index c407a537d..c1302433d 100644 --- a/src/test/java/ezvcard/io/xml/XCardDocumentTest.java +++ b/src/test/java/ezvcard/io/xml/XCardDocumentTest.java @@ -895,7 +895,10 @@ private static XCardDocument read(String file) throws SAXException, IOException } private static class EmbeddedProperty extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return new EmbeddedProperty(); + } } private static class EmbeddedScribe extends VCardPropertyScribe { diff --git a/src/test/java/ezvcard/io/xml/XCardWriterTest.java b/src/test/java/ezvcard/io/xml/XCardWriterTest.java index 9f147d2b4..b635e7049 100644 --- a/src/test/java/ezvcard/io/xml/XCardWriterTest.java +++ b/src/test/java/ezvcard/io/xml/XCardWriterTest.java @@ -741,7 +741,10 @@ private void assertExample(VCard vcard, String exampleFileName) throws IOExcepti } private static class EmbeddedProperty extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return this; + } } private static class EmbeddedScribe extends VCardPropertyScribe { diff --git a/src/test/java/ezvcard/property/BinaryPropertyTest.java b/src/test/java/ezvcard/property/BinaryPropertyTest.java index 6fe362974..45c8e27ce 100644 --- a/src/test/java/ezvcard/property/BinaryPropertyTest.java +++ b/src/test/java/ezvcard/property/BinaryPropertyTest.java @@ -54,6 +54,11 @@ public void validate() { } private class BinaryTypeImpl extends BinaryProperty { + @Override + public BinaryProperty deepCopy() { + return new BinaryTypeImpl(); + } + public BinaryTypeImpl() { super((String) null, null); } diff --git a/src/test/java/ezvcard/property/CannotParseProperty.java b/src/test/java/ezvcard/property/CannotParseProperty.java index ea69a52b5..f3889f4a3 100644 --- a/src/test/java/ezvcard/property/CannotParseProperty.java +++ b/src/test/java/ezvcard/property/CannotParseProperty.java @@ -1,5 +1,8 @@ package ezvcard.property; public class CannotParseProperty extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return new CannotParseProperty(); + } } diff --git a/src/test/java/ezvcard/property/FavoriteColors.java b/src/test/java/ezvcard/property/FavoriteColors.java index cb81aeb0f..82f7f012b 100644 --- a/src/test/java/ezvcard/property/FavoriteColors.java +++ b/src/test/java/ezvcard/property/FavoriteColors.java @@ -75,6 +75,14 @@ protected void _validate(List warnings, VCardVersion version, VCard vca } } + @Override + public VCardProperty deepCopy() { + FavoriteColors that = new FavoriteColors(); + copyTo(that); + that.colors = new ArrayList(this.colors); + return that; + } + public static class FavoriteColorsScribe extends VCardPropertyScribe { public FavoriteColorsScribe() { super(FavoriteColors.class, "X-FAV-COLORS"); diff --git a/src/test/java/ezvcard/property/SkipMeProperty.java b/src/test/java/ezvcard/property/SkipMeProperty.java index c44e6596f..519fbca20 100644 --- a/src/test/java/ezvcard/property/SkipMeProperty.java +++ b/src/test/java/ezvcard/property/SkipMeProperty.java @@ -32,5 +32,8 @@ * @author Michael Angstadt */ public class SkipMeProperty extends VCardProperty { - //empty + @Override + public VCardProperty deepCopy() { + return this; + } } diff --git a/src/test/java/ezvcard/property/VCardPropertyTest.java b/src/test/java/ezvcard/property/VCardPropertyTest.java index 847c6350f..f7705cbb9 100644 --- a/src/test/java/ezvcard/property/VCardPropertyTest.java +++ b/src/test/java/ezvcard/property/VCardPropertyTest.java @@ -96,7 +96,10 @@ public void compareTo() { } private class VCardTypeImpl extends VCardProperty { - //empty + @Override + public VCardTypeImpl deepCopy() { + return new VCardTypeImpl(); + } } private class ValidateType extends VCardProperty { @@ -111,5 +114,12 @@ public Set _supportedVersions() { public void _validate(List warnings, VCardVersion version, VCard vcard) { validateCalled = true; } + + @Override + public ValidateType deepCopy() { + ValidateType that = new ValidateType(); + copyTo(that); + return that; + } } }