io.annot8.common.implementations.registries.SimpleContentBuilderFactoryRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of annot8-common-implementations Show documentation
Show all versions of annot8-common-implementations Show documentation
Common functionality used by Annot8 implementations
/* Annot8 (annot8.io) - Licensed under Apache-2.0. */
package io.annot8.common.implementations.registries;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import io.annot8.common.implementations.factories.ContentBuilderFactory;
import io.annot8.core.data.Content;
public class SimpleContentBuilderFactoryRegistry implements ContentBuilderFactoryRegistry {
private final Map>, ContentBuilderFactory, ?>> builders =
new HashMap<>();
public , I extends C> void register(
Class contentClass, ContentBuilderFactory contentBuilderFactory) {
builders.put(contentClass, contentBuilderFactory);
}
@Override
public > Optional> get(
Class contentClass) {
// This cast to C is correct, due to the way that the content is registered, we know that it
// tallies.
// TODO: Slightly unsure about cast to D, I think it's correct in our case
ContentBuilderFactory contentBuilderFactory =
(ContentBuilderFactory) builders.get(contentClass);
return Optional.ofNullable(contentBuilderFactory);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy