Code formatting

pull/411/head
Nikita 9 years ago
parent 5cca26e526
commit eb0a8363a8

@ -15,7 +15,6 @@
*/
package org.redisson;
class BaseConfig<T extends BaseConfig<T>> {
/**
@ -113,6 +112,7 @@ class BaseConfig<T extends BaseConfig<T>> {
this.subscriptionsPerConnection = subscriptionsPerConnection;
return (T) this;
}
public int getSubscriptionsPerConnection() {
return subscriptionsPerConnection;
}
@ -127,6 +127,7 @@ class BaseConfig<T extends BaseConfig<T>> {
this.password = password;
return (T) this;
}
public String getPassword() {
return password;
}
@ -142,6 +143,7 @@ class BaseConfig<T extends BaseConfig<T>> {
this.retryAttempts = retryAttempts;
return (T) this;
}
public int getRetryAttempts() {
return retryAttempts;
}
@ -156,6 +158,7 @@ class BaseConfig<T extends BaseConfig<T>> {
this.retryInterval = retryInterval;
return (T) this;
}
public int getRetryInterval() {
return retryInterval;
}
@ -169,6 +172,7 @@ class BaseConfig<T extends BaseConfig<T>> {
this.timeout = timeout;
return (T) this;
}
public int getTimeout() {
return timeout;
}
@ -183,11 +187,11 @@ class BaseConfig<T extends BaseConfig<T>> {
this.clientName = clientName;
return (T) this;
}
public String getClientName() {
return clientName;
}
/**
* Ping timeout used in <code>Node.ping</code> and <code>Node.pingAll<code> operation
*
@ -197,13 +201,14 @@ class BaseConfig<T extends BaseConfig<T>> {
this.pingTimeout = pingTimeout;
return (T) this;
}
public int getPingTimeout() {
return pingTimeout;
}
/**
* Timeout during connecting to any Redis server.
*
* <p/>
* @param connectTimeout - timeout in milliseconds
* @return
*/
@ -211,6 +216,7 @@ class BaseConfig<T extends BaseConfig<T>> {
this.connectTimeout = connectTimeout;
return (T) this;
}
public int getConnectTimeout() {
return connectTimeout;
}
@ -227,6 +233,7 @@ class BaseConfig<T extends BaseConfig<T>> {
this.idleConnectionTimeout = idleConnectionTimeout;
return (T) this;
}
public int getIdleConnectionTimeout() {
return idleConnectionTimeout;
}
@ -234,10 +241,10 @@ class BaseConfig<T extends BaseConfig<T>> {
/**
* Reconnection attempt timeout to Redis server when
* it has been excluded from internal list of available servers.
*
* <p/>
* On every such timeout event Redisson tries
* to connect to disconnected Redis server.
*
* <p/>
* Default is 3000
*
* @see #failedAttempts
@ -246,8 +253,9 @@ class BaseConfig<T extends BaseConfig<T>> {
public T setReconnectionTimeout(int slaveRetryTimeout) {
this.reconnectionTimeout = slaveRetryTimeout;
return (T)this;
return (T) this;
}
public int getReconnectionTimeout() {
return reconnectionTimeout;
}
@ -256,14 +264,15 @@ class BaseConfig<T extends BaseConfig<T>> {
* Redis server will be excluded from the internal list of available nodes
* when sequential unsuccessful execution attempts of any Redis command
* on this server reaches <code>failedAttempts</code>.
*
* <p/>
* Default is 3
*
*/
public T setFailedAttempts(int slaveFailedAttempts) {
this.failedAttempts = slaveFailedAttempts;
return (T)this;
return (T) this;
}
public int getFailedAttempts() {
return failedAttempts;
}

@ -79,10 +79,10 @@ public class Config {
if (oldConf.getMasterSlaveServersConfig() != null) {
setMasterSlaveServersConfig(new MasterSlaveServersConfig(oldConf.getMasterSlaveServersConfig()));
}
if (oldConf.getSentinelServersConfig() != null ) {
if (oldConf.getSentinelServersConfig() != null) {
setSentinelServersConfig(new SentinelServersConfig(oldConf.getSentinelServersConfig()));
}
if (oldConf.getClusterServersConfig() != null ) {
if (oldConf.getClusterServersConfig() != null) {
setClusterServersConfig(new ClusterServersConfig(oldConf.getClusterServersConfig()));
}
if (oldConf.getElasticacheServersConfig() != null) {
@ -100,6 +100,7 @@ public class Config {
this.codec = codec;
return this;
}
public Codec getCodec() {
return codec;
}
@ -131,10 +132,10 @@ public class Config {
return clusterServersConfig;
}
ClusterServersConfig getClusterServersConfig() {
return clusterServersConfig;
}
void setClusterServersConfig(ClusterServersConfig clusterServersConfig) {
this.clusterServersConfig = clusterServersConfig;
}
@ -169,6 +170,7 @@ public class Config {
ElasticacheServersConfig getElasticacheServersConfig() {
return elasticacheServersConfig;
}
void setElasticacheServersConfig(ElasticacheServersConfig elasticacheServersConfig) {
this.elasticacheServersConfig = elasticacheServersConfig;
}
@ -200,10 +202,10 @@ public class Config {
return singleServerConfig;
}
SingleServerConfig getSingleServerConfig() {
return singleServerConfig;
}
void setSingleServerConfig(SingleServerConfig singleConnectionConfig) {
this.singleServerConfig = singleConnectionConfig;
}
@ -237,6 +239,7 @@ public class Config {
SentinelServersConfig getSentinelServersConfig() {
return sentinelServersConfig;
}
void setSentinelServersConfig(SentinelServersConfig sentinelConnectionConfig) {
this.sentinelServersConfig = sentinelConnectionConfig;
}
@ -270,6 +273,7 @@ public class Config {
MasterSlaveServersConfig getMasterSlaveServersConfig() {
return masterSlaveServersConfig;
}
void setMasterSlaveServersConfig(MasterSlaveServersConfig masterSlaveConnectionConfig) {
this.masterSlaveServersConfig = masterSlaveConnectionConfig;
}
@ -339,6 +343,7 @@ public class Config {
this.useLinuxNativeEpoll = useLinuxNativeEpoll;
return this;
}
public boolean isUseLinuxNativeEpoll() {
return useLinuxNativeEpoll;
}
@ -360,6 +365,7 @@ public class Config {
this.eventLoopGroup = eventLoopGroup;
return this;
}
public EventLoopGroup getEventLoopGroup() {
return eventLoopGroup;
}

@ -66,9 +66,11 @@ public class CommandEncoder extends MessageToByteEncoder<CommandData<Object, Obj
for (Object param : msg.getParams()) {
Encoder encoder = paramsEncoder;
if (msg.getCommand().getInParamType().size() == 1) {
if (msg.getCommand().getInParamIndex() == i && msg.getCommand().getInParamType().get(0) == ValueType.OBJECT) {
if (msg.getCommand().getInParamIndex() == i
&& msg.getCommand().getInParamType().get(0) == ValueType.OBJECT) {
encoder = msg.getCodec().getValueEncoder();
} else if (msg.getCommand().getInParamIndex() <= i && msg.getCommand().getInParamType().get(0) != ValueType.OBJECT) {
} else if (msg.getCommand().getInParamIndex() <= i
&& msg.getCommand().getInParamType().get(0) != ValueType.OBJECT) {
encoder = selectEncoder(msg, i - msg.getCommand().getInParamIndex());
}
} else {
@ -124,31 +126,27 @@ public class CommandEncoder extends MessageToByteEncoder<CommandData<Object, Obj
out.writeBytes(CRLF);
}
final static char[] DigitTens = {'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1',
'1', '1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '3', '3', '3',
'3', '3', '3', '3', '3', '3', '3', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '5', '5',
'5', '5', '5', '5', '5', '5', '5', '5', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '7',
'7', '7', '7', '7', '7', '7', '7', '7', '7', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8',
'9', '9', '9', '9', '9', '9', '9', '9', '9', '9',};
static final char[] DIGITTENS = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1',
'1', '1', '1', '1', '2', '2', '2', '2', '2', '2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '3', '3',
'3', '3', '3', '4', '4', '4', '4', '4', '4', '4', '4', '4', '4', '5', '5', '5', '5', '5', '5', '5', '5',
'5', '5', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '7', '7', '7', '7', '7', '7', '7', '7', '7',
'7', '8', '8', '8', '8', '8', '8', '8', '8', '8', '8', '9', '9', '9', '9', '9', '9', '9', '9', '9', '9', };
final static char[] DigitOnes = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2',
'3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1',
'2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',};
static final char[] DIGITONES = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5',
'6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', };
final static char[] digits = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e',
'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z'};
static final char[] DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
final static int[] sizeTable = {9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999,
Integer.MAX_VALUE};
static final int[] SIZETABLE = { 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, Integer.MAX_VALUE };
// Requires positive x
static int stringSize(long x) {
for (int i = 0;; i++)
if (x <= sizeTable[i])
if (x <= SIZETABLE[i])
return i + 1;
}
@ -168,8 +166,8 @@ public class CommandEncoder extends MessageToByteEncoder<CommandData<Object, Obj
// really: r = i - (q * 100);
r = i - ((q << 6) + (q << 5) + (q << 2));
i = q;
buf[--charPos] = (byte) DigitOnes[(int)r];
buf[--charPos] = (byte) DigitTens[(int)r];
buf[--charPos] = (byte) DIGITONES[(int) r];
buf[--charPos] = (byte) DIGITTENS[(int) r];
}
// Fall thru to fast mode for smaller numbers
@ -177,7 +175,7 @@ public class CommandEncoder extends MessageToByteEncoder<CommandData<Object, Obj
for (;;) {
q = (i * 52429) >>> (16 + 3);
r = i - ((q << 3) + (q << 1)); // r = i-(q*10) ...
buf[--charPos] = (byte) digits[(int)r];
buf[--charPos] = (byte) DIGITS[(int) r];
i = q;
if (i == 0)
break;
@ -194,5 +192,4 @@ public class CommandEncoder extends MessageToByteEncoder<CommandData<Object, Obj
return buf;
}
}

@ -24,8 +24,8 @@ import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
* @date 2015-10-16
*/
public class CborJacksonCodec extends JsonJacksonCodec {
@Override
protected ObjectMapper initObjectMapper() {
return new ObjectMapper(new CBORFactory());
}
@Override
protected ObjectMapper initObjectMapper() {
return new ObjectMapper(new CBORFactory());
}
}

@ -73,8 +73,7 @@ public class JsonJacksonCodec implements Codec {
init(mapObjectMapper);
// type info inclusion
TypeResolverBuilder<?> mapTyper = new DefaultTypeResolverBuilder(DefaultTyping.NON_FINAL) {
public boolean useForType(JavaType t)
{
public boolean useForType(JavaType t) {
switch (_appliesFor) {
case NON_CONCRETE_AND_ARRAYS:
while (t.isArrayType()) {
@ -93,7 +92,7 @@ public class JsonJacksonCodec implements Codec {
}
return !t.isFinal(); // includes Object.class
default:
//case JAVA_LANG_OBJECT:
// case JAVA_LANG_OBJECT:
return (t.getRawClass() == Object.class);
}
}
@ -106,10 +105,9 @@ public class JsonJacksonCodec implements Codec {
protected void init(ObjectMapper objectMapper) {
objectMapper.setSerializationInclusion(Include.NON_NULL);
objectMapper.setVisibilityChecker(objectMapper.getSerializationConfig().getDefaultVisibilityChecker()
.withFieldVisibility(JsonAutoDetect.Visibility.ANY)
.withGetterVisibility(JsonAutoDetect.Visibility.NONE)
.withSetterVisibility(JsonAutoDetect.Visibility.NONE)
.withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
.withFieldVisibility(JsonAutoDetect.Visibility.ANY).withGetterVisibility(JsonAutoDetect.Visibility.NONE)
.withSetterVisibility(JsonAutoDetect.Visibility.NONE)
.withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN, true);
objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);

Loading…
Cancel
Save