Class PathGenerator


  • public class PathGenerator
    extends java.lang.Object
    Path 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.String covertPath​(java.lang.String name)  
      static java.lang.String covertPathName​(java.lang.String name)
      Get the configuration name of the specified element.
      @Nullable java.lang.String getClassPath​(@NotNull ConfigurationHolder<?> holder, @Nullable java.lang.String parentPath, @NotNull java.lang.Class<?> clazz, @Nullable java.lang.reflect.Field clazzField)  
      @Nullable java.lang.String getFieldPath​(@NotNull ConfigurationHolder<?> holder, @Nullable java.lang.String parentPath, @NotNull java.lang.reflect.Field field)  
      @NotNull java.util.function.UnaryOperator<java.lang.String> getPathConverter()  
      static boolean isBlank​(java.lang.String path)  
      protected @Nullable java.lang.String link​(@NotNull ConfigurationHolder<?> holder, @Nullable java.lang.String parent, boolean root, @Nullable java.lang.String path)  
      static PathGenerator of()  
      static PathGenerator of​(java.util.function.UnaryOperator<java.lang.String> pathConverter)  
      static char pathSeparator​(ConfigurationHolder<?> holder)  
      protected java.lang.String select​(java.lang.String path, java.lang.String defaultValue)  
      void setPathConverter​(java.util.function.UnaryOperator<java.lang.String> pathConverter)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pathConverter

        protected java.util.function.UnaryOperator<java.lang.String> pathConverter
    • Constructor Detail

      • PathGenerator

        public PathGenerator​(java.util.function.UnaryOperator<java.lang.String> pathConverter)
    • Method Detail

      • 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)
      • 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