com.g2forge.alexandria.media.IMediaRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ax-media Show documentation
Show all versions of ax-media Show documentation
Media types and file extensions.
package com.g2forge.alexandria.media;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import com.g2forge.alexandria.java.core.helpers.HCollection;
import com.g2forge.alexandria.java.io.Filename;
public interface IMediaRegistry {
public default IMediaType computeMediaType(Filename filename) {
final String extension = filename.getLastExtension();
final List matches = getMediaTypes().stream().filter(mediaType -> mediaType.getFileExtensions().isMatch(extension)).collect(Collectors.toList());
if (matches.isEmpty()) return null;
return HCollection.getOne(matches);
}
public Collection getMediaTypes();
}