Class ConfigUtils


  • public class ConfigUtils
    extends java.lang.Object
    The Class ConfigUtils.
    • Field Detail

      • defaultPrimitiveValues

        public static java.util.Map<java.lang.Class<?>,​java.lang.Object> defaultPrimitiveValues
        The default primitive values.
    • Method Detail

      • newPluginConfigNoPath

        public static PluginConfigDataHandler newPluginConfigNoPath​(java.lang.Class<? extends CometEntity> clazz,
                                                                    int newId,
                                                                    java.lang.String login)
                                                             throws CometException
        New plugin config no path.
        Parameters:
        clazz - the class
        newId - the new id
        login - the login
        Returns:
        the plugin config data handler
        Throws:
        CometException - the comet exception
      • newPluginConfig

        public static PluginConfigDataHandler newPluginConfig​(java.lang.Class<? extends CometEntity> clazz,
                                                              int newId,
                                                              java.lang.String login)
                                                       throws CometException
        New plugin config.
        Parameters:
        clazz - the class
        newId - the new id
        login - the login
        Returns:
        the plugin config data handler
        Throws:
        CometException - the comet exception
      • newPluginConfig

        public static PluginConfigDataHandler newPluginConfig​(java.lang.Class<? extends CometEntity> clazz,
                                                              int newId,
                                                              java.lang.String login,
                                                              java.lang.String rootPath)
                                                       throws CometException
        New plugin config.
        Parameters:
        clazz - the class
        newId - the new id
        login - the login
        rootPath - the root path
        Returns:
        the plugin config data handler
        Throws:
        CometException - the comet exception
      • newPluginConfig

        public static PluginConfigDataHandler newPluginConfig​(java.lang.Class<? extends CometEntity> clazz,
                                                              int newId,
                                                              java.lang.String login,
                                                              java.lang.String rootPath,
                                                              boolean calculatePath)
                                                       throws CometException
        New plugin config.
        Parameters:
        clazz - the class
        newId - the new id
        login - the login
        rootPath - the root path
        calculatePath - the calculate path
        Returns:
        the plugin config data handler
        Throws:
        CometException - the comet exception
      • getEmbeddedEntity

        public static <T extends CometEntity> T getEmbeddedEntity​(PluginConfigDataHandler container,
                                                                  java.lang.Class<T> clazz)
                                                           throws CometException

        Get the embedded CometEntity custom configuration from a PluginConfig container.

        We assume, that there is exactly one item of the expected type embedded in this PluginConfig, otherwise an Exception is raised.

        Type Parameters:
        T - the generic type
        Parameters:
        container - the container
        clazz - the clazz
        Returns:
        the custom configuration embedded in this container
        Throws:
        CometException - the comet exception
      • setEmbeddedEntity

        public static <T extends CometEntity> void setEmbeddedEntity​(PluginConfigDataHandler container,
                                                                     T entity)
                                                              throws CometException
        Sets the embedded entity.
        Type Parameters:
        T - the generic type
        Parameters:
        container - the container
        entity - the entity
        Throws:
        CometException - the comet exception
      • dependencyExists

        public static boolean dependencyExists​(PluginConfigDataHandler container,
                                               java.lang.String uri)
                                        throws CometException
        Dependency exists.
        Parameters:
        container - the container
        uri - the uri
        Returns:
        true, if successful
        Throws:
        CometException - the comet exception
      • removeFromIndex

        public static void removeFromIndex​(PluginConfigDataHandler indexContainer,
                                           java.lang.String uri)
                                    throws CometException
        Removes the from index.
        Parameters:
        indexContainer - the index container
        uri - the uri
        Throws:
        CometException - the comet exception
      • removeDependency

        public static boolean removeDependency​(PluginConfigDataHandler container,
                                               java.lang.String uri)
                                        throws CometException
        Removes the dependency.
        Parameters:
        container - the container
        uri - the uri
        Returns:
        true, if successful
        Throws:
        CometException - the comet exception
      • getClassesString

        public static java.lang.String getClassesString​(java.lang.Class<?>[] classes)
        Gets the classes string.
        Parameters:
        classes - the classes
        Returns:
        the classes string
      • getClassesString

        public static java.lang.String getClassesString​(java.lang.Class<?>[] classes,
                                                        java.lang.String delimiter)
        Gets the classes string.
        Parameters:
        classes - the classes
        delimiter - the delimiter
        Returns:
        the classes string
      • getObjectSkeleton

        public static <T> T getObjectSkeleton​(java.lang.Class<T> clazz)
        Gets the object skeleton.
        Type Parameters:
        T - the generic type
        Parameters:
        clazz - the class
        Returns:
        the object skeleton
      • getObjectSkeleton

        public static <T> T getObjectSkeleton​(java.lang.Class<T> clazz,
                                              java.util.Map<java.lang.Class<?>,​java.lang.Object> defaultValues)
        Gets the object skeleton.
        Type Parameters:
        T - the generic type
        Parameters:
        clazz - the class
        defaultValues - the default values
        Returns:
        the object skeleton
      • getObjectSkeleton

        public static <T> T getObjectSkeleton​(java.lang.Class<T> clazz,
                                              java.util.List<java.lang.Class<?>> usedClasses,
                                              java.util.Map<java.lang.Class<?>,​java.lang.Object> defaultValues)
        Gets the object skeleton.
        Type Parameters:
        T - the generic type
        Parameters:
        clazz - the class
        usedClasses - the used classes
        defaultValues - the default values
        Returns:
        the object skeleton
      • initializeObject

        public static <T> T initializeObject​(T target)
        Initialize object.
        Type Parameters:
        T - the generic type
        Parameters:
        target - the target
        Returns:
        the t
      • initializeObject

        public static <T> T initializeObject​(T target,
                                             java.util.Map<java.lang.Class<?>,​java.lang.Object> defaultValues)
        Initialize object.
        Type Parameters:
        T - the generic type
        Parameters:
        target - the target
        defaultValues - the default values
        Returns:
        the t
      • initializeObject

        public static <T> T initializeObject​(T target,
                                             java.util.List<java.lang.Class<?>> usedClasses,
                                             java.util.Map<java.lang.Class<?>,​java.lang.Object> defaultValues)
        Initialize object.
        Type Parameters:
        T - the generic type
        Parameters:
        target - the target
        usedClasses - the used classes
        defaultValues - the default values
        Returns:
        the t
      • getConfigSkeleton

        public static <T extends java.io.Serializable> PluginConfigDataHandler getConfigSkeleton​(java.lang.Class<T> clazz)
        Gets the config skeleton.
        Type Parameters:
        T - the generic type
        Parameters:
        clazz - the class
        Returns:
        the config skeleton
      • getConfigSkeleton

        public static <T extends java.io.Serializable> PluginConfigDataHandler getConfigSkeleton​(java.lang.Class<T> clazz,
                                                                                                 java.util.Map<java.lang.Class<?>,​java.lang.Object> defaultValues)
        Gets the config skeleton.
        Type Parameters:
        T - the generic type
        Parameters:
        clazz - the class
        defaultValues - the default values
        Returns:
        the config skeleton
      • cast

        public static java.lang.Object cast​(java.lang.reflect.Field target,
                                            java.lang.Object value)
        Cast.
        Parameters:
        target - the target
        value - the value
        Returns:
        the object
      • createContextRule

        public static PluginMethod createContextRule​(java.lang.String methodName)
        Creates the context rule.
        Parameters:
        methodName - the method name
        Returns:
        the plugin method
      • findFieldWithValue

        public static ConfigUtils.ObjectField findFieldWithValue​(java.lang.Object item,
                                                                 java.lang.String fieldName,
                                                                 java.lang.Object value)
                                                          throws CometException
        Find field with value.
        Parameters:
        item - the item
        fieldName - the field name
        value - the value
        Returns:
        the object field
        Throws:
        CometException - the comet exception
      • findField

        public static ConfigUtils.ObjectField findField​(java.lang.Object item,
                                                        java.lang.String fieldName)
                                                 throws CometException
        Find field.
        Parameters:
        item - the item
        fieldName - the field name
        Returns:
        the object field
        Throws:
        CometException - the comet exception
      • isInSameProject

        public static boolean isInSameProject​(java.lang.String path1,
                                              java.lang.String path2)
        Checks if is in same project.
        Parameters:
        path1 - the path 1
        path2 - the path 2
        Returns:
        true, if is in same project
      • isInSameProject

        public static boolean isInSameProject​(PluginConfigDataHandler config1,
                                              PluginConfigDataHandler config2)
        Checks if is in same project.
        Parameters:
        config1 - the config 1
        config2 - the config 2
        Returns:
        true, if is in same project