uk.autores.processors.ResourceContexts Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of annotations Show documentation
Show all versions of annotations Show documentation
Annotation driven library for handling embedded resources
// Copyright 2024 https://github.com/autores-uk/autores/blob/main/LICENSE.txt
// SPDX-License-Identifier: Apache-2.0
package uk.autores.processors;
import uk.autores.Processing;
import uk.autores.handling.Config;
import uk.autores.handling.Handler;
import uk.autores.handling.ResourceFiles;
import uk.autores.repeat.RepeatableResources;
import javax.annotation.processing.ProcessingEnvironment;
import java.util.ArrayList;
import java.util.List;
final class ResourceContexts extends ContextFactory {
ResourceContexts(ProcessingEnvironment env) {
super(env, ResourceFiles.class, RepeatableResources.class);
}
@Override
Handler handler(ResourceFiles single) {
return instance(single::handler);
}
@Override
List config(ResourceFiles resourceFiles) {
List configs = new ArrayList<>();
for (ResourceFiles.Cfg c : resourceFiles.config()) {
configs.add(new Config(c.key(), c.value()));
}
return configs;
}
@Override
ResourceFiles[] expand(RepeatableResources repeating) {
return repeating.value();
}
@Override
Processing processing(ResourceFiles single) {
return single.processing();
}
@Override
String[] resources(ResourceFiles single) {
return single.value();
}
static AnnotationDef, ?> def() {
return new AnnotationDef<>(ResourceFiles.class, RepeatableResources.class, ResourceContexts::new);
}
}