com.codepoetics:navn

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

GroupId

GroupId

com.codepoetics
ArtifactId

ArtifactId

navn
Last Version

Last Version

0.3
Release Date

Release Date

Type

Type

jar
Description

Description

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Source Code Management

Source Code Management

http://github.com/poetix/navn

Download navn

How to add to project

<!-- https://jarcasting.com/artifacts/com.codepoetics/navn/ -->
<dependency>
    <groupId>com.codepoetics</groupId>
    <artifactId>navn</artifactId>
    <version>0.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.codepoetics/navn/
implementation 'com.codepoetics:navn:0.3'
// https://jarcasting.com/artifacts/com.codepoetics/navn/
implementation ("com.codepoetics:navn:0.3")
'com.codepoetics:navn:jar:0.3'
<dependency org="com.codepoetics" name="navn" rev="0.3">
  <artifact name="navn" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.codepoetics', module='navn', version='0.3')
)
libraryDependencies += "com.codepoetics" % "navn" % "0.3"
[com.codepoetics/navn "0.3"]

Dependencies

compile (1)

Group / Artifact Type Version
com.codepoetics : protonpack jar 1.3

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.hamcrest : hamcrest-library jar 1.3

Project Modules

There are no modules declared in this project.

navn

Build Status

Name munging for Java 8 (camel case to underscore, etc)

In maven:

<dependency>
    <groupId>com.codepoetics</groupId>
    <artifactId>navn</artifactId>
    <version>0.3</version>
</dependency>

Example usage:

Name name = Name.of("XML to CSV converter");

assertThat(name.toTitleCase(), equalTo("XMLToCSVConverter"));

// Don't uppercase acronyms
assertThat(name.toTitleCase(false), equalTo("XmlToCsvConverter"));

assertThat(name.toUnderscored(), equalTo("xml_to_csv_converter"));
assertThat(name.toConstant(), equalTo("XML_TO_CSV_CONVERTER"));
assertThat(name.toAddress(), equalTo("XML To CSV Converter"));

assertThat(Name.of("foo_bar_baz").toCamelCase(), equalTo("fooBarBaz"));
assertThat(Name.of("std::io", ':').toHyphenated(FormattingOptions.UPPERCASE),
        equalTo("STD-IO"));

// Selective uppercasing
assertThat(Name.of("xml_to_csv_converter").uppercasing("csv").toCamelCase(),
        equalTo("xmlToCSVConverter"));

// Prefix munging
assertThat(Name.of("getDateOfBirth").withoutFirst().toUnderscored(),
        equalTo("date_of_birth"));
assertThat(Name.of("size_of_head").withPrefix("get").toCamelCase(),
        equalTo("getSizeOfHead"));

// Disambiguation
assertThat(Name.of("foo-bar_baz-xyzzy", SourceFormat.UNDERSCORE_SEPARATED).toSeparated(),
        equalTo("foo-bar baz-xyzzy"));
assertThat(Name.of("foo-bar_baz-xyzzy", SourceFormat.HYPHEN_SEPARATED).toSeparated(),
        equalTo("foo bar_baz xyzzy"));
assertThat(Name.of("foo-bar_baz-xyzzy", "[_-]+").toSeparated(),
        equalTo("foo bar baz xyzzy"));

// Double-barrelled
assertThat(Name.of("martina_topley-bird", SourceFormat.UNDERSCORE_SEPARATED)
        .map(s -> Name.of(s).toHyphenated(FormattingOptions.CAPITALISE_ALL))
        .toSeparated(),
        equalTo("Martina Topley-Bird"));

Versions

Version
0.3
0.2
0.1