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

com.hypertino.inflector.naming.DashCaseParser.scala Maven / Gradle / Ivy

package com.hypertino.inflector.naming

object DashCaseParser extends IdentifierParser {
  override def parse(identifier: String, builder: IdentifierBuilder): Unit = {
    var prevIsDash = false
    var dashConsumed = false
    for (c <- identifier) {
      if (prevIsDash) {
        builder.divider()
        builder.regular(c)
        dashConsumed = true
        prevIsDash = false
      }
      else {
        if (c == '-') {
          prevIsDash = true
          dashConsumed = false
        } else {
          builder.regular(c)
          prevIsDash = false
        }
      }
    }
    if (prevIsDash && !dashConsumed) {
      builder.regular('-')
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy