Catalog.java
package com.sintia.ffl.admin.optique.catalogue.models;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
/**
* Represent a catalog, which is identified by:
* <ul>
* <li>a maker</li>
* <li>a provider</li>
* <li>a label</li>
* <li>a date</li>
* </ul>
* When comparing 2 catalogs, only these fields will be used.<br>
* <br>
* Also, There's 3 more attributes that correspond to the actuals files of the catalog
*
* @author hlouanzi
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Slf4j
public class Catalog {
private String catalogType;
/**
* The path to the associations file for the current catalog
*/
private String associationsFileName;
/**
* The path to the extras file for the current catalog
*/
private String extrasFileName;
/**
* The path to the glasses file for the current catalog
*/
private String glassesFileName;
/**
* The label extracted from the files name.<br>
* Can't be set manually. It's only updated when the 1st file is set (whatever it is)
*/
private String label;
/**
* The date extracted from the files name.<br>
* Can't be set manually. It's only updated when the 1st file is set (whatever it is)
*/
private String date;
/**
* The maker extracted from the files name.<br>
* Can't be set manually. It's only updated when the 1st file is set (whatever it is)
*/
private String maker;
/**
* The provider extracted from the files name.<br>
* Can't be set manually. It's only updated when the 1st file is set (whatever it is)
*/
private String provider;
/**
* Indicate if the 3 files have been correctly set or not
* Can't be set manually. It's only updated when all the files have been set
*/
private boolean valid;
public Catalog(String catalogType) {
this.valid = false;
this.catalogType = catalogType;
}
/**
* Two catalogs are equals if theirs maker, provider, label and date are equals.<br>
* The 3 file names are not taken into account for this comparison.
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
Catalog other = (Catalog) obj;
if (date == null) {
if (other.date != null) {
return false;
}
} else if (!date.equals(other.date)) {
return false;
}
if (label == null) {
if (other.label != null) {
return false;
}
} else if (!label.equals(other.label)) {
return false;
}
if (maker == null) {
if (other.maker != null) {
return false;
}
} else if (!maker.equals(other.maker)) {
return false;
}
if (provider == null) {
if (other.provider != null) {
return false;
}
} else if (!provider.equals(other.provider)) {
return false;
}
return true;
}
}