Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.estylesoft.pfr.spu.classifier.model;
- import com.estylesoft.pfr.spu.common.model.Period;
- import javax.persistence.*;
- import javax.xml.bind.annotation.XmlTransient;
- import java.io.Serializable;
- /**
- * A base class for classifiers. Classifiers are closer to entities than to value objects (DDD). Classifiers are
- * immutable and are created by other system (НСИ).
- *
- * <p>
- * The <code>{@link #id}</code> should not be considered as a primary (find) key.
- *
- * @author schurukanov
- */
- @MappedSuperclass
- // @DataCache(enabled = true, timeout = 43200000)
- @EntityListeners(ClassifierDefaultsInitializer.class)
- public abstract class Classifier implements Serializable{
- @XmlTransient
- private Long id;
- @XmlTransient
- private Period lifetime;
- @XmlTransient
- private String dsc;
- public Classifier() {
- this.lifetime = new Period();
- }
- public Classifier(Period lifetime) {
- this.lifetime = lifetime;
- }
- @Embedded
- public Period getLifetime() {
- return lifetime;
- }
- public void setLifetime(Period lifetime) {
- this.lifetime = lifetime;
- }
- /**
- * This method should not be used in business code.
- *
- * deprecated [schurukanov]: see
- * {@link com.estylesoft.pfr.spu.classifier.infrastructure.ClassifierRepositoryImpl#add(Classifier)}
- */
- public void setId(Long id) {
- this.id = id;
- }
- @Id
- @Column(name = "ID")
- public Long getId() {
- return id;
- }
- @Override
- public int hashCode() {
- return this.getId() != null ? this.getId().hashCode() : 0;
- }
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (object == null || getClass() != object.getClass()) {
- return false;
- }
- Classifier classifier = (Classifier) object;
- if(this.getId() != null){
- return this.getId().equals(classifier.getId());
- } else {
- return (classifier.getId() == null);
- }
- }
- //
- // Infrastructure stuff
- //
- @Transient
- public Long getPersistenceId() {
- return getId();
- }
- @Transient
- public String getDsc() {
- return dsc;
- }
- public void setDsc(String dsc) {
- this.dsc = dsc;
- }
- @Override
- public String toString() {
- return "Classifier{" +
- "id=" + getId() +
- ", lifetime=" + getLifetime() +
- ", dsc='" + getDsc() + '\'' +
- ", persistenceId=" + getPersistenceId() +
- '}';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement