info.freelibrary.iiif.presentation.v3.services.AbstractOtherService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jiiify-presentation-v3 Show documentation
Show all versions of jiiify-presentation-v3 Show documentation
A Java Library for version 3 of the IIIF Presentation API
package info.freelibrary.iiif.presentation.v3.services;
import java.util.Optional;
import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import info.freelibrary.util.warnings.JDK;
import info.freelibrary.iiif.presentation.v3.MediaType;
import info.freelibrary.iiif.presentation.v3.Service;
import info.freelibrary.iiif.presentation.v3.utils.JsonKeys;
/**
* An abstract class for other services.
*
* @param The type of other service
*/
abstract class AbstractOtherService> extends AbstractService
implements OtherService {
/**
* This service's format.
*/
@JsonProperty(JsonKeys.FORMAT)
protected MediaType myFormat;
/**
* This service's profile.
*/
@JsonProperty(JsonKeys.PROFILE)
protected OtherService.Profile myProfile;
@Override
@JsonGetter(JsonKeys.PROFILE)
@JsonInclude(Include.NON_ABSENT)
public Optional getProfile() {
return Optional.ofNullable(myProfile);
}
@Override
@SuppressWarnings(JDK.UNCHECKED)
public T setProfile(final OtherService.Profile aProfile) {
myProfile = aProfile;
return (T) this;
}
@Override
public abstract T setProfile(String aProfile);
@Override
@SuppressWarnings(JDK.UNCHECKED)
public T setFormat(final MediaType aFormat) {
myFormat = aFormat;
return (T) this;
}
@Override
@SuppressWarnings(JDK.UNCHECKED)
public T setFormat(final String aFormat) {
MediaType.fromString(aFormat).ifPresentOrElse(format -> myFormat = format, () -> myFormat = null);
return (T) this;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy