Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
c9964e64
Commit
c9964e64
authored
Jun 10, 2017
by
Greg Messner
Browse files
Initial check-in.
parent
0038a559
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/GitLabApiConstants.java
0 → 100644
View file @
c9964e64
package
org.gitlab4j.api
;
import
org.gitlab4j.api.utils.JacksonJsonEnumHelper
;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
com.fasterxml.jackson.annotation.JsonValue
;
public
interface
GitLabApiConstants
{
/** Enum to use for ordering the results of various API calls. */
public
enum
SortOrder
{
ASC
,
DESC
;
private
static
JacksonJsonEnumHelper
<
SortOrder
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
SortOrder
.
class
);
@JsonCreator
public
static
SortOrder
forValue
(
String
value
)
{
return
enumHelper
.
forValue
(
value
);
}
@JsonValue
public
String
toValue
()
{
return
(
name
().
toLowerCase
());
}
@Override
public
String
toString
()
{
return
(
name
().
toLowerCase
());
}
}
/** Enum to use for ordering the results of getProjects(). */
public
enum
ProjectOrderBy
{
ID
,
NAME
,
PATH
,
CREATED_AT
,
UPDATED_AT
,
LAST_ACTIVITY
;
private
static
JacksonJsonEnumHelper
<
ProjectOrderBy
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
ProjectOrderBy
.
class
);
@JsonCreator
public
static
ProjectOrderBy
forValue
(
String
value
)
{
return
enumHelper
.
forValue
(
value
);
}
@JsonValue
public
String
toValue
()
{
return
(
name
().
toLowerCase
());
}
@Override
public
String
toString
()
{
return
(
name
().
toLowerCase
());
}
}
/** Enum to use for ordering the results of getPipelines(). */
public
enum
PipelineOrderBy
{
ID
,
STATUS
,
REF
,
USER_ID
;
private
static
JacksonJsonEnumHelper
<
PipelineOrderBy
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
PipelineOrderBy
.
class
);
@JsonCreator
public
static
PipelineOrderBy
forValue
(
String
value
)
{
return
enumHelper
.
forValue
(
value
);
}
@JsonValue
public
String
toValue
()
{
return
(
name
().
toLowerCase
());
}
@Override
public
String
toString
()
{
return
(
name
().
toLowerCase
());
}
}
/** Enum to use for specifying the scope when calling getPipelines(). */
public
enum
PipelineScope
{
RUNNING
,
PENDING
,
FINISHED
,
BRANCHES
,
TAGS
;
private
static
JacksonJsonEnumHelper
<
PipelineScope
>
enumHelper
=
new
JacksonJsonEnumHelper
<>(
PipelineScope
.
class
);
@JsonCreator
public
static
PipelineScope
forValue
(
String
value
)
{
return
enumHelper
.
forValue
(
value
);
}
@JsonValue
public
String
toValue
()
{
return
(
name
().
toLowerCase
());
}
@Override
public
String
toString
()
{
return
(
name
().
toLowerCase
());
}
}
}
src/main/java/org/gitlab4j/api/utils/JacksonJsonEnumHelper.java
0 → 100644
View file @
c9964e64
package
org.gitlab4j.api.utils
;
import
java.util.HashMap
;
import
java.util.Map
;
import
com.fasterxml.jackson.annotation.JsonCreator
;
public
class
JacksonJsonEnumHelper
<
E
extends
Enum
<
E
>>
{
private
Map
<
String
,
E
>
valuesMap
;
public
JacksonJsonEnumHelper
(
Class
<
E
>
enumType
)
{
valuesMap
=
new
HashMap
<>();
for
(
E
e
:
enumType
.
getEnumConstants
())
valuesMap
.
put
(
e
.
name
().
toLowerCase
(),
e
);
}
@JsonCreator
public
E
forValue
(
String
value
)
{
return
valuesMap
.
get
(
value
);
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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