Package com.priint.pubserver.comet.util
Class ConfigUtils
- java.lang.Object
-
- com.priint.pubserver.comet.util.ConfigUtils
-
public class ConfigUtils extends java.lang.ObjectThe Class ConfigUtils.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConfigUtils.ObjectFieldThe Class ObjectField.
-
Field Summary
Fields Modifier and Type Field Description static java.util.Map<java.lang.Class<?>,java.lang.Object>defaultPrimitiveValuesThe default primitive values.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanaddOrUpdateDependency(PluginConfigDataHandler container, java.lang.String uri, PluginConfigDependencyRestriction restriction)Adds the or update dependency.static voidaddToIndex(PluginConfigDataHandler indexContainer, java.lang.String uri, java.lang.String label, PluginConfigDependencyRestriction restriction)Adds the to index.static java.lang.Objectcast(java.lang.reflect.Field target, java.lang.Object value)Cast.static PluginMethodcreateContextRule(java.lang.String methodName)Creates the context rule.static booleandependencyExists(PluginConfigDataHandler container, java.lang.String uri)Dependency exists.static ConfigUtils.ObjectFieldfindField(java.lang.Object item, java.lang.String fieldName)Find field.static ConfigUtils.ObjectFieldfindFieldWithValue(java.lang.Object item, java.lang.String fieldName, java.lang.Object value)Find field with value.static java.lang.StringgetClassesString(java.lang.Class<?>[] classes)Gets the classes string.static java.lang.StringgetClassesString(java.lang.Class<?>[] classes, java.lang.String delimiter)Gets the classes string.static <T extends java.io.Serializable>
PluginConfigDataHandlergetConfigSkeleton(java.lang.Class<T> clazz)Gets the config skeleton.static <T extends java.io.Serializable>
PluginConfigDataHandlergetConfigSkeleton(java.lang.Class<T> clazz, java.util.Map<java.lang.Class<?>,java.lang.Object> defaultValues)Gets the config skeleton.static <T extends CometEntity>
TgetEmbeddedEntity(PluginConfigDataHandler container, java.lang.Class<T> clazz)Get the embedded CometEntity custom configuration from a PluginConfig container.static <T> TgetObjectSkeleton(java.lang.Class<T> clazz)Gets the object skeleton.static <T> TgetObjectSkeleton(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.static <T> TgetObjectSkeleton(java.lang.Class<T> clazz, java.util.Map<java.lang.Class<?>,java.lang.Object> defaultValues)Gets the object skeleton.static <T> TinitializeObject(T target)Initialize object.static <T> TinitializeObject(T target, java.util.List<java.lang.Class<?>> usedClasses, java.util.Map<java.lang.Class<?>,java.lang.Object> defaultValues)Initialize object.static <T> TinitializeObject(T target, java.util.Map<java.lang.Class<?>,java.lang.Object> defaultValues)Initialize object.static booleanisInSameProject(PluginConfigDataHandler config1, PluginConfigDataHandler config2)Checks if is in same project.static booleanisInSameProject(java.lang.String path1, java.lang.String path2)Checks if is in same project.static PluginConfigDataHandlernewPluginConfig(java.lang.Class<? extends CometEntity> clazz, int newId, java.lang.String login)New plugin config.static PluginConfigDataHandlernewPluginConfig(java.lang.Class<? extends CometEntity> clazz, int newId, java.lang.String login, java.lang.String rootPath)New plugin config.static PluginConfigDataHandlernewPluginConfig(java.lang.Class<? extends CometEntity> clazz, int newId, java.lang.String login, java.lang.String rootPath, boolean calculatePath)New plugin config.static PluginConfigDataHandlernewPluginConfigNoPath(java.lang.Class<? extends CometEntity> clazz, int newId, java.lang.String login)New plugin config no path.static booleanremoveDependency(PluginConfigDataHandler container, java.lang.String uri)Removes the dependency.static voidremoveFromIndex(PluginConfigDataHandler indexContainer, java.lang.String uri)Removes the from index.static <T extends CometEntity>
voidsetEmbeddedEntity(PluginConfigDataHandler container, T entity)Sets the embedded entity.
-
-
-
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 classnewId- the new idlogin- 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 classnewId- the new idlogin- 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 classnewId- the new idlogin- the loginrootPath- 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 classnewId- the new idlogin- the loginrootPath- the root pathcalculatePath- 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 containerclazz- 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 containerentity- the entity- Throws:
CometException- the comet exception
-
addOrUpdateDependency
public static boolean addOrUpdateDependency(PluginConfigDataHandler container, java.lang.String uri, PluginConfigDependencyRestriction restriction) throws CometException
Adds the or update dependency.- Parameters:
container- the containeruri- the urirestriction- the restriction- Returns:
- true, if successful
- Throws:
CometException- the comet exception
-
dependencyExists
public static boolean dependencyExists(PluginConfigDataHandler container, java.lang.String uri) throws CometException
Dependency exists.- Parameters:
container- the containeruri- the uri- Returns:
- true, if successful
- Throws:
CometException- the comet exception
-
addToIndex
public static void addToIndex(PluginConfigDataHandler indexContainer, java.lang.String uri, java.lang.String label, PluginConfigDependencyRestriction restriction) throws CometException
Adds the to index.- Parameters:
indexContainer- the index containeruri- the urilabel- the labelrestriction- the restriction- 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 containeruri- 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 containeruri- 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 classesdelimiter- 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 classdefaultValues- 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 classusedClasses- the used classesdefaultValues- 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 targetdefaultValues- 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 targetusedClasses- the used classesdefaultValues- 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 classdefaultValues- 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 targetvalue- 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 itemfieldName- the field namevalue- 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 itemfieldName- 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 1path2- 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 1config2- the config 2- Returns:
- true, if is in same project
-
-