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

org.raml.ramltopojo.extensions.tools.BoxWhenNotRequired Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
package org.raml.ramltopojo.extensions.tools;

import com.squareup.javapoet.TypeName;
import org.raml.ramltopojo.extensions.ReferencePluginContext;
import org.raml.ramltopojo.extensions.ReferenceTypeHandlerPlugin;
import org.raml.v2.api.model.v10.datamodel.TypeDeclaration;

import java.util.List;

/**
 * Created. There, you have it.
 */
public class BoxWhenNotRequired implements ReferenceTypeHandlerPlugin {

    private final List arguments;

    public BoxWhenNotRequired(List arguments) {
        this.arguments = arguments;
    }

    @Override
    public TypeName typeName(ReferencePluginContext referencePluginContext, TypeDeclaration ramlType, TypeName currentSuggestion) {

        if (! ramlType.required()) {
            return currentSuggestion.box();
        } else {
            return currentSuggestion;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy