Class ConfigUtils

java.lang.Object
com.priint.pubserver.comet.util.ConfigUtils

public class ConfigUtils extends Object
The Class ConfigUtils.
  • Field Details

    • defaultPrimitiveValues

      public static Map<Class<?>,Object> defaultPrimitiveValues
      The default primitive values.
  • Method Details

    • newPluginConfigNoPath

      public static PluginConfigDataHandler newPluginConfigNoPath(Class<? extends CometEntity> clazz, int newId, 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(Class<? extends CometEntity> clazz, int newId, 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(Class<? extends CometEntity> clazz, int newId, String login, 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(Class<? extends CometEntity> clazz, int newId, String login, 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, 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
    • addOrUpdateDependency

      public static boolean addOrUpdateDependency(PluginConfigDataHandler container, String uri, PluginConfigDependencyRestriction restriction) throws CometException
      Adds the or update dependency.
      Parameters:
      container - the container
      uri - the uri
      restriction - the restriction
      Returns:
      true, if successful
      Throws:
      CometException - the comet exception
    • dependencyExists

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

      public static void addToIndex(PluginConfigDataHandler indexContainer, String uri, String label, PluginConfigDependencyRestriction restriction) throws CometException
      Adds the to index.
      Parameters:
      indexContainer - the index container
      uri - the uri
      label - the label
      restriction - the restriction
      Throws:
      CometException - the comet exception
    • removeFromIndex

      public static void removeFromIndex(PluginConfigDataHandler indexContainer, 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, 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 String getClassesString(Class<?>[] classes)
      Gets the classes string.
      Parameters:
      classes - the classes
      Returns:
      the classes string
    • getClassesString

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

      public static <T> T getObjectSkeleton(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(Class<T> clazz, Map<Class<?>,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(Class<T> clazz, List<Class<?>> usedClasses, Map<Class<?>,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, Map<Class<?>,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, List<Class<?>> usedClasses, Map<Class<?>,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 Serializable> PluginConfigDataHandler getConfigSkeleton(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 Serializable> PluginConfigDataHandler getConfigSkeleton(Class<T> clazz, Map<Class<?>,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 Object cast(Field target, Object value)
      Cast.
      Parameters:
      target - the target
      value - the value
      Returns:
      the object
    • createContextRule

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

      public static ConfigUtils.ObjectField findFieldWithValue(Object item, String fieldName, 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(Object item, 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(String path1, 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