Skip to content

Commit

Permalink
simplify enum comparisons - and avoid possible npes
Browse files Browse the repository at this point in the history
  • Loading branch information
mebigfatguy committed Oct 17, 2011
1 parent 562b61f commit e45b71c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Expand Up @@ -24,12 +24,12 @@ public class ConfigurableConsistencyLevel implements ConsistencyLevelPolicy {

@Override
public HConsistencyLevel get(OperationType op) {
return op.equals(OperationType.READ) ? defaultReadConsistencyLevel : defaultWriteConsistencyLevel;
return (op == OperationType.READ) ? defaultReadConsistencyLevel : defaultWriteConsistencyLevel;
}

@Override
public HConsistencyLevel get(OperationType op, String cfName) {
if (op.equals(OperationType.READ)) {
if (op == OperationType.READ) {
HConsistencyLevel rcf = readCfConsistencyLevels.get(cfName);
return rcf != null ? rcf : defaultReadConsistencyLevel;
} else {
Expand All @@ -49,7 +49,7 @@ public void setWriteCfConsistencyLevels(Map<String, HConsistencyLevel> columnFam
public void setConsistencyLevelForCfOperation(HConsistencyLevel consistencyLevel,
String columnFamily,
OperationType operationType) {
if ( operationType.equals(OperationType.READ)) {
if (operationType == OperationType.READ) {
readCfConsistencyLevels.put(columnFamily, consistencyLevel);
} else {
writeCfConsistencyLevels.put(columnFamily, consistencyLevel);
Expand Down
Expand Up @@ -57,7 +57,7 @@ public CqlRows() {
* @return
*/
public int getAsCount() {
if ( !resultType.equals(CqlResultType.INT))
if (resultType != CqlResultType.INT)
throw new IllegalArgumentException("Attempted to extract count from the wrong type of CQL query: " + resultType.toString());
return count;
}
Expand Down
Expand Up @@ -42,7 +42,7 @@ public abstract class Operation<T> {
public final OperationType operationType;

public Operation(OperationType operationType) {
this.failCounter = operationType.equals(OperationType.READ) ? Counter.READ_FAIL :
this.failCounter = (operationType == OperationType.READ) ? Counter.READ_FAIL :
Counter.WRITE_FAIL;
this.operationType = operationType;
this.stopWatchTagName = operationType.name();
Expand All @@ -53,7 +53,7 @@ public Operation(OperationType operationType, Map<String, String> credentials) {
}

public Operation(OperationType operationType, FailoverPolicy failoverPolicy, String keyspaceName, Map<String, String> credentials) {
this.failCounter = operationType.equals(OperationType.READ) ? Counter.READ_FAIL :
this.failCounter = (operationType == OperationType.READ) ? Counter.READ_FAIL :
Counter.WRITE_FAIL;
this.operationType = operationType;
this.stopWatchTagName = operationType.name();
Expand Down

0 comments on commit e45b71c

Please sign in to comment.