net.nemerosa.ontrack.model.structure.Entity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ontrack-model Show documentation
Show all versions of ontrack-model Show documentation
Ontrack module: ontrack-model
package net.nemerosa.ontrack.model.structure;
import static org.apache.commons.lang3.Validate.isTrue;
/**
* An Entity is a model object that has an {@link ID}. The state of this ID will determined the status
* of this entity:
*
* - new - the ID is not {@linkplain ID#isSet() set}.
* - defined - the ID is {@linkplain ID#isSet() set}.
*
*/
public interface Entity {
public static void isEntityNew(Entity e, String message) {
isTrue(e != null && !ID.isDefined(e.getId()), message);
}
public static void isEntityDefined(Entity e, String message) {
isTrue(e != null && ID.isDefined(e.getId()), message);
}
ID getId();
default int id() {
ID id = getId();
isTrue(ID.isDefined(id), "ID must be defined");
return id.getValue();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy