Class PathGenerator
- java.lang.Object
-
- cc.carm.lib.configuration.source.loader.PathGenerator
-
public class PathGenerator extends java.lang.ObjectPath generator for configuration.Path generator is a utility class that helps to generate the path of the configuration. It can be used to generate the path of the field or class.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.function.UnaryOperator<java.lang.String>pathConverter
-
Constructor Summary
Constructors Constructor Description PathGenerator(java.util.function.UnaryOperator<java.lang.String> pathConverter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringcovertPath(java.lang.String name)static java.lang.StringcovertPathName(java.lang.String name)Get the configuration name of the specified element.@Nullable java.lang.StringgetClassPath(@NotNull ConfigurationHolder<?> holder, @Nullable java.lang.String parentPath, @NotNull java.lang.Class<?> clazz, @Nullable java.lang.reflect.Field clazzField)@Nullable java.lang.StringgetFieldPath(@NotNull ConfigurationHolder<?> holder, @Nullable java.lang.String parentPath, @NotNull java.lang.reflect.Field field)@NotNull java.util.function.UnaryOperator<java.lang.String>getPathConverter()static booleanisBlank(java.lang.String path)protected @Nullable java.lang.Stringlink(@NotNull ConfigurationHolder<?> holder, @Nullable java.lang.String parent, boolean root, @Nullable java.lang.String path)static PathGeneratorof()static PathGeneratorof(java.util.function.UnaryOperator<java.lang.String> pathConverter)static charpathSeparator(ConfigurationHolder<?> holder)protected java.lang.Stringselect(java.lang.String path, java.lang.String defaultValue)voidsetPathConverter(java.util.function.UnaryOperator<java.lang.String> pathConverter)
-
-
-
Method Detail
-
of
public static PathGenerator of()
-
of
public static PathGenerator of(java.util.function.UnaryOperator<java.lang.String> pathConverter)
-
getPathConverter
@NotNull public @NotNull java.util.function.UnaryOperator<java.lang.String> getPathConverter()
-
setPathConverter
public void setPathConverter(java.util.function.UnaryOperator<java.lang.String> pathConverter)
-
covertPath
public java.lang.String covertPath(java.lang.String name)
-
getFieldPath
@Nullable public @Nullable java.lang.String getFieldPath(@NotNull @NotNull ConfigurationHolder<?> holder, @Nullable @Nullable java.lang.String parentPath, @NotNull @NotNull java.lang.reflect.Field field)
-
getClassPath
@Nullable public @Nullable java.lang.String getClassPath(@NotNull @NotNull ConfigurationHolder<?> holder, @Nullable @Nullable java.lang.String parentPath, @NotNull @NotNull java.lang.Class<?> clazz, @Nullable @Nullable java.lang.reflect.Field clazzField)
-
select
protected java.lang.String select(java.lang.String path, java.lang.String defaultValue)
-
link
@Nullable protected @Nullable java.lang.String link(@NotNull @NotNull ConfigurationHolder<?> holder, @Nullable @Nullable java.lang.String parent, boolean root, @Nullable @Nullable java.lang.String path)
-
isBlank
public static boolean isBlank(java.lang.String path)
-
pathSeparator
public static char pathSeparator(ConfigurationHolder<?> holder)
-
covertPathName
public static java.lang.String covertPathName(java.lang.String name)
Get the configuration name of the specified element. Use the naming convention of all lowercase and "-" links.e.g. "SOME_NAME" will be "some-name"
- Parameters:
name- source name- Returns:
- the final path
-
-