diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Categorization.java b/ccm-core/src/main/java/org/libreccm/categorization/Categorization.java index 8cf99b457..f1126e77d 100644 --- a/ccm-core/src/main/java/org/libreccm/categorization/Categorization.java +++ b/ccm-core/src/main/java/org/libreccm/categorization/Categorization.java @@ -158,7 +158,7 @@ public class Categorization implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + if (!(obj instanceof Categorization)) { return false; } final Categorization other = (Categorization) obj; diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Category.java b/ccm-core/src/main/java/org/libreccm/categorization/Category.java index 8d665c7e8..f4214b076 100644 --- a/ccm-core/src/main/java/org/libreccm/categorization/Category.java +++ b/ccm-core/src/main/java/org/libreccm/categorization/Category.java @@ -308,7 +308,7 @@ public class Category extends CcmObject implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + if (!(obj instanceof Category)) { return false; } final Category other = (Category) obj; @@ -360,11 +360,11 @@ public class Category extends CcmObject implements Serializable { + "categoryOrder = %d%s", uniqueId, name, - title.toString(), + Objects.toString(title), enabled, visible, abstractCategory, - parentCategory, + Objects.toString(parentCategory), categoryOrder, data)); } diff --git a/ccm-core/src/main/java/org/libreccm/categorization/Domain.java b/ccm-core/src/main/java/org/libreccm/categorization/Domain.java index 304a56e4f..016ef2244 100644 --- a/ccm-core/src/main/java/org/libreccm/categorization/Domain.java +++ b/ccm-core/src/main/java/org/libreccm/categorization/Domain.java @@ -100,10 +100,10 @@ public class Domain extends CcmObject implements Serializable { */ @Embedded @AssociationOverride( - name = "values", - joinTable = @JoinTable(name = "domain_titles", - joinColumns = { - @JoinColumn(name = "object_id")})) + name = "values", + joinTable = @JoinTable(name = "domain_titles", + joinColumns = { + @JoinColumn(name = "object_id")})) private LocalizedString title; /** @@ -111,10 +111,10 @@ public class Domain extends CcmObject implements Serializable { */ @Embedded @AssociationOverride( - name = "values", - joinTable = @JoinTable(name = "domain_descriptions", - joinColumns = { - @JoinColumn(name = "object_id")})) + name = "values", + joinTable = @JoinTable(name = "domain_descriptions", + joinColumns = { + @JoinColumn(name = "object_id")})) private LocalizedString description; /** @@ -192,11 +192,19 @@ public class Domain extends CcmObject implements Serializable { } public Date getReleased() { - return new Date(released.getTime()); + if (released == null) { + return null; + } else { + return new Date(released.getTime()); + } } public void setReleased(final Date released) { - this.released = new Date(released.getTime()); + if (released == null) { + this.released = null; + } else { + this.released = new Date(released.getTime()); + } } public Category getRoot() { @@ -213,6 +221,7 @@ public class Domain extends CcmObject implements Serializable { * {@link DomainManager}. * * @return An unmodifiable list of the owners of this { + * * @Domain} * * @see #owners @@ -254,7 +263,7 @@ public class Domain extends CcmObject implements Serializable { @Override public int hashCode() { - int hash = 3; + int hash = super.hashCode(); hash = 41 * hash + Objects.hashCode(domainKey); hash = 41 * hash + Objects.hashCode(uri); hash = 41 * hash + Objects.hashCode(title); @@ -271,10 +280,14 @@ public class Domain extends CcmObject implements Serializable { "PMD.StdCyclomaticComplexity", "PMD.ModifiedCyclomaticComplexity"}) public boolean equals(final Object obj) { + if (!super.equals(obj)) { + return false; + } + if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + if (!(obj instanceof Domain)) { return false; } final Domain other = (Domain) obj; @@ -311,19 +324,19 @@ public class Domain extends CcmObject implements Serializable { @Override public String toString(final String data) { return String.format( - ", domainKey = \"%s\", " - + "uri = \"%s\", " - + "title = \"%s\", " - + "version = \"%s\", " - + "released = %tF % getChildComponents() { - return Collections.unmodifiableList(childComponents); + if (childComponents == null) { + return null; + } else { + return Collections.unmodifiableList(childComponents); + } } protected void setChildComponents(final List childComponents) { @@ -158,7 +162,12 @@ public class Component extends CcmObject implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof Component)) { return false; } final Component other = (Component) obj; diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/DataDrivenSelect.java b/ccm-core/src/main/java/org/libreccm/formbuilder/DataDrivenSelect.java index 25b48a65b..dc54a7bf7 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/DataDrivenSelect.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/DataDrivenSelect.java @@ -70,7 +70,12 @@ public class DataDrivenSelect extends Widget implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof DataDrivenSelect)) { return false; } final DataDrivenSelect other = (DataDrivenSelect) obj; diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/FormSection.java b/ccm-core/src/main/java/org/libreccm/formbuilder/FormSection.java index 1671cca98..21d3562b0 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/FormSection.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/FormSection.java @@ -18,8 +18,6 @@ */ package org.libreccm.formbuilder; -import org.hibernate.annotations.CollectionId; - import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; @@ -89,7 +87,12 @@ public class FormSection extends Component implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof FormSection)) { return false; } final FormSection other = (FormSection) obj; diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/Listener.java b/ccm-core/src/main/java/org/libreccm/formbuilder/Listener.java index ccb34856f..8a14cb143 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/Listener.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/Listener.java @@ -85,11 +85,16 @@ public class Listener extends CcmObject implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof Listener)) { return false; } final Listener other = (Listener) obj; - if (other.canEqual(this)) { + if (!other.canEqual(this)) { return false; } @@ -99,14 +104,11 @@ public class Listener extends CcmObject implements Serializable { if (!Objects.equals(attributeString, other.getAttributeString())) { return false; } - if (!Objects.equals(widget, other.getWidget())) { - return false; - } - return true; + return Objects.equals(widget, other.getWidget()); } @Override - public boolean canEqual(Object obj) { + public boolean canEqual(final Object obj) { return obj instanceof Listener; } diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/MetaObject.java b/ccm-core/src/main/java/org/libreccm/formbuilder/MetaObject.java index 7f629e90c..241a77b87 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/MetaObject.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/MetaObject.java @@ -96,7 +96,12 @@ public class MetaObject extends CcmObject implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof MetaObject)) { return false; } final MetaObject other = (MetaObject) obj; diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/ObjectType.java b/ccm-core/src/main/java/org/libreccm/formbuilder/ObjectType.java index 51e2642a3..2a4263ebd 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/ObjectType.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/ObjectType.java @@ -61,7 +61,7 @@ public class ObjectType extends CcmObject implements Serializable { @Override public int hashCode() { - int hash = 7; + int hash = super.hashCode(); hash = 61 * hash + Objects.hashCode(appName); hash = 61 * hash + Objects.hashCode(className); return hash; @@ -72,7 +72,12 @@ public class ObjectType extends CcmObject implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof ObjectType)) { return false; } final ObjectType other = (ObjectType) obj; diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/Option.java b/ccm-core/src/main/java/org/libreccm/formbuilder/Option.java index 11d01cc15..553e1259c 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/Option.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/Option.java @@ -80,7 +80,12 @@ public class Option extends Component implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof Option)) { return false; } final Option other = (Option) obj; diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/PersistentDataQuery.java b/ccm-core/src/main/java/org/libreccm/formbuilder/PersistentDataQuery.java index 971bd7023..b500cae52 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/PersistentDataQuery.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/PersistentDataQuery.java @@ -100,7 +100,12 @@ public class PersistentDataQuery extends CcmObject implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof PersistentDataQuery)) { return false; } final PersistentDataQuery other = (PersistentDataQuery) obj; diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/ProcessListener.java b/ccm-core/src/main/java/org/libreccm/formbuilder/ProcessListener.java index 6ade2933a..cd4811f25 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/ProcessListener.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/ProcessListener.java @@ -126,7 +126,12 @@ public class ProcessListener extends CcmObject implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof ProcessListener)) { return false; } final ProcessListener other = (ProcessListener) obj; diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/Widget.java b/ccm-core/src/main/java/org/libreccm/formbuilder/Widget.java index 0e90577ba..c7f356dc2 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/Widget.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/Widget.java @@ -18,7 +18,6 @@ */ package org.libreccm.formbuilder; - import java.io.Serializable; import java.util.Collections; import java.util.List; @@ -51,7 +50,7 @@ public class Widget extends Component implements Serializable { @OneToOne private WidgetLabel label; - + @OneToMany(mappedBy = "widget") private List listeners; @@ -88,7 +87,11 @@ public class Widget extends Component implements Serializable { } public List getListeners() { - return Collections.unmodifiableList(listeners); + if (listeners == null) { + return null; + } else { + return Collections.unmodifiableList(listeners); + } } protected void setListeners(final List listeners) { @@ -98,12 +101,11 @@ public class Widget extends Component implements Serializable { protected void addListener(final Listener listener) { listeners.add(listener); } - + protected void removeListener(final Listener listener) { listeners.remove(listener); } - - + @Override public int hashCode() { int hash = super.hashCode(); @@ -120,7 +122,12 @@ public class Widget extends Component implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof Widget)) { return false; } final Widget other = (Widget) obj; @@ -140,9 +147,14 @@ public class Widget extends Component implements Serializable { if (!Objects.equals(label, other.getLabel())) { return false; } - + return Objects.equals(listeners, other.getListeners()); } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof Widget; + } @Override public String toString(final String data) { diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/WidgetLabel.java b/ccm-core/src/main/java/org/libreccm/formbuilder/WidgetLabel.java index d6f711567..f9a48f601 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/WidgetLabel.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/WidgetLabel.java @@ -59,7 +59,12 @@ public class WidgetLabel extends Component implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof WidgetLabel)) { return false; } final WidgetLabel other = (WidgetLabel) obj; diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/actions/ConfirmEmailListener.java b/ccm-core/src/main/java/org/libreccm/formbuilder/actions/ConfirmEmailListener.java index a434e5566..7b9878a5c 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/actions/ConfirmEmailListener.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/actions/ConfirmEmailListener.java @@ -20,8 +20,8 @@ import org.libreccm.formbuilder.ProcessListener; @Entity @Table(name = "formbuilder_confirm_email_listener") public class ConfirmEmailListener - extends ProcessListener - implements Serializable { + extends ProcessListener + implements Serializable { private static final long serialVersionUID = -7009695795355273248L; @@ -73,7 +73,12 @@ public class ConfirmEmailListener if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof ConfirmEmailListener)) { return false; } final ConfirmEmailListener other = (ConfirmEmailListener) obj; @@ -98,7 +103,7 @@ public class ConfirmEmailListener @Override public String toString(final String data) { return super.toString(String.format(", fromEmail = \"%s\"," - + "subject = \"%s\"%s", + + "subject = \"%s\"%s", fromEmail, subject, data)); diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/actions/ConfirmRedirectListener.java b/ccm-core/src/main/java/org/libreccm/formbuilder/actions/ConfirmRedirectListener.java index ca61bbf5b..1baff323d 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/actions/ConfirmRedirectListener.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/actions/ConfirmRedirectListener.java @@ -19,11 +19,11 @@ import org.libreccm.formbuilder.ProcessListener; @Entity @Table(name = "formbuilder_confirm_redirect_listeners") public class ConfirmRedirectListener - extends ProcessListener - implements Serializable { + extends ProcessListener + implements Serializable { private static final long serialVersionUID = 7891034630202555922L; - + @Column(name = "url") private String url; @@ -47,22 +47,27 @@ public class ConfirmRedirectListener if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof ConfirmRedirectListener)) { return false; } final ConfirmRedirectListener other = (ConfirmRedirectListener) obj; if (!other.canEqual(this)) { return false; } - + return Objects.equals(this.url, other.url); } - + @Override public boolean canEqual(final Object obj) { return obj instanceof ConfirmRedirectListener; } - + @Override public String toString(final String data) { return super.toString(String.format(", url = \"%s\"%s", diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/actions/RemoteServerPostListener.java b/ccm-core/src/main/java/org/libreccm/formbuilder/actions/RemoteServerPostListener.java index ed7c308e7..734123d49 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/actions/RemoteServerPostListener.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/actions/RemoteServerPostListener.java @@ -45,7 +45,12 @@ public class RemoteServerPostListener if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof RemoteServerPostListener)) { return false; } final RemoteServerPostListener other = (RemoteServerPostListener) obj; @@ -53,7 +58,12 @@ public class RemoteServerPostListener return false; } - return Objects.equals(this.remoteUrl, other.remoteUrl); + return Objects.equals(this.remoteUrl, other.getRemoteUrl()); + } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof RemoteServerPostListener; } @Override diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/actions/SimpleEmailListener.java b/ccm-core/src/main/java/org/libreccm/formbuilder/actions/SimpleEmailListener.java index 288e3056e..4a1cc9482 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/actions/SimpleEmailListener.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/actions/SimpleEmailListener.java @@ -62,7 +62,12 @@ public class SimpleEmailListener if (!super.equals(obj)) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof SimpleEmailListener)) { return false; } final SimpleEmailListener other = (SimpleEmailListener) obj; diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/actions/TemplateEmailListener.java b/ccm-core/src/main/java/org/libreccm/formbuilder/actions/TemplateEmailListener.java index 1875a541e..f00da49f5 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/actions/TemplateEmailListener.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/actions/TemplateEmailListener.java @@ -20,8 +20,8 @@ import org.libreccm.formbuilder.ProcessListener; @Entity @Table(name = "formbuilder_template_email_listeners") public class TemplateEmailListener - extends ProcessListener - implements Serializable { + extends ProcessListener + implements Serializable { private static final long serialVersionUID = -4476860960485494976L; @@ -62,9 +62,9 @@ public class TemplateEmailListener @Override public int hashCode() { int hash = super.hashCode(); - hash = 67 * hash + Objects.hashCode(this.recipient); - hash = 67 * hash + Objects.hashCode(this.subject); - hash = 67 * hash + Objects.hashCode(this.body); + hash = 67 * hash + Objects.hashCode(recipient); + hash = 67 * hash + Objects.hashCode(subject); + hash = 67 * hash + Objects.hashCode(body); return hash; } @@ -73,7 +73,12 @@ public class TemplateEmailListener if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof TemplateEmailListener)) { return false; } final TemplateEmailListener other = (TemplateEmailListener) obj; @@ -81,13 +86,13 @@ public class TemplateEmailListener return false; } - if (!Objects.equals(this.recipient, other.recipient)) { + if (!Objects.equals(recipient, other.getRecipient())) { return false; } - if (!Objects.equals(this.subject, other.subject)) { + if (!Objects.equals(subject, other.getSubject())) { return false; } - return Objects.equals(this.body, other.body); + return Objects.equals(body, other.getBody()); } @Override @@ -98,7 +103,7 @@ public class TemplateEmailListener @Override public String toString(final String data) { return super.toString(String.format(", recipient = \"%s\", " - + "subject = \"%s\"%s", + + "subject = \"%s\"%s", recipient, subject, data)); diff --git a/ccm-core/src/main/java/org/libreccm/formbuilder/actions/XmlEmailListener.java b/ccm-core/src/main/java/org/libreccm/formbuilder/actions/XmlEmailListener.java index d8a33be0e..60c410c54 100644 --- a/ccm-core/src/main/java/org/libreccm/formbuilder/actions/XmlEmailListener.java +++ b/ccm-core/src/main/java/org/libreccm/formbuilder/actions/XmlEmailListener.java @@ -24,7 +24,7 @@ public class XmlEmailListener extends ProcessListener implements Serializable { @Column(name = "recipient") private String recipient; - + @Column(name = "subject") private String subject; @@ -57,7 +57,12 @@ public class XmlEmailListener extends ProcessListener implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof XmlEmailListener)) { return false; } final XmlEmailListener other = (XmlEmailListener) obj; @@ -79,7 +84,7 @@ public class XmlEmailListener extends ProcessListener implements Serializable { @Override public String toString(final String data) { return super.toString(String.format(", recipient = \"%s\", " - + "subject = \"%s\"%s", + + "subject = \"%s\"%s", recipient, subject, data)); diff --git a/ccm-core/src/main/java/org/libreccm/l10n/LocalizedString.java b/ccm-core/src/main/java/org/libreccm/l10n/LocalizedString.java index a120861ee..b7da4f1e3 100644 --- a/ccm-core/src/main/java/org/libreccm/l10n/LocalizedString.java +++ b/ccm-core/src/main/java/org/libreccm/l10n/LocalizedString.java @@ -23,6 +23,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Set; import javax.persistence.Column; @@ -158,6 +159,34 @@ public class LocalizedString implements Serializable { return values.keySet(); } + @Override + public int hashCode() { + int hash = 7; + hash = 41 * hash + Objects.hashCode(this.values); + return hash; + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (!(obj instanceof LocalizedString)) { + return false; + } + final LocalizedString other = (LocalizedString) obj; + if (!other.canEqual(this)) { + return false; + } + + return Objects.equals(values, other.getValues()); + } + + public boolean canEqual(final Object obj) { + return obj instanceof LocalizedString; + } + + @Override public String toString() { return String.format( @@ -165,7 +194,7 @@ public class LocalizedString implements Serializable { + "%s" + " }", super.toString(), - values.toString()); + Objects.toString(values)); } } diff --git a/ccm-core/src/main/java/org/libreccm/messaging/Attachment.java b/ccm-core/src/main/java/org/libreccm/messaging/Attachment.java index 489d2e887..fe05baea4 100644 --- a/ccm-core/src/main/java/org/libreccm/messaging/Attachment.java +++ b/ccm-core/src/main/java/org/libreccm/messaging/Attachment.java @@ -110,11 +110,19 @@ public class Attachment implements Serializable { } public byte[] getData() { - return Arrays.copyOf(data, data.length); + if (data == null) { + return null; + } else { + return Arrays.copyOf(data, data.length); + } } public void setData(byte[] data) { - this.data = Arrays.copyOf(data, data.length); + if (data == null) { + this.data = null; + } else { + this.data = Arrays.copyOf(data, data.length); + } } @Override @@ -135,7 +143,7 @@ public class Attachment implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + if (!(obj instanceof Attachment)) { return false; } final Attachment other = (Attachment) obj; diff --git a/ccm-core/src/main/java/org/libreccm/messaging/Message.java b/ccm-core/src/main/java/org/libreccm/messaging/Message.java index 470c0e40c..99b8f4b6c 100644 --- a/ccm-core/src/main/java/org/libreccm/messaging/Message.java +++ b/ccm-core/src/main/java/org/libreccm/messaging/Message.java @@ -111,11 +111,19 @@ public class Message extends CcmObject implements Serializable { } public Date getSent() { - return new Date(sent.getTime()); + if (sent == null) { + return null; + } else { + return new Date(sent.getTime()); + } } public void setSent(final Date sent) { - this.sent = new Date(sent.getTime()); + if (sent == null) { + this.sent = null; + } else { + this.sent = new Date(sent.getTime()); + } } public Message getInReplyTo() { @@ -127,7 +135,11 @@ public class Message extends CcmObject implements Serializable { } public List getReplies() { - return Collections.unmodifiableList(replies); + if (replies == null) { + return null; + } else { + return Collections.unmodifiableList(replies); + } } protected void setReplies(final List replies) { @@ -143,7 +155,11 @@ public class Message extends CcmObject implements Serializable { } public List getAttachments() { - return Collections.unmodifiableList(attachments); + if (attachments == null) { + return null; + } else { + return Collections.unmodifiableList(attachments); + } } protected void setAttachments(final List attachments) { @@ -177,11 +193,16 @@ public class Message extends CcmObject implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof Message)) { return false; } final Message other = (Message) obj; - if (!other.canEqual(obj)) { + if (!other.canEqual(this)) { return false; } diff --git a/ccm-core/src/main/java/org/libreccm/messaging/MessageThread.java b/ccm-core/src/main/java/org/libreccm/messaging/MessageThread.java index 3c66babaa..d8fc29d09 100644 --- a/ccm-core/src/main/java/org/libreccm/messaging/MessageThread.java +++ b/ccm-core/src/main/java/org/libreccm/messaging/MessageThread.java @@ -62,7 +62,12 @@ public class MessageThread extends CcmObject implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof MessageThread)) { return false; } final MessageThread other = (MessageThread) obj; @@ -70,7 +75,7 @@ public class MessageThread extends CcmObject implements Serializable { return false; } - return Objects.equals(this.root, other.getRoot()); + return Objects.equals(root, other.getRoot()); } @Override diff --git a/ccm-core/src/main/java/org/libreccm/notification/Digest.java b/ccm-core/src/main/java/org/libreccm/notification/Digest.java index c783ce6fb..37deacdd1 100644 --- a/ccm-core/src/main/java/org/libreccm/notification/Digest.java +++ b/ccm-core/src/main/java/org/libreccm/notification/Digest.java @@ -28,20 +28,19 @@ import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; /** - * + * * Models the envelope information associated with a digest. * * When a digest is processed, all notifications associated with it are grouped * for delivery as a single unit to each receiver. The outbound email generated * for the receivers has a common subject, header, separator between the - * individual messages, and signature (from the documentation of the + * individual messages, and signature (from the documentation of the * {@code com.arsdigita.notification.Digest} class). * * @author Jens Pelzetter @@ -124,11 +123,19 @@ public class Digest extends CcmObject implements Serializable { } public Date getNextRun() { - return new Date(nextRun.getTime()); + if (nextRun == null) { + return null; + } else { + return new Date(nextRun.getTime()); + } } public void setNextRun(final Date nextRun) { - this.nextRun = new Date(nextRun.getTime()); + if (nextRun == null) { + this.nextRun = null; + } else { + this.nextRun = new Date(nextRun.getTime()); + } } @Override @@ -149,11 +156,12 @@ public class Digest extends CcmObject implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { return false; } - - if (!super.equals(obj)) { + + if (!(obj instanceof Digest)) { return false; } diff --git a/ccm-core/src/main/java/org/libreccm/notification/Notification.java b/ccm-core/src/main/java/org/libreccm/notification/Notification.java index 8676b7bf9..a70b09c1e 100644 --- a/ccm-core/src/main/java/org/libreccm/notification/Notification.java +++ b/ccm-core/src/main/java/org/libreccm/notification/Notification.java @@ -36,38 +36,34 @@ import javax.persistence.TemporalType; /** * - *The {@code Notification} class is used to create and send - * messages via email to ACS users and groups. It acts as a wrapper - * for a {@link Message} which contains the subject, sender, body and - * any attachments for the email. The recipient can be a {@link - * com.arsdigita.kernel.User} or a {@link org.libreccm.core.Group}. - * In the case of Group, the message can be sent to the group's email - * address or expanded into a separate message for each member of the - * group. + * The {@code Notification} class is used to create and send messages via email + * to ACS users and groups. It acts as a wrapper for a {@link Message} which + * contains the subject, sender, body and any attachments for the email. The + * recipient can be a {@link + * com.arsdigita.kernel.User} or a {@link org.libreccm.core.Group}. In the case + * of Group, the message can be sent to the group's email address or expanded + * into a separate message for each member of the group. * *

Email Alerts

* - * When using notifications for email alerts, applications often - * need to wrap a special header and signature around the contained - * Message object. This can be useful for including introductory - * remarks and action links in the email body. The - * {@code setHeader} and {@code setSignature} methods allow - * you to do this without the need to create a separate Message for - * the modified email. - * * + * When using notifications for email alerts, applications often need to wrap a + * special header and signature around the contained Message object. This can be + * useful for including introductory remarks and action links in the email body. + * The {@code setHeader} and {@code setSignature} methods allow you to do this + * without the need to create a separate Message for the modified email. + * *

Digests

* - * Finally, notifications can be sent in "instant processing mode" - * or as part of a {@link Digest}. When sent as part of a digest all - * notifications to the same recipient are collected into a single - * email and sent at regular internal. For example, an hourly digest - * might send a user all of their workflow task updates that have - * changed in the past hour, rather a much larger number of individual - * messages every time an tasks changed. - * - * (Documentation taken from the {@code com.arsdigita.notification.Notification} + * Finally, notifications can be sent in "instant processing mode" or as part of + * a {@link Digest}. When sent as part of a digest all notifications to the same + * recipient are collected into a single email and sent at regular internal. For + * example, an hourly digest might send a user all of their workflow task + * updates that have changed in the past hour, rather a much larger number of + * individual messages every time an tasks changed. + * + * (Documentation taken from the {@code com.arsdigita.notification.Notification} * class) - * + * * @author Jens Pelzetter */ @Entity @@ -166,19 +162,35 @@ public class Notification extends CcmObject implements Serializable { } public Date getRequestDate() { - return new Date(requestDate.getTime()); + if (requestDate == null) { + return null; + } else { + return new Date(requestDate.getTime()); + } } public void setRequestDate(final Date requestDate) { - this.requestDate = new Date(requestDate.getTime()); + if (requestDate == null) { + this.requestDate = null; + } else { + this.requestDate = new Date(requestDate.getTime()); + } } public Date getFulfillDate() { - return new Date(fulfillDate.getTime()); + if (fulfillDate == null) { + return null; + } else { + return new Date(fulfillDate.getTime()); + } } public void setFulfillDate(final Date fulfillDate) { - this.fulfillDate = new Date(fulfillDate.getTime()); + if (fulfillDate == null) { + this.fulfillDate = null; + } else { + this.fulfillDate = new Date(fulfillDate.getTime()); + } } public String getStatus() { @@ -236,7 +248,7 @@ public class Notification extends CcmObject implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + if (!(obj instanceof Notification)) { return false; } diff --git a/ccm-core/src/main/java/org/libreccm/notification/QueueItem.java b/ccm-core/src/main/java/org/libreccm/notification/QueueItem.java index 2bf3ebbe0..5f8fd6426 100644 --- a/ccm-core/src/main/java/org/libreccm/notification/QueueItem.java +++ b/ccm-core/src/main/java/org/libreccm/notification/QueueItem.java @@ -160,10 +160,14 @@ public class QueueItem implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + if (!(obj instanceof QueueItem)) { return false; } final QueueItem other = (QueueItem) obj; + if (!other.canEqual(this)) { + return false; + } + if (this.queueItemId != other.getQueueItemId()) { return false; } diff --git a/ccm-core/src/main/java/org/libreccm/portal/Portal.java b/ccm-core/src/main/java/org/libreccm/portal/Portal.java index 310ee12f1..b97bf5679 100644 --- a/ccm-core/src/main/java/org/libreccm/portal/Portal.java +++ b/ccm-core/src/main/java/org/libreccm/portal/Portal.java @@ -62,7 +62,11 @@ public class Portal extends Resource implements Serializable { } public List getPortlets() { - return Collections.unmodifiableList(portlets); + if (portlets == null) { + return null; + } else { + return Collections.unmodifiableList(portlets); + } } protected void setPortlets(final List portlets) { @@ -90,11 +94,12 @@ public class Portal extends Resource implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { return false; } - if (!super.equals(obj)) { + if (!(obj instanceof Portal)) { return false; } @@ -108,7 +113,7 @@ public class Portal extends Resource implements Serializable { } return Objects.equals(portlets, other.getPortlets()); } - + @Override public boolean canEqual(final Object obj) { return obj instanceof Portal; diff --git a/ccm-core/src/main/java/org/libreccm/portal/Portlet.java b/ccm-core/src/main/java/org/libreccm/portal/Portlet.java index d12935852..4f69e1fa1 100644 --- a/ccm-core/src/main/java/org/libreccm/portal/Portlet.java +++ b/ccm-core/src/main/java/org/libreccm/portal/Portlet.java @@ -88,16 +88,17 @@ public class Portlet extends Resource implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { return false; } - - if (!super.equals(obj)) { + + if (!(obj instanceof Portlet)) { return false; } final Portlet other = (Portlet) obj; - if (!other.canEqual(obj)) { + if (!other.canEqual(this)) { return false; } diff --git a/ccm-core/src/main/java/org/libreccm/runtime/Initalizer.java b/ccm-core/src/main/java/org/libreccm/runtime/Initalizer.java index 1e037c0db..ea557e358 100644 --- a/ccm-core/src/main/java/org/libreccm/runtime/Initalizer.java +++ b/ccm-core/src/main/java/org/libreccm/runtime/Initalizer.java @@ -90,7 +90,11 @@ public class Initalizer implements Serializable { } public List getRequiredInitializers() { - return Collections.unmodifiableList(requiredInitializers); + if (requiredInitializers == null) { + return null; + } else { + return Collections.unmodifiableList(requiredInitializers); + } } protected void setRequiredInitializers( @@ -122,7 +126,7 @@ public class Initalizer implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + if (!(obj instanceof Initalizer)) { return false; } final Initalizer other = (Initalizer) obj; diff --git a/ccm-core/src/main/java/org/libreccm/search/lucene/Document.java b/ccm-core/src/main/java/org/libreccm/search/lucene/Document.java index adc3f6877..a850e22de 100644 --- a/ccm-core/src/main/java/org/libreccm/search/lucene/Document.java +++ b/ccm-core/src/main/java/org/libreccm/search/lucene/Document.java @@ -59,13 +59,13 @@ public class Document implements Serializable { @Column(name = "document_timestamp") @Temporal(TemporalType.TIMESTAMP) - private Date documentTimeStamp; + private Date timeStamp; @Column(name = "dirty") private long dirty; @Column(name = "document_language", length = 8) - private String documentLanguage; + private String language; @Column(name = "country", length = 8) private String country; @@ -127,12 +127,20 @@ public class Document implements Serializable { this.typeSpecificInfo = typeSpecificInfo; } - public Date getDocumentTimeStamp() { - return new Date(documentTimeStamp.getTime()); + public Date getTimeStamp() { + if (timeStamp == null) { + return null; + } else { + return new Date(timeStamp.getTime()); + } } - public void setDocumentTimeStamp(final Date documentTimeStamp) { - this.documentTimeStamp = new Date(documentTimeStamp.getTime()); + public void setTimeStamp(final Date timeStamp) { + if (timeStamp == null) { + this.timeStamp = null; + } else { + this.timeStamp = new Date(timeStamp.getTime()); + } } public long getDirty() { @@ -143,12 +151,12 @@ public class Document implements Serializable { this.dirty = dirty; } - public String getDocumentLanguage() { - return documentLanguage; + public String getLanguage() { + return language; } - public void setDocumentLanguage(final String documentLanguage) { - this.documentLanguage = documentLanguage; + public void setLanguage(final String language) { + this.language = language; } public String getCountry() { @@ -184,11 +192,19 @@ public class Document implements Serializable { } public Date getCreated() { - return new Date(created.getTime()); + if (created == null) { + return null; + } else { + return new Date(created.getTime()); + } } public void setCreated(final Date created) { - this.created = new Date(created.getTime()); + if (created == null) { + this.created = null; + } else { + this.created = new Date(created.getTime()); + } } public Party getCreatedBy() { @@ -200,11 +216,19 @@ public class Document implements Serializable { } public Date getLastModified() { - return new Date(lastModified.getTime()); + if (lastModified == null) { + return null; + } else { + return new Date(lastModified.getTime()); + } } public void setLastModified(final Date lastModified) { - this.lastModified = new Date(lastModified.getTime()); + if (lastModified == null) { + this.lastModified = null; + } else { + this.lastModified = new Date(lastModified.getTime()); + } } public Party getLastModifiedBy() { @@ -229,9 +253,9 @@ public class Document implements Serializable { hash = 53 * hash + (int) (documentId ^ (documentId >>> 32)); hash = 53 * hash + Objects.hashCode(type); hash = 53 * hash + Objects.hashCode(typeSpecificInfo); - hash = 53 * hash + Objects.hashCode(documentTimeStamp); + hash = 53 * hash + Objects.hashCode(timeStamp); hash = 53 * hash + (int) (dirty ^ (dirty >>> 32)); - hash = 53 * hash + Objects.hashCode(documentLanguage); + hash = 53 * hash + Objects.hashCode(language); hash = 53 * hash + Objects.hashCode(country); hash = 53 * hash + Objects.hashCode(title); hash = 53 * hash + Objects.hashCode(summary); @@ -249,10 +273,14 @@ public class Document implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + if (!(obj instanceof Document)) { return false; } final Document other = (Document) obj; + if (!other.canEqual(this)) { + return false; + } + if (documentId != other.getDocumentId()) { return false; } @@ -262,13 +290,13 @@ public class Document implements Serializable { if (!Objects.equals(typeSpecificInfo, other.getTypeSpecificInfo())) { return false; } - if (!Objects.equals(documentTimeStamp, other.getDocumentTimeStamp())) { + if (!Objects.equals(timeStamp, other.getTimeStamp())) { return false; } if (dirty != other.getDirty()) { return false; } - if (!Objects.equals(documentLanguage, other.getDocumentLanguage())) { + if (!Objects.equals(language, other.getLanguage())) { return false; } if (!Objects.equals(country, other.getCountry())) { @@ -298,6 +326,10 @@ public class Document implements Serializable { return Objects.equals(contentSection, other.getContentSection()); } + public boolean canEqual(final Object obj) { + return obj instanceof Document; + } + @Override public String toString() { return String.format("%s{ " @@ -317,9 +349,9 @@ public class Document implements Serializable { super.toString(), documentId, type, - documentTimeStamp, + timeStamp, dirty, - documentLanguage, + language, country, title, created, diff --git a/ccm-core/src/main/java/org/libreccm/search/lucene/Index.java b/ccm-core/src/main/java/org/libreccm/search/lucene/Index.java index 603325fbd..ba71de586 100644 --- a/ccm-core/src/main/java/org/libreccm/search/lucene/Index.java +++ b/ccm-core/src/main/java/org/libreccm/search/lucene/Index.java @@ -97,10 +97,14 @@ public class Index implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + if (!(obj instanceof Index)) { return false; } final Index other = (Index) obj; + if (!other.canEqual(this)) { + return false; + } + if (indexId != other.getIndexId()) { return false; } @@ -110,6 +114,10 @@ public class Index implements Serializable { return luceneIndexId == other.getLuceneIndexId(); } + public boolean canEqual(final Object obj) { + return obj instanceof Index; + } + @Override public String toString() { return String.format("%s{ " diff --git a/ccm-core/src/main/java/org/libreccm/web/Application.java b/ccm-core/src/main/java/org/libreccm/web/Application.java index 0b32f2f0b..90e3bb6bd 100644 --- a/ccm-core/src/main/java/org/libreccm/web/Application.java +++ b/ccm-core/src/main/java/org/libreccm/web/Application.java @@ -80,11 +80,12 @@ public class Application extends Resource implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { return false; } - if (!super.equals(obj)) { + if (!(obj instanceof Application)) { return false; } @@ -98,6 +99,11 @@ public class Application extends Resource implements Serializable { } return Objects.equals(containerGroup, other.getContainerGroup()); } + + @Override + public boolean canEqual(final Object obj) { + return obj instanceof Application; + } @Override public String toString(final String data) { diff --git a/ccm-core/src/main/java/org/libreccm/web/Host.java b/ccm-core/src/main/java/org/libreccm/web/Host.java index b98808a69..bc0193c25 100644 --- a/ccm-core/src/main/java/org/libreccm/web/Host.java +++ b/ccm-core/src/main/java/org/libreccm/web/Host.java @@ -90,10 +90,13 @@ public class Host implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + if (!(obj instanceof Host)) { return false; } final Host other = (Host) obj; + if (!other.canEqual(this)) { + return false; + } if (this.hostId != other.getHostId()) { return false; } @@ -103,6 +106,10 @@ public class Host implements Serializable { return this.serverPort == other.getServerPort(); } + public boolean canEqual(final Object obj) { + return obj instanceof Host; + } + @Override public String toString() { return String.format("%s{ " diff --git a/ccm-core/src/main/java/org/libreccm/workflow/Task.java b/ccm-core/src/main/java/org/libreccm/workflow/Task.java index e97c94c9b..3cfa06a46 100644 --- a/ccm-core/src/main/java/org/libreccm/workflow/Task.java +++ b/ccm-core/src/main/java/org/libreccm/workflow/Task.java @@ -163,7 +163,11 @@ public class Task implements Serializable { } public List getDependentTasks() { - return Collections.unmodifiableList(dependentTasks); + if (dependentTasks == null) { + return null; + } else { + return Collections.unmodifiableList(dependentTasks); + } } protected void setDependentTasks(final List dependentTasks) { @@ -179,7 +183,11 @@ public class Task implements Serializable { } public List getDependsOn() { - return Collections.unmodifiableList(dependsOn); + if (dependsOn == null) { + return null; + } else { + return Collections.unmodifiableList(dependsOn); + } } protected void setDependsOn(final List dependsOn) { @@ -195,7 +203,11 @@ public class Task implements Serializable { } public List getComments() { - return Collections.unmodifiableList(comments); + if (comments == null) { + return null; + } else { + return Collections.unmodifiableList(comments); + } } protected void setComments(final List comments) { @@ -230,14 +242,14 @@ public class Task implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + if (!(obj instanceof Task)) { return false; } final Task other = (Task) obj; - if (!other.canEqual(obj)) { + if (!other.canEqual(this)) { return false; } - + if (taskId != other.getTaskId()) { return false; } @@ -264,7 +276,7 @@ public class Task implements Serializable { } return Objects.equals(comments, other.getComments()); } - + public boolean canEqual(final Object obj) { return obj instanceof Task; } @@ -273,17 +285,17 @@ public class Task implements Serializable { public final String toString() { return toString(""); } - + public String toString(final String data) { return String.format("%s{ " - + "taskId = %d, " - + "label = %s, " - + "active = %b, " - + "taskState = \"%s\", " - + "workflow = %s, " - + "dependentTasks = %s, " - + "dependsOn = %s%s" - + " }", + + "taskId = %d, " + + "label = %s, " + + "active = %b, " + + "taskState = \"%s\", " + + "workflow = %s, " + + "dependentTasks = %s, " + + "dependsOn = %s%s" + + " }", super.toString(), taskId, Objects.toString(label), @@ -294,4 +306,5 @@ public class Task implements Serializable { Objects.toString(dependsOn), data); } + } diff --git a/ccm-core/src/main/java/org/libreccm/workflow/UserTask.java b/ccm-core/src/main/java/org/libreccm/workflow/UserTask.java index 19132ab08..00ce0c619 100644 --- a/ccm-core/src/main/java/org/libreccm/workflow/UserTask.java +++ b/ccm-core/src/main/java/org/libreccm/workflow/UserTask.java @@ -109,19 +109,35 @@ public class UserTask extends Task implements Serializable { } public Date getStartDate() { - return new Date(startDate.getTime()); + if (startDate == null) { + return null; + } else { + return new Date(startDate.getTime()); + } } public void setStartDate(final Date startDate) { - this.startDate = new Date(startDate.getTime()); + if (startDate == null) { + this.startDate = null; + } else { + this.startDate = new Date(startDate.getTime()); + } } public Date getDueDate() { - return new Date(dueDate.getTime()); + if (dueDate == null) { + return null; + } else { + return new Date(dueDate.getTime()); + } } public void setDueDate(final Date dueDate) { - this.dueDate = new Date(dueDate.getTime()); + if (dueDate == null) { + this.dueDate = null; + } else { + this.dueDate = new Date(dueDate.getTime()); + } } public long getDurationMinutes() { @@ -141,7 +157,11 @@ public class UserTask extends Task implements Serializable { } public List getAssignedUsers() { - return Collections.unmodifiableList(assignedUsers); + if (assignedUsers == null) { + return null; + } else { + return Collections.unmodifiableList(assignedUsers); + } } protected void setAssignedUsers(final List assignedUsers) { @@ -157,7 +177,11 @@ public class UserTask extends Task implements Serializable { } public List getAssignedGroups() { - return Collections.unmodifiableList(assignedGroups); + if (assignedGroups == null) { + return null; + } else { + return Collections.unmodifiableList(assignedGroups); + } } protected void setAssignedGroups(final List assignedGroups) { @@ -192,11 +216,16 @@ public class UserTask extends Task implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + + if (!super.equals(obj)) { + return false; + } + + if (!(obj instanceof UserTask)) { return false; } final UserTask other = (UserTask) obj; - if (!other.canEqual(obj)) { + if (!other.canEqual(this)) { return false; } @@ -224,6 +253,11 @@ public class UserTask extends Task implements Serializable { return Objects.equals(assignedGroups, other.getAssignedGroups()); } + @Override + public boolean canEqual(final Object obj) { + return obj instanceof UserTask; + } + @Override public String toString(final String data) { return super.toString(String.format(", locked = %b, " diff --git a/ccm-core/src/main/java/org/libreccm/workflow/Workflow.java b/ccm-core/src/main/java/org/libreccm/workflow/Workflow.java index aba06615e..eb5b5fb67 100644 --- a/ccm-core/src/main/java/org/libreccm/workflow/Workflow.java +++ b/ccm-core/src/main/java/org/libreccm/workflow/Workflow.java @@ -104,9 +104,13 @@ public class Workflow implements Serializable { public void setDescription(final LocalizedString description) { this.description = description; } - + public List getTasks() { - return Collections.unmodifiableList(tasks); + if (tasks == null) { + return null; + } else { + return Collections.unmodifiableList(tasks); + } } protected void setTasks(final List tasks) { @@ -135,11 +139,11 @@ public class Workflow implements Serializable { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { + if (!(obj instanceof Workflow)) { return false; } final Workflow other = (Workflow) obj; - if (!other.canEqual(obj)) { + if (!other.canEqual(this)) { return false; } diff --git a/ccm-core/src/test/java/org/libreccm/categorization/EqualsAndHashCodeTest.java b/ccm-core/src/test/java/org/libreccm/categorization/EqualsAndHashCodeTest.java index 7a160427e..ce34a7e72 100644 --- a/ccm-core/src/test/java/org/libreccm/categorization/EqualsAndHashCodeTest.java +++ b/ccm-core/src/test/java/org/libreccm/categorization/EqualsAndHashCodeTest.java @@ -18,9 +18,11 @@ */ package org.libreccm.categorization; +import nl.jqno.equalsverifier.EqualsVerifier; +import nl.jqno.equalsverifier.Warning; +import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import org.libreccm.testutils.EqualsVerifier; import org.libreccm.tests.categories.UnitTest; import java.util.Arrays; @@ -32,7 +34,9 @@ import java.util.Collection; */ @RunWith(Parameterized.class) @org.junit.experimental.categories.Category(UnitTest.class) -public class EqualsAndHashCodeTest extends EqualsVerifier { +public class EqualsAndHashCodeTest { + + private final Class entityClass; @Parameterized.Parameters(name = "{0}") public static Collection> data() { @@ -43,8 +47,32 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { DomainOwnership.class}); } - public EqualsAndHashCodeTest(final Class entitiesClass) { - super(entitiesClass); + public EqualsAndHashCodeTest(final Class entityClass) { + this.entityClass = entityClass; + } + + @Test + public void verifyEqualsAndHashCode() { + final Category category1 = new Category(); + category1.setName("Category One"); + + final Category category2 = new Category(); + category2.setName("Category Two"); + + final Domain domain1 = new Domain(); + domain1.setDomainKey("Domain-One"); + + final Domain domain2 = new Domain(); + domain2.setDomainKey("Domain Two"); + + EqualsVerifier + .forClass(entityClass) + .suppress(Warning.STRICT_INHERITANCE) + .suppress(Warning.NONFINAL_FIELDS) + .withRedefinedSuperclass() + .withPrefabValues(Category.class, category1, category2) + .withPrefabValues(Domain.class, domain1, domain2) + .verify(); } } diff --git a/ccm-core/src/test/java/org/libreccm/formbuilder/EqualsAndHashCodeTest.java b/ccm-core/src/test/java/org/libreccm/formbuilder/EqualsAndHashCodeTest.java index 5112c4e83..b7234bed1 100644 --- a/ccm-core/src/test/java/org/libreccm/formbuilder/EqualsAndHashCodeTest.java +++ b/ccm-core/src/test/java/org/libreccm/formbuilder/EqualsAndHashCodeTest.java @@ -18,10 +18,12 @@ */ package org.libreccm.formbuilder; +import nl.jqno.equalsverifier.EqualsVerifier; +import nl.jqno.equalsverifier.Warning; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import org.libreccm.testutils.EqualsVerifier; import org.libreccm.tests.categories.UnitTest; import java.util.Arrays; @@ -33,11 +35,13 @@ import java.util.Collection; */ @RunWith(Parameterized.class) @Category(UnitTest.class) -public class EqualsAndHashCodeTest extends EqualsVerifier { - +public class EqualsAndHashCodeTest { + + private final Class entityClass; + @Parameterized.Parameters(name = "{0}") public static Collection> data() { - return Arrays.asList(new Class[] { + return Arrays.asList(new Class[]{ Component.class, DataDrivenSelect.class, FormSection.class, @@ -51,8 +55,47 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { WidgetLabel.class }); } - + public EqualsAndHashCodeTest(final Class entityClass) { - super(entityClass); + this.entityClass = entityClass; } + + @Test + public void verifyEqualsAndHashCode() { + final Component component1 = new Component(); + component1.setAdminName("Component One"); + + final Component component2 = new Component(); + component2.setAdminName("Component Two"); + + final WidgetLabel widgetLabel1 = new WidgetLabel(); + widgetLabel1.setAdminName("WidgetLabel One"); + + final WidgetLabel widgetLabel2 = new WidgetLabel(); + widgetLabel2.setAdminName("WidgetLabel Two"); + + final Widget widget1 = new Widget(); + widget1.setAdminName("Widget 1"); + + final Widget widget2 = new Widget(); + widget2.setAdminName("Widget 2"); + + final FormSection formSection1 = new FormSection(); + formSection1.setAdminName("FormSection One"); + + final FormSection formSection2 = new FormSection(); + formSection2.setAdminName("FormSection Two"); + + EqualsVerifier + .forClass(entityClass) + .suppress(Warning.STRICT_INHERITANCE) + .suppress(Warning.NONFINAL_FIELDS) + .withRedefinedSuperclass() + .withPrefabValues(Component.class, component1, component2) + .withPrefabValues(WidgetLabel.class, widgetLabel1, widgetLabel2) + .withPrefabValues(Widget.class, widget1, widget2) + .withPrefabValues(FormSection.class, formSection1, formSection2) + .verify(); + } + } diff --git a/ccm-core/src/test/java/org/libreccm/formbuilder/actions/EqualsAndHashCodeTest.java b/ccm-core/src/test/java/org/libreccm/formbuilder/actions/EqualsAndHashCodeTest.java index 13f627c73..8ffaab766 100644 --- a/ccm-core/src/test/java/org/libreccm/formbuilder/actions/EqualsAndHashCodeTest.java +++ b/ccm-core/src/test/java/org/libreccm/formbuilder/actions/EqualsAndHashCodeTest.java @@ -18,10 +18,14 @@ */ package org.libreccm.formbuilder.actions; +import nl.jqno.equalsverifier.EqualsVerifier; +import nl.jqno.equalsverifier.Warning; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import org.libreccm.testutils.EqualsVerifier; +import org.libreccm.formbuilder.Component; +import org.libreccm.formbuilder.FormSection; import org.libreccm.tests.categories.UnitTest; import java.util.Arrays; @@ -33,7 +37,9 @@ import java.util.Collection; */ @RunWith(Parameterized.class) @Category(UnitTest.class) -public class EqualsAndHashCodeTest extends EqualsVerifier { +public class EqualsAndHashCodeTest { + + private final Class entityClass; @Parameterized.Parameters(name = "{0}") public static Collection> data() { @@ -48,7 +54,31 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { } public EqualsAndHashCodeTest(final Class entityClass) { - super(entityClass); + this.entityClass = entityClass; + } + + @Test + public void verifyEqualsAndHashCode() { + final Component component1 = new Component(); + component1.setAdminName("Component One"); + + final Component component2 = new Component(); + component2.setAdminName("Component Two"); + + final FormSection formSection1 = new FormSection(); + formSection1.setAdminName("FormSection One"); + + final FormSection formSection2 = new FormSection(); + formSection2.setAdminName("FormSection Two"); + + EqualsVerifier + .forClass(entityClass) + .suppress(Warning.STRICT_INHERITANCE) + .suppress(Warning.NONFINAL_FIELDS) + .withRedefinedSuperclass() + .withPrefabValues(Component.class, component1, component2) + .withPrefabValues(FormSection.class, formSection1, formSection2) + .verify(); } } diff --git a/ccm-core/src/test/java/org/libreccm/l10n/EqualsAndHashCodeTest.java b/ccm-core/src/test/java/org/libreccm/l10n/EqualsAndHashCodeTest.java index df1535108..f4aa26b69 100644 --- a/ccm-core/src/test/java/org/libreccm/l10n/EqualsAndHashCodeTest.java +++ b/ccm-core/src/test/java/org/libreccm/l10n/EqualsAndHashCodeTest.java @@ -18,9 +18,12 @@ */ package org.libreccm.l10n; +import nl.jqno.equalsverifier.Warning; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.libreccm.messaging.Message; import org.libreccm.tests.categories.UnitTest; import org.libreccm.testutils.EqualsVerifier; @@ -33,7 +36,9 @@ import java.util.Collection; */ @RunWith(Parameterized.class) @Category(UnitTest.class) -public class EqualsAndHashCodeTest extends EqualsVerifier { +public class EqualsAndHashCodeTest { + + private final Class entityClass; @Parameterized.Parameters(name = "{0}") public static Collection> data() { @@ -43,7 +48,26 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { } public EqualsAndHashCodeTest(final Class entityClass) { - super(entityClass); + this.entityClass = entityClass; } + @Test + public void verifyEqualsAndHashCode() { + final Message message1 = new Message(); + message1.setSubject("Message One"); + + final Message message2 = new Message(); + message2.setSubject("Message Two"); + + nl.jqno.equalsverifier.EqualsVerifier + .forClass(entityClass) + .suppress(Warning.STRICT_INHERITANCE) + .suppress(Warning.NONFINAL_FIELDS) + .withRedefinedSuperclass() + .withPrefabValues(Message.class, message1, message2) + .verify(); + } + + + } diff --git a/ccm-core/src/test/java/org/libreccm/messaging/EqualsAndHashCodeTest.java b/ccm-core/src/test/java/org/libreccm/messaging/EqualsAndHashCodeTest.java index 62d0fff1a..6ae2be5d7 100644 --- a/ccm-core/src/test/java/org/libreccm/messaging/EqualsAndHashCodeTest.java +++ b/ccm-core/src/test/java/org/libreccm/messaging/EqualsAndHashCodeTest.java @@ -18,11 +18,12 @@ */ package org.libreccm.messaging; +import nl.jqno.equalsverifier.Warning; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.libreccm.tests.categories.UnitTest; -import org.libreccm.testutils.EqualsVerifier; import java.util.Arrays; import java.util.Collection; @@ -33,7 +34,9 @@ import java.util.Collection; */ @RunWith(Parameterized.class) @Category(UnitTest.class) -public class EqualsAndHashCodeTest extends EqualsVerifier { +public class EqualsAndHashCodeTest { + + private final Class entityClass; @Parameterized.Parameters(name = "{0}") public static Collection> data() { @@ -45,7 +48,24 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { } public EqualsAndHashCodeTest(final Class entityClass) { - super(entityClass); + this.entityClass = entityClass; + } + + @Test + public void verifyEqualsAndHashCode() { + final Message message1 = new Message(); + message1.setSubject("Message One"); + + final Message message2 = new Message(); + message2.setSubject("Message Two"); + + nl.jqno.equalsverifier.EqualsVerifier + .forClass(entityClass) + .suppress(Warning.STRICT_INHERITANCE) + .suppress(Warning.NONFINAL_FIELDS) + .withRedefinedSuperclass() + .withPrefabValues(Message.class, message1, message2) + .verify(); } } diff --git a/ccm-core/src/test/java/org/libreccm/notification/EqualsAndHashCodeTest.java b/ccm-core/src/test/java/org/libreccm/notification/EqualsAndHashCodeTest.java index cddb79042..bd9216d0c 100644 --- a/ccm-core/src/test/java/org/libreccm/notification/EqualsAndHashCodeTest.java +++ b/ccm-core/src/test/java/org/libreccm/notification/EqualsAndHashCodeTest.java @@ -18,11 +18,14 @@ */ package org.libreccm.notification; +import nl.jqno.equalsverifier.EqualsVerifier; +import nl.jqno.equalsverifier.Warning; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.libreccm.messaging.Message; import org.libreccm.tests.categories.UnitTest; -import org.libreccm.testutils.EqualsVerifier; import java.util.Arrays; import java.util.Collection; @@ -33,7 +36,9 @@ import java.util.Collection; */ @RunWith(Parameterized.class) @Category(UnitTest.class) -public class EqualsAndHashCodeTest extends EqualsVerifier { +public class EqualsAndHashCodeTest { + + private final Class entityClass; @Parameterized.Parameters(name = "{0}") public static Collection> data() { @@ -45,7 +50,24 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { } public EqualsAndHashCodeTest(final Class entityClass) { - super(entityClass); + this.entityClass = entityClass; + } + + @Test + public void verifyEqualsAndHashCode() { + final Message message1 = new Message(); + message1.setSubject("Message One"); + + final Message message2 = new Message(); + message2.setSubject("Message Two"); + + EqualsVerifier + .forClass(entityClass) + .suppress(Warning.STRICT_INHERITANCE) + .suppress(Warning.NONFINAL_FIELDS) + .withRedefinedSuperclass() + .withPrefabValues(Message.class, message1, message2) + .verify(); } } diff --git a/ccm-core/src/test/java/org/libreccm/portal/EqualsAndHashCodeTest.java b/ccm-core/src/test/java/org/libreccm/portal/EqualsAndHashCodeTest.java index 007158010..4666f849f 100644 --- a/ccm-core/src/test/java/org/libreccm/portal/EqualsAndHashCodeTest.java +++ b/ccm-core/src/test/java/org/libreccm/portal/EqualsAndHashCodeTest.java @@ -18,11 +18,14 @@ */ package org.libreccm.portal; +import nl.jqno.equalsverifier.EqualsVerifier; +import nl.jqno.equalsverifier.Warning; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.libreccm.core.Resource; import org.libreccm.tests.categories.UnitTest; -import org.libreccm.testutils.EqualsVerifier; import java.util.Arrays; import java.util.Collection; @@ -33,7 +36,9 @@ import java.util.Collection; */ @RunWith(Parameterized.class) @Category(UnitTest.class) -public class EqualsAndHashCodeTest extends EqualsVerifier { +public class EqualsAndHashCodeTest { + + private final Class entityClass; @Parameterized.Parameters(name = "{0}") public static Collection> data() { @@ -44,6 +49,31 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { } public EqualsAndHashCodeTest(final Class entityTest) { - super(entityTest); + this.entityClass = entityTest; } + + @Test + public void verifyEqualsAndHashCode() { + final Portal portal1 = new Portal(); + portal1.setDisplayName("Portal One"); + + final Portal portal2 = new Portal(); + portal2.setDisplayName("Portal Two"); + + final Resource resource1 = new Resource(); + resource1.setDisplayName("Resource One"); + + final Resource resource2 = new Resource(); + resource2.setDisplayName("Resource Two"); + + EqualsVerifier + .forClass(entityClass) + .suppress(Warning.STRICT_INHERITANCE) + .suppress(Warning.NONFINAL_FIELDS) + .withRedefinedSuperclass() + .withPrefabValues(Portal.class, portal1, portal2) + .withPrefabValues(Resource.class, resource1, resource2) + .verify(); + } + } diff --git a/ccm-core/src/test/java/org/libreccm/runtime/EqualsAndHashCodeTest.java b/ccm-core/src/test/java/org/libreccm/runtime/EqualsAndHashCodeTest.java index c8cd247c1..89deb5ca8 100644 --- a/ccm-core/src/test/java/org/libreccm/runtime/EqualsAndHashCodeTest.java +++ b/ccm-core/src/test/java/org/libreccm/runtime/EqualsAndHashCodeTest.java @@ -18,11 +18,13 @@ */ package org.libreccm.runtime; +import nl.jqno.equalsverifier.EqualsVerifier; +import nl.jqno.equalsverifier.Warning; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.libreccm.tests.categories.UnitTest; -import org.libreccm.testutils.EqualsVerifier; import java.util.Arrays; import java.util.Collection; @@ -33,7 +35,9 @@ import java.util.Collection; */ @RunWith(Parameterized.class) @Category(UnitTest.class) -public class EqualsAndHashCodeTest extends EqualsVerifier { +public class EqualsAndHashCodeTest { + + private final Class entityClass; @Parameterized.Parameters(name = "{0}") public static Collection> data() { @@ -43,8 +47,24 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { } public EqualsAndHashCodeTest(final Class entityClass) { - super(entityClass); + this.entityClass = entityClass; + } + + @Test + public void verifyEqualsAndHashCode() { + final Initalizer initalizer1 = new Initalizer(); + initalizer1.setClassName("org.example.foo.Initalizer"); + + final Initalizer initalizer2 = new Initalizer(); + initalizer2.setClassName("org.example.bar.Initalizer"); + + EqualsVerifier + .forClass(entityClass) + .suppress(Warning.STRICT_INHERITANCE) + .suppress(Warning.NONFINAL_FIELDS) + .withRedefinedSuperclass() + .withPrefabValues(Initalizer.class, initalizer1, initalizer2) + .verify(); } - } diff --git a/ccm-core/src/test/java/org/libreccm/web/EqualsAndHashCodeTest.java b/ccm-core/src/test/java/org/libreccm/web/EqualsAndHashCodeTest.java index 3cbe26a60..f59f96030 100644 --- a/ccm-core/src/test/java/org/libreccm/web/EqualsAndHashCodeTest.java +++ b/ccm-core/src/test/java/org/libreccm/web/EqualsAndHashCodeTest.java @@ -18,11 +18,14 @@ */ package org.libreccm.web; +import nl.jqno.equalsverifier.EqualsVerifier; +import nl.jqno.equalsverifier.Warning; +import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import org.libreccm.core.Resource; import org.libreccm.tests.categories.UnitTest; -import org.libreccm.testutils.EqualsVerifier; import java.util.Arrays; import java.util.Collection; @@ -33,7 +36,9 @@ import java.util.Collection; */ @RunWith(Parameterized.class) @Category(UnitTest.class) -public class EqualsAndHashCodeTest extends EqualsVerifier { +public class EqualsAndHashCodeTest { + + private final Class entityClass; @Parameterized.Parameters(name = "{0}") public static Collection> data() { @@ -44,7 +49,24 @@ public class EqualsAndHashCodeTest extends EqualsVerifier { } public EqualsAndHashCodeTest(final Class entityClass) { - super(entityClass); + this.entityClass = entityClass; + } + + @Test + public void verifyEqualsAndHashCode() { + final Resource resource1 = new Resource(); + resource1.setDisplayName("Resource One"); + + final Resource resource2 = new Resource(); + resource2.setDisplayName("Resource Two"); + + EqualsVerifier + .forClass(entityClass) + .suppress(Warning.STRICT_INHERITANCE) + .suppress(Warning.NONFINAL_FIELDS) + .withRedefinedSuperclass() + .withPrefabValues(Resource.class, resource1, resource2) + .verify(); } }