Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
3b365039
Unverified
Commit
3b365039
authored
Sep 06, 2016
by
Guus der Kinderen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OF-1189: New getEnumProperty implementation.
parent
0b0dc85e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
15 deletions
+33
-15
JiveGlobals.java
src/java/org/jivesoftware/util/JiveGlobals.java
+33
-15
No files found.
src/java/org/jivesoftware/util/JiveGlobals.java
View file @
3b365039
...
...
@@ -20,28 +20,19 @@
package
org
.
jivesoftware
.
util
;
import
org.apache.commons.lang.StringUtils
;
import
org.jivesoftware.database.DbConnectionManager
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.File
;
import
java.io.IOException
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.SQLException
;
import
java.text.DateFormat
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.Map.Entry
;
import
java.util.TimeZone
;
import
java.util.TimerTask
;
import
org.apache.commons.lang.StringUtils
;
import
org.jivesoftware.database.DbConnectionManager
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* Controls Jive properties. Jive properties are only meant to be set and retrieved
...
...
@@ -565,6 +556,33 @@ public class JiveGlobals {
}
}
/**
* Returns an enum constant Jive property. If the specified property doesn't exist, or if it's value cannot be parsed
* as an enum constant, the <tt>defaultValue</tt> will be returned.
*
* @param name the name of the property to return.
* @param enumType the {@code Class} object of the enum type from which to return a constant.
* @param defaultValue value returned if the property doesn't exist or it's value could not be parsed.
* @param <E> The enum type whose constant is to be returned.
* @return the property value (as an enum constant) or <tt>defaultValue</tt>.
*/
public
static
<
E
extends
Enum
<
E
>>
E
getEnumProperty
(
String
name
,
Class
<
E
>
enumType
,
E
defaultValue
)
{
String
value
=
getProperty
(
name
);
if
(
value
!=
null
)
{
try
{
return
E
.
valueOf
(
enumType
,
value
);
}
catch
(
IllegalArgumentException
e
)
{
// Ignore
}
}
return
defaultValue
;
}
/**
* Returns an integer value Jive property. If the specified property doesn't exist, the
* <tt>defaultValue</tt> will be returned.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment