Package io.protostuff.compiler
Enum Formatter.BUILTIN
- java.lang.Object
-
- java.lang.Enum<Formatter.BUILTIN>
-
- io.protostuff.compiler.Formatter.BUILTIN
-
- All Implemented Interfaces:
Formatter
,java.io.Serializable
,java.lang.Comparable<Formatter.BUILTIN>
- Enclosing interface:
- Formatter
public static enum Formatter.BUILTIN extends java.lang.Enum<Formatter.BUILTIN> implements Formatter
Built-in formatters.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.protostuff.compiler.Formatter
Formatter.BUILTIN
-
-
Enum Constant Summary
Enum Constants Enum Constant Description CC
camel-case.CCU
camel-case with trailing underscore.CUT_L
CUT_R
LOWER
lowercase.PC
pascal-case.PCS
pascal-case with space in between.PLURAL
Transform word in singular form to plural form.PSC
Same as PCS but with the more correct name :/.SINGULAR
Transform word in plural form to singular form.TRIM
UC
underscore-case.UCU
underscore-case with trailing underscore.UPPER
uppercase.UUC
"uppercased" underscore-case.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<java.lang.String[]>
irregulars
private static java.util.List<java.lang.String[]>
plurals
private static java.util.List<java.lang.String[]>
singulars
private static java.util.List<java.lang.String>
uncountables
-
Constructor Summary
Constructors Modifier Constructor Description private
BUILTIN()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addAllTo(java.util.Map<java.lang.String,Formatter> map)
Add all the builtin formatters to the map using the enum's name as key.private static void
addIrregular(java.lang.String rule, java.lang.String replacement)
private static void
addPlural(java.lang.String rule, java.lang.String replacement)
private static void
addSingular(java.lang.String rule, java.lang.String replacement)
private static java.lang.String
gsub(java.lang.String word, java.lang.String rule, java.lang.String replacement)
Replaces a found pattern in a word and returns a transformed word.private static java.lang.String
pluralize(java.lang.String word)
private static java.lang.String
singularize(java.lang.String word)
static Formatter.BUILTIN
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static Formatter.BUILTIN[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
UPPER
public static final Formatter.BUILTIN UPPER
uppercase.
-
LOWER
public static final Formatter.BUILTIN LOWER
lowercase.
-
CC
public static final Formatter.BUILTIN CC
camel-case.some_foo/SomeFoo becomes someFoo
-
CCU
public static final Formatter.BUILTIN CCU
camel-case with trailing underscore.some_foo/SomeFoo/someFoo becomes someFoo_
-
UC
public static final Formatter.BUILTIN UC
underscore-case.someFoo/SomeFoo becomes some_foo
-
UCU
public static final Formatter.BUILTIN UCU
underscore-case with trailing underscore.someFoo/SomeFoo/some_foo becomes some_foo_
-
UUC
public static final Formatter.BUILTIN UUC
"uppercased" underscore-case.someFoo/SomeFoo/some_foo becomes SOME_FOO
-
PC
public static final Formatter.BUILTIN PC
pascal-case.some_foo/someFoo becomes SomeFoo
-
PCS
public static final Formatter.BUILTIN PCS
pascal-case with space in between.someFoo/some_foo/SomeFoo becomes "Some Foo"
-
PSC
public static final Formatter.BUILTIN PSC
Same as PCS but with the more correct name :/.The space "S" is really in-between.
-
PLURAL
public static final Formatter.BUILTIN PLURAL
Transform word in singular form to plural form. If given word is already in the plural form, it should not be changed. Please not that this formatter does not guarantee that all words can be transformed correctly. The implementation was cloned from https://github.com/javalite/activejdbc/blob/master/javalite-common/src/main /java/org/javalite/common/Inflector.java Copyright 2009-2014 Igor Polevoy Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
SINGULAR
public static final Formatter.BUILTIN SINGULAR
Transform word in plural form to singular form. If given word is already in the singular form, it should not be changed. Please not that this formatter does not guarantee that all words can be transformed correctly. The implementation was cloned from https://github.com/javalite/activejdbc/blob/master/javalite-common/src/main /java/org/javalite/common/Inflector.java Copyright 2009-2014 Igor Polevoy Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
-
TRIM
public static final Formatter.BUILTIN TRIM
-
CUT_L
public static final Formatter.BUILTIN CUT_L
-
CUT_R
public static final Formatter.BUILTIN CUT_R
-
-
Method Detail
-
values
public static Formatter.BUILTIN[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Formatter.BUILTIN c : Formatter.BUILTIN.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Formatter.BUILTIN valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
addPlural
private static void addPlural(java.lang.String rule, java.lang.String replacement)
-
addSingular
private static void addSingular(java.lang.String rule, java.lang.String replacement)
-
addIrregular
private static void addIrregular(java.lang.String rule, java.lang.String replacement)
-
gsub
private static java.lang.String gsub(java.lang.String word, java.lang.String rule, java.lang.String replacement)
Replaces a found pattern in a word and returns a transformed word. Null is pattern does not match.
-
pluralize
private static java.lang.String pluralize(java.lang.String word)
-
singularize
private static java.lang.String singularize(java.lang.String word)
-
addAllTo
public static void addAllTo(java.util.Map<java.lang.String,Formatter> map)
Add all the builtin formatters to the map using the enum's name as key.
-
-