org.bidib.wizard.api.model.Flag Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bidibwizard-api Show documentation
Show all versions of bidibwizard-api Show documentation
jBiDiB BiDiB Wizard API POM
package org.bidib.wizard.api.model;
import org.apache.commons.lang3.StringUtils;
public class Flag implements IdAware {
private int id;
private String label;
public static final Flag NONE = new Flag.Builder(-1).build();
public Flag() {
}
public Flag(int id) {
this(id, null);
}
public Flag(int id, String label) {
this.id = id;
this.label = label;
}
private Flag(Builder builder) {
setId(builder.id);
setLabel(builder.label);
}
@Override
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Flag) {
Flag other = (Flag) obj;
if (id == other.id) {
return true;
}
}
return false;
}
@Override
public int hashCode() {
return id;
}
public String toString() {
String result = null;
if (!StringUtils.isBlank(label)) {
result = label;
}
// else {
// result = Resources.getString(getClass(), "label") + "_" + id;
// }
return result;
}
public static class Builder {
private final int id;
private String label;
public Builder(int id) {
this.id = id;
}
public Builder setLabel(String label) {
this.label = label;
return this;
}
public Flag build() {
return new Flag(this);
}
}
}