Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nikita
committed
Jul 17, 2015
1 parent
0e0e1c1
commit 68a1c01
Showing
8 changed files
with
234 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/org/redisson/client/protocol/convertor/NumberConvertor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.redisson.client.protocol.convertor; | ||
|
||
import java.math.BigDecimal; | ||
|
||
public class NumberConvertor extends SingleConvertor<Object> { | ||
|
||
private Class<?> resultClass; | ||
|
||
public NumberConvertor(Class<?> resultClass) { | ||
super(); | ||
this.resultClass = resultClass; | ||
} | ||
|
||
@Override | ||
public Object convert(Object result) { | ||
String res = (String) result; | ||
if (resultClass.isAssignableFrom(Long.class)) { | ||
Object obj = Long.parseLong(res); | ||
return obj; | ||
} | ||
if (resultClass.isAssignableFrom(Integer.class)) { | ||
Object obj = Integer.parseInt(res); | ||
return obj; | ||
} | ||
if (resultClass.isAssignableFrom(Float.class)) { | ||
Object obj = Float.parseFloat(res); | ||
return obj; | ||
} | ||
if (resultClass.isAssignableFrom(Double.class)) { | ||
Object obj = Double.parseDouble(res); | ||
return obj; | ||
} | ||
if (resultClass.isAssignableFrom(BigDecimal.class)) { | ||
Object obj = new BigDecimal(res); | ||
return obj; | ||
} | ||
throw new IllegalStateException("Wrong value type!"); | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/org/redisson/client/protocol/decoder/ObjectSetReplayDecoder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright 2014 Nikita Koksharov, Nickolay Borbit | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.redisson.client.protocol.decoder; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
|
||
public class ObjectSetReplayDecoder implements MultiDecoder<Set<Object>> { | ||
|
||
@Override | ||
public Object decode(ByteBuf buf) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public Set<Object> decode(List<Object> parts) { | ||
return new HashSet<Object>(parts); | ||
} | ||
|
||
@Override | ||
public boolean isApplicable(int paramNum) { | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.