Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructors should only call non-overridable methods #1223

Open
wants to merge 1 commit into
base: titan10
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ private CLevel() {
astyanax = com.netflix.astyanax.model.ConsistencyLevel.valueOf("CL_" + toString());
}



@Override
public org.apache.cassandra.db.ConsistencyLevel getDB() {
return db;
Expand Down Expand Up @@ -56,4 +58,9 @@ public static CLevel parse(String value) {
}
throw new IllegalArgumentException("Unrecognized cassandra consistency level: " + value);
}

@Override
public final String toString() {
return super.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static CassandraTransaction getTx(StoreTransaction txh) {
return (CassandraTransaction) txh;
}

public String toString() {
public final String toString() {
StringBuilder sb = new StringBuilder(64);
sb.append("CassandraTransaction@");
sb.append(Integer.toHexString(hashCode()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public Deployment getDeployment() {

@Override
@SuppressWarnings("unchecked")
public IPartitioner getCassandraPartitioner() throws BackendException {
public final IPartitioner getCassandraPartitioner() throws BackendException {
CTConnection conn = null;
try {
conn = pool.borrowObject(SYSTEM_KS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,12 @@ private String getMetricsCacheName(String storeName) {
return configuration.get(METRICS_MERGE_STORES) ? METRICS_MERGED_CACHE : storeName + METRICS_CACHE_SUFFIX;
}

public KCVSLogManager getKCVSLogManager(String logName) {
public final KCVSLogManager getKCVSLogManager(String logName) {
Preconditions.checkArgument(configuration.restrictTo(logName).get(LOG_BACKEND).equalsIgnoreCase(LOG_BACKEND.getDefaultValue()));
return (KCVSLogManager)getLogManager(logName);
}

public LogManager getLogManager(String logName) {
public final LogManager getLogManager(String logName) {
return getLogManager(configuration, logName, storeManager);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void rollback() throws BackendException {
}

@Override
public BaseTransactionConfig getConfiguration() {
public final BaseTransactionConfig getConfiguration() {
return config;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public IndexEntry(final String field, final Object value, Map<EntryMetaData, Obj
private Map<EntryMetaData,Object> metadata = EntryMetaData.EMPTY_METADATA;

@Override
public synchronized Object setMetaData(EntryMetaData key, Object value) {
public final synchronized Object setMetaData(EntryMetaData key, Object value) {
if (metadata == EntryMetaData.EMPTY_METADATA)
metadata = new EntryMetaData.Map();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public StaticBuffer getKeyEnd() {
}

@Override
public KeyRangeQuery setLimit(int limit) {
public final KeyRangeQuery setLimit(int limit) {
super.setLimit(limit);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public StaticBuffer getKey() {
}

@Override
public KeySliceQuery setLimit(int limit) {
public final KeySliceQuery setLimit(int limit) {
super.setLimit(limit);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,106 +191,106 @@ public Builder(StoreFeatures template) {
supportsInterruption(template.supportsInterruption());
}

public Builder unorderedScan(boolean b) {
public final Builder unorderedScan(boolean b) {
unorderedScan = b;
return this;
}

public Builder orderedScan(boolean b) {
public final Builder orderedScan(boolean b) {
orderedScan = b;
return this;
}

public Builder multiQuery(boolean b) {
public final Builder multiQuery(boolean b) {
multiQuery = b;
return this;
}

public Builder locking(boolean b) {
public final Builder locking(boolean b) {
locking = b;
return this;
}

public Builder batchMutation(boolean b) {
public final Builder batchMutation(boolean b) {
batchMutation = b;
return this;
}

public Builder localKeyPartition(boolean b) {
public final Builder localKeyPartition(boolean b) {
localKeyPartition = b;
return this;
}

public Builder keyOrdered(boolean b) {
public final Builder keyOrdered(boolean b) {
keyOrdered = b;
return this;
}

public Builder distributed(boolean b) {
public final Builder distributed(boolean b) {
distributed = b;
return this;
}

public Builder transactional(boolean b) {
public final Builder transactional(boolean b) {
transactional = b;
return this;
}

public Builder timestamps(boolean b) {
public final Builder timestamps(boolean b) {
timestamps = b;
return this;
}

public Builder preferredTimestamps(TimestampProviders t) {
public final Builder preferredTimestamps(TimestampProviders t) {
preferredTimestamps = t;
return this;
}

public Builder cellTTL(boolean b) {
public final Builder cellTTL(boolean b) {
cellLevelTTL = b;
return this;
}

public Builder storeTTL(boolean b) {
public final Builder storeTTL(boolean b) {
storeLevelTTL = b;
return this;
}


public Builder visibility(boolean b) {
public final Builder visibility(boolean b) {
visibility = b;
return this;
}

public Builder persists(boolean b) {
public final Builder persists(boolean b) {
supportsPersist = b;
return this;
}

public Builder keyConsistent(Configuration c) {
public final Builder keyConsistent(Configuration c) {
keyConsistent = true;
keyConsistentTxConfig = c;
return this;
}

public Builder keyConsistent(Configuration global, Configuration local) {
public final Builder keyConsistent(Configuration global, Configuration local) {
keyConsistent = true;
keyConsistentTxConfig = global;
localKeyConsistentTxConfig = local;
return this;
}

public Builder notKeyConsistent() {
public final Builder notKeyConsistent() {
keyConsistent = false;
return this;
}

public Builder scanTxConfig(Configuration c) {
public final Builder scanTxConfig(Configuration c) {
scanTxConfig = c;
return this;
}

public Builder supportsInterruption(boolean i)
public final Builder supportsInterruption(boolean i)
{
supportsInterruption = i;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Builder(BaseTransactionConfig template) {
timestampProvider(template.getTimestampProvider());
}

public Builder groupName(String group) {
public final Builder groupName(String group) {
groupName = group;
return this;
}
Expand All @@ -111,12 +111,12 @@ public Builder commitTime(Instant commit) {
return this;
}

public Builder timestampProvider(TimestampProvider times) {
public final Builder timestampProvider(TimestampProvider times) {
this.times = times;
return this;
}

public Builder customOptions(Configuration c) {
public final Builder customOptions(Configuration c) {
customOptions = c;
Preconditions.checkNotNull(customOptions, "Null custom options disallowed; use an empty Configuration object instead");
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private int require(int position, int size) {
}

@Override
public int length() {
public final int length() {
return limit - offset;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public PropertyPlacementStrategy(String key, int concurrentPartitions) {
setPartitionKey(key);
}

public void setPartitionKey(String key) {
public final void setPartitionKey(String key) {
Preconditions.checkArgument(StringUtils.isNotBlank(key),"Invalid key configured: %s",key);
this.key=key;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public SimplePartitionAssignment(int id) {
setPartitionID(id);
}

public void setPartitionID(int id) {
public final void setPartitionID(int id) {
Preconditions.checkArgument(id >= 0);
this.partitionID = id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public synchronized <V> void registerClass(int registrationNo, Class<V> datatype
registerClassInternal(CLASS_REGISTRATION_OFFSET + registrationNo, datatype, serializer);
}

public synchronized <V> void registerClassInternal(int registrationNo, Class<? extends V> datatype, AttributeSerializer<V> serializer) {
public final synchronized <V> void registerClassInternal(int registrationNo, Class<? extends V> datatype, AttributeSerializer<V> serializer) {
Preconditions.checkArgument(registrationNo>0); //must be bigger than 0 since 0 is used to indicate null values
Preconditions.checkNotNull(datatype);
Preconditions.checkArgument(!handlers.containsKey(datatype), "DataType has already been registered: %s", datatype);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public R next() {
return current;
}

public R nextInternal() {
public final R nextInternal() {
if (nextFirst == null && first.hasNext()) {
nextFirst = first.next();
assert nextFirst != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.thinkaurelius.titan.graphdb.relations.RelationIdentifier;
import com.thinkaurelius.titan.graphdb.tinkerpop.io.graphson.TitanGraphSONModule;
import org.apache.tinkerpop.gremlin.structure.io.AbstractIoRegistry;
import org.apache.tinkerpop.gremlin.structure.io.Io;
import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoIo;

Expand All @@ -22,4 +23,9 @@ public TitanIoRegistry() {
register(GryoIo.class, RelationIdentifier.class, null);
register(GryoIo.class, Geoshape.class, new Geoshape.GeoShapeGryoSerializer());
}

@Override
protected final void register(Class<? extends Io> ioClass, Class clazz, Object serializer) {
super.register(ioClass, clazz, serializer);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
Expand All @@ -30,6 +32,16 @@ private TitanGraphSONModule() {
addDeserializer(Geoshape.class, new Geoshape.GeoshapeGsonDeserializer());
}

@Override
public final <T> SimpleModule addSerializer(Class<? extends T> aClass, JsonSerializer<T> jsonSerializer) {
return super.addSerializer(aClass, jsonSerializer);
}

@Override
public final <T> SimpleModule addDeserializer(Class<T> aClass, JsonDeserializer<? extends T> jsonDeserializer) {
return super.addDeserializer(aClass, jsonDeserializer);
}

private static final TitanGraphSONModule INSTANCE = new TitanGraphSONModule();

public static final TitanGraphSONModule getInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ public StandardTransactionBuilder threadBound() {
}

@Override
public StandardTransactionBuilder readOnly() {
public final StandardTransactionBuilder readOnly() {
this.isReadOnly = true;
return this;
}

@Override
public StandardTransactionBuilder enableBatchLoading() {
public final StandardTransactionBuilder enableBatchLoading() {
hasEnabledBatchLoading = true;
checkExternalVertexExistence(false);
consistencyChecks(false);
Expand All @@ -139,15 +139,15 @@ public StandardTransactionBuilder disableBatchLoading() {
}

@Override
public StandardTransactionBuilder vertexCacheSize(int size) {
public final StandardTransactionBuilder vertexCacheSize(int size) {
Preconditions.checkArgument(size >= 0);
this.vertexCacheSize = size;
this.indexCacheWeight = size / 2;
return this;
}

@Override
public TransactionBuilder dirtyVertexSize(int size) {
public final TransactionBuilder dirtyVertexSize(int size) {
this.dirtyVertexSize = size;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public StandardPropertyKeyMaker dataType(Class<?> clazz) {
}

@Override
public StandardPropertyKeyMaker cardinality(Cardinality cardinality) {
public final StandardPropertyKeyMaker cardinality(Cardinality cardinality) {
super.multiplicity(Multiplicity.convert(cardinality));
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public StandardRelationTypeMaker sortOrder(Order order) {
return this;
}

public StandardRelationTypeMaker name(String name) {
public final StandardRelationTypeMaker name(String name) {
SystemTypeManager.isNotSystemName(getSchemaCategory(), name);
this.name = name;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public TypeDefinitionMap(TypeDefinitionMap copy) {
}
}

public TypeDefinitionMap setValue(TypeDefinitionCategory type, Object value) {
public final TypeDefinitionMap setValue(TypeDefinitionCategory type, Object value) {
assert type != null;
assert value != null;
assert type.verifyAttribute(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ private static class KeyContainer {

KeyContainer() {}

void setKeys(final String[] keys) {
final void setKeys(final String[] keys) {
checkKeys(keys);
this.keys = keys;
this.hashcode= Arrays.hashCode(keys);
Expand Down
Loading