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

com.atlassian.bamboo.specs.codegen.emitters.plan.PlanIdentifierEmitter Maven / Gradle / Ivy

There is a newer version: 10.1.0
Show newest version
package com.atlassian.bamboo.specs.codegen.emitters.plan;

import com.atlassian.bamboo.specs.api.builders.plan.PlanIdentifier;
import com.atlassian.bamboo.specs.api.codegen.CodeEmitter;
import com.atlassian.bamboo.specs.api.codegen.CodeGenerationContext;
import com.atlassian.bamboo.specs.api.codegen.CodeGenerationException;
import com.atlassian.bamboo.specs.api.model.plan.PlanIdentifierProperties;
import com.atlassian.bamboo.specs.codegen.emitters.value.EntityPropertiesEmitter;
import com.atlassian.bamboo.specs.codegen.emitters.value.LiteralEmitter;
import org.jetbrains.annotations.NotNull;

public class PlanIdentifierEmitter extends EntityPropertiesEmitter implements CodeEmitter {
    @Override
    protected void initBuilderClass(@NotNull PlanIdentifierProperties entity) throws CodeGenerationException {
        builderClass = PlanIdentifier.class;
    }

    @Override
    protected String emitConstructorInvocation(@NotNull CodeGenerationContext context, @NotNull PlanIdentifierProperties entity) throws CodeGenerationException {
        context.importClassName(PlanIdentifier.class);
        LiteralEmitter literalEmitter = new LiteralEmitter();
        if (entity.isFullKeyDefined()) {
            fieldsToSkip.add("key");
            fieldsToSkip.add("projectKey");
            return "new PlanIdentifier("
                    + literalEmitter.emitCode(context, entity.getProjectKey().getKey())
                    + ", "
                    + literalEmitter.emitCode(context, entity.getKey().getKey())
                    + ")";
        } else {
            fieldsToSkip.add("oid");
            return "new PlanIdentifier("
                    + literalEmitter.emitCode(context, entity.getOid().getOid())
                    + ")";
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy