nl.vpro.domain.media.MidIdentifiable Maven / Gradle / Ivy
Show all versions of media-domain Show documentation
/*
* Copyright (C) 2010 Licensed under the Apache License, Version 2.0
* VPRO The Netherlands
*/
package nl.vpro.domain.media;
import com.fasterxml.jackson.annotation.JsonIgnore;
import nl.vpro.domain.Identifiable;
/**
* Object that are identifiable with their 'MID' (or 'media id'). These ids are generated by METIS.
*
* This currently also extends {@link Identifiable} because all objects also have an id that is generated by the poms backend itself.
* @since 5.11
*/
public interface MidIdentifiable extends Identifiable {
String getMid();
/**
* The {@link MediaType} of the poms object. E.g. {@link MediaType#BROADCAST} or {@link MediaType#SERIES}.
*/
MediaType getMediaType();
/**
* {@code MedioObject}s can be {@link MediaObjectLocker locked}, normally on their {@link MediaObject#getMid()}, but
* in this context we think of it as {@link #getCorrelation()}. In some cases thi is not the same as the {@code mid} itself.
* e.g. if there is no {@code mid} filled in yet, or if the object is a {@link Segment} (which is correlated with its parent instead)
* @see #getCorrelation()
*/
@JsonIgnore
default String getCorrelationId() {
return getCorrelation().id;
}
/**
*/
@JsonIgnore
default MediaIdentifiable.Correlation getCorrelation() {
String mid = getMid();
if (mid != null) {
return MediaIdentifiable.Correlation.mid(mid);
}
return new MediaIdentifiable.Correlation(String.valueOf(hashCode()), MediaIdentifiable.Correlation.Type.HASH);
}
}