All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.autores.processors.ResourceContexts Maven / Gradle / Ivy

There is a newer version: 11.0.35-beta
Show newest version
// 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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy