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

io.swagger.codegen.mustache.LowercaseLambda Maven / Gradle / Ivy

There is a newer version: 3.0.0-rc1
Show newest version
package io.swagger.codegen.mustache;

import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import io.swagger.codegen.CodegenConfig;

import java.io.IOException;
import java.io.Writer;

/**
 * Converts text in a fragment to lowercase.
 *
 * Register:
 * 
 * additionalProperties.put("lowercase", new LowercaseLambda());
 * 
* * Use: *
 * {{#lowercase}}{{httpMethod}}{{/lowercase}}
 * 
*/ public class LowercaseLambda implements Mustache.Lambda { private CodegenConfig generator = null; public LowercaseLambda() { } public LowercaseLambda generator(final CodegenConfig generator) { this.generator = generator; return this; } @Override public void execute(Template.Fragment fragment, Writer writer) throws IOException { String text = fragment.execute().toLowerCase(); if (generator != null && generator.reservedWords().contains(text)) { text = generator.escapeReservedWord(text); } writer.write(text); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy