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

com.github.timm.cucumber.generate.name.PatternNamingScheme Maven / Gradle / Ivy

There is a newer version: 5.0.0
Show newest version
package com.github.timm.cucumber.generate.name;

/**
 * Generate a Class Name based on a pattern.
 *
 * 

* No validation is performed to ensure that the generated class name is valid. *

* *

* The following placeholders are supported: *

*
    *
  • '{f}' - The feature file, converted using supplied naming scheem.
  • *
  • '{c}' - A one-up number, formatted to have minimum 2 character width.
  • *
*/ public class PatternNamingScheme implements ClassNamingScheme { private final String pattern; private final Counter counter; private final ClassNamingScheme featureFileNamingScheme; /** * @param pattern The pattern to use. * @param counter Counter to generate one up numbers * @param featureFileNamingScheme Naming scheme to use for '{f}' placeholder */ public PatternNamingScheme(final String pattern, final Counter counter, final ClassNamingScheme featureFileNamingScheme) { this.pattern = pattern; this.counter = counter; this.featureFileNamingScheme = featureFileNamingScheme; } /** * @param featureFileName The feature file to generate a class name for * @return A class name based on the required pattern. */ public String generate(final String featureFileName) { String className = pattern.replace("{f}", featureFileNamingScheme.generate(featureFileName)); className = className.replace("{c}", String.format("%02d", counter.next())); return className; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy