Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
K
key_value-server
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
amir.yosef
key_value-server
Commits
d7c1beda
You need to sign in or sign up before continuing.
Commit
d7c1beda
authored
Aug 13, 2024
by
amir.yosef
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update CommandUtil
parent
d8ae6da7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
39 deletions
+16
-39
CommandUtil.java
src/util/CommandUtil.java
+16
-39
No files found.
src/util/CommandUtil.java
View file @
d7c1beda
...
...
@@ -2,46 +2,23 @@ package util;
import
model.Command
;
import
java.util.Map
;
public
class
CommandUtil
{
private
static
final
Map
<
String
,
Command
>
COMMAND_MAP
=
Map
.
of
(
"echo"
,
Command
.
ECHO
,
"ping"
,
Command
.
PING
,
"set"
,
Command
.
SET
,
"get"
,
Command
.
GET
,
"info"
,
Command
.
INFO
);
public
static
Command
getCommand
(
String
command
)
{
if
(
command
.
toLowerCase
().
contains
(
Command
.
ECHO
.
getValue
().
toLowerCase
()))
{
return
Command
.
ECHO
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
PING
.
getValue
().
toLowerCase
()))
{
return
Command
.
PING
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
SET
.
getValue
().
toLowerCase
()))
{
return
Command
.
SET
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
GET
.
getValue
().
toLowerCase
()))
{
return
Command
.
GET
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
INFO
.
getValue
().
toLowerCase
()))
{
return
Command
.
INFO
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
REPLCONF
.
getValue
().
toLowerCase
())
||
command
.
equalsIgnoreCase
(
Command
.
REPLCONF
.
getValue
()))
{
return
Command
.
REPLCONF
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
FULLRESYNC
.
getValue
().
toLowerCase
())
||
command
.
equalsIgnoreCase
(
Command
.
FULLRESYNC
.
getValue
()))
{
return
Command
.
FULLRESYNC
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
PSYNC
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
PSYNC
.
getValue
()))
{
return
Command
.
PSYNC
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
WAIT
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
WAIT
.
getValue
()))
{
return
Command
.
WAIT
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
CONFIG
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
CONFIG
.
getValue
()))
{
return
Command
.
CONFIG
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
KEYS
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
KEYS
.
getValue
()))
{
return
Command
.
KEYS
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
TYPE
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
TYPE
.
getValue
()))
{
return
Command
.
TYPE
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
XADD
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
XADD
.
getValue
()))
{
return
Command
.
XADD
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
XRANGE
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
XRANGE
.
getValue
()))
{
return
Command
.
XRANGE
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
XREAD
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
XREAD
.
getValue
()))
{
return
Command
.
XREAD
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
INCR
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
INCR
.
getValue
()))
{
return
Command
.
INCR
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
MULTI
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
MULTI
.
getValue
()))
{
return
Command
.
MULTI
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
EXEC
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
EXEC
.
getValue
()))
{
return
Command
.
EXEC
;
}
else
if
(
command
.
toLowerCase
().
contains
(
Command
.
DISCARD
.
getValue
())
||
command
.
equalsIgnoreCase
(
Command
.
DISCARD
.
getValue
()))
{
return
Command
.
DISCARD
;
}
else
return
Command
.
UNKNOWN
;
return
COMMAND_MAP
.
entrySet
().
stream
()
.
filter
(
entry
->
command
.
toLowerCase
().
contains
(
entry
.
getKey
().
toLowerCase
()))
.
map
(
Map
.
Entry
::
getValue
)
.
findFirst
()
.
orElse
(
Command
.
UNKNOWN
);
}
}
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