io.polyapi.plugin.model.generation.ResolvedContext Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of polyapi-maven-plugin Show documentation
Show all versions of polyapi-maven-plugin Show documentation
Maven plugin to run handle Poly API functions.
package io.polyapi.plugin.model.generation;
import io.polyapi.plugin.model.specification.resolved.*;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@Getter
public class ResolvedContext implements Generable {
private final String name;
private final String packageName;
private final Set imports;
private final String className;
private final List subcontexts;
private final List specifications;
public ResolvedContext(String name, String packageName, Set imports, String className, List subcontexts, List specifications) {
this.packageName = packageName;
this.imports = imports;
this.name = name;
this.className = className;
this.subcontexts = new ArrayList<>();
Optional.ofNullable(subcontexts).ifPresent(this.subcontexts::addAll);
this.specifications = new ArrayList<>();
Optional.ofNullable(specifications).ifPresent(this.specifications::addAll);
}
public List getServerFunctionSpecifications() {
return filterSpecifications(ResolvedServerFunctionSpecification.class);
}
public List getCustomFunctionSpecifications() {
return filterSpecifications(ResolvedCustomFunctionSpecification.class);
}
public List getApiFunctionSpecifications() {
return filterSpecifications(ResolvedApiFunctionSpecification.class);
}
public List getAuthFunctionSpecification() {
return filterSpecifications(ResolvedAuthFunctionSpecification.class);
}
public List getSubresourceAuthFunctionSpecifications() {
return filterSpecifications(ResolvedSubresourceAuthFunctionSpecification.class);
}
public List getStandardAuthFunctionSpecifications() {
return filterSpecifications(ResolvedStandardAuthFunctionSpecification.class);
}
public List getServerVariableSpecifications() {
return filterSpecifications(ResolvedServerVariableSpecification.class);
}
public List getWebhookHandlerSpecifications() {
return filterSpecifications(ResolvedWebhookHandleSpecification.class);
}
public List getFunctionSpecifications() {
return filterSpecifications(ResolvedDefaultFunctionSpecification.class);
}
private List filterSpecifications(Class resolvedSpecificationClass) {
return specifications.stream().filter(resolvedSpecificationClass::isInstance).map(resolvedSpecificationClass::cast).toList();
}
}