Search in sources :

Example 1 with NodeContext

use of com.github.benmanes.caffeine.cache.node.NodeContext in project caffeine by ben-manes.

the class NodeFactoryGenerator method addNodeSpec.

private void addNodeSpec(String className, boolean isFinal, Set<Feature> features) {
    TypeName superClass;
    Set<Feature> parentFeatures;
    Set<Feature> generateFeatures;
    if (features.size() == 2) {
        parentFeatures = ImmutableSet.of();
        generateFeatures = features;
        superClass = TypeName.OBJECT;
    } else {
        parentFeatures = ImmutableSet.copyOf(Iterables.limit(features, features.size() - 1));
        generateFeatures = ImmutableSet.of(Iterables.getLast(features));
        superClass = ParameterizedTypeName.get(ClassName.get(PACKAGE_NAME + ".NodeFactory", encode(Feature.makeClassName(parentFeatures))), kTypeVar, vTypeVar);
    }
    NodeContext context = new NodeContext(superClass, className, isFinal, parentFeatures, generateFeatures);
    for (NodeRule rule : rules) {
        rule.accept(context);
    }
    nodeFactory.addType(context.nodeSubtype.build());
    addEnumConstant(className, features);
}
Also used : TypeName(com.squareup.javapoet.TypeName) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) NodeRule(com.github.benmanes.caffeine.cache.node.NodeRule) NodeContext(com.github.benmanes.caffeine.cache.node.NodeContext)

Aggregations

NodeContext (com.github.benmanes.caffeine.cache.node.NodeContext)1 NodeRule (com.github.benmanes.caffeine.cache.node.NodeRule)1 ParameterizedTypeName (com.squareup.javapoet.ParameterizedTypeName)1 TypeName (com.squareup.javapoet.TypeName)1