mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-09 14:34:43 +00:00
Add missing @Override annotations.
These help a lot when refactoring, upgrading lucene, etc, and can prevent code duplication (as you get a compile error for outdated stuff). Closes #9832.
This commit is contained in:
parent
668d09db08
commit
0fa5b87fdd
@ -239,6 +239,7 @@ public abstract class BlendedTermQuery extends Query {
|
||||
|
||||
public static BlendedTermQuery booleanBlendedQuery(Term[] terms, final float[] boosts, final boolean disableCoord) {
|
||||
return new BlendedTermQuery(terms) {
|
||||
@Override
|
||||
protected Query topLevelQuery(Term[] terms, TermContext[] ctx, int[] docFreqs, int maxDoc) {
|
||||
BooleanQuery query = new BooleanQuery(disableCoord);
|
||||
for (int i = 0; i < terms.length; i++) {
|
||||
@ -255,6 +256,7 @@ public abstract class BlendedTermQuery extends Query {
|
||||
|
||||
public static BlendedTermQuery commonTermsBlendedQuery(Term[] terms, final float[] boosts, final boolean disableCoord, final float maxTermFrequency) {
|
||||
return new BlendedTermQuery(terms) {
|
||||
@Override
|
||||
protected Query topLevelQuery(Term[] terms, TermContext[] ctx, int[] docFreqs, int maxDoc) {
|
||||
BooleanQuery query = new BooleanQuery(true);
|
||||
BooleanQuery high = new BooleanQuery(disableCoord);
|
||||
@ -294,6 +296,7 @@ public abstract class BlendedTermQuery extends Query {
|
||||
|
||||
public static BlendedTermQuery dismaxBlendedQuery(Term[] terms, final float[] boosts, final float tieBreakerMultiplier) {
|
||||
return new BlendedTermQuery(terms) {
|
||||
@Override
|
||||
protected Query topLevelQuery(Term[] terms, TermContext[] ctx, int[] docFreqs, int maxDoc) {
|
||||
DisjunctionMaxQuery query = new DisjunctionMaxQuery(tieBreakerMultiplier);
|
||||
for (int i = 0; i < terms.length; i++) {
|
||||
|
@ -851,6 +851,7 @@ public class MapperQueryParser extends QueryParser {
|
||||
return fields;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query parse(String query) throws ParseException {
|
||||
if (query.trim().isEmpty()) {
|
||||
// if the query string is empty we return no docs / empty result
|
||||
|
@ -254,7 +254,8 @@ public class XAnalyzingSuggester extends Lookup {
|
||||
}
|
||||
|
||||
/** Returns byte size of the underlying FST. */
|
||||
public long ramBytesUsed() {
|
||||
@Override
|
||||
public long ramBytesUsed() {
|
||||
return fst == null ? 0 : fst.ramBytesUsed();
|
||||
}
|
||||
|
||||
|
@ -190,6 +190,7 @@ public class ElasticsearchException extends RuntimeException {
|
||||
this.headers = headers != null ? headers : ImmutableMap.<String, List<String>>of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableMap<String, List<String>> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ public abstract class ActionRunnable<Response> extends AbstractRunnable {
|
||||
* Calls the action listeners {@link ActionListener#onFailure(Throwable)} method with the given exception.
|
||||
* This method is invoked for all exception thrown by {@link #doRun()}
|
||||
*/
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
listener.onFailure(t);
|
||||
}
|
||||
|
@ -198,6 +198,7 @@ public abstract class ActionWriteResponse extends ActionResponse {
|
||||
/**
|
||||
* @return On what index the failure occurred.
|
||||
*/
|
||||
@Override
|
||||
public String index() {
|
||||
return index;
|
||||
}
|
||||
@ -205,6 +206,7 @@ public abstract class ActionWriteResponse extends ActionResponse {
|
||||
/**
|
||||
* @return On what shard id the failure occurred.
|
||||
*/
|
||||
@Override
|
||||
public int shardId() {
|
||||
return shardId;
|
||||
}
|
||||
@ -220,6 +222,7 @@ public abstract class ActionWriteResponse extends ActionResponse {
|
||||
/**
|
||||
* @return A text description of the failure
|
||||
*/
|
||||
@Override
|
||||
public String reason() {
|
||||
return reason;
|
||||
}
|
||||
@ -227,6 +230,7 @@ public abstract class ActionWriteResponse extends ActionResponse {
|
||||
/**
|
||||
* @return The status to report if this failure was a primary failure.
|
||||
*/
|
||||
@Override
|
||||
public RestStatus status() {
|
||||
return status;
|
||||
}
|
||||
|
@ -110,6 +110,7 @@ public class ClearIndicesCacheRequest extends BroadcastOperationRequest<ClearInd
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
filterCache = in.readBoolean();
|
||||
@ -121,6 +122,7 @@ public class ClearIndicesCacheRequest extends BroadcastOperationRequest<ClearInd
|
||||
queryCache = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeBoolean(filterCache);
|
||||
|
@ -76,6 +76,7 @@ public class TypesExistsRequest extends MasterNodeReadOperationRequest<TypesExis
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
ActionRequestValidationException validationException = null;
|
||||
if (indices == null) { // Specifying '*' via rest api results in an empty array
|
||||
|
@ -64,6 +64,7 @@ public class TypesExistsRequestBuilder extends MasterNodeReadOperationRequestBui
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<TypesExistsResponse> listener) {
|
||||
client.typesExists(request, listener);
|
||||
}
|
||||
|
@ -42,11 +42,13 @@ public class TypesExistsResponse extends ActionResponse {
|
||||
return this.exists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
exists = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeBoolean(exists);
|
||||
|
@ -161,6 +161,7 @@ public class TransportGetFieldMappingsIndexAction extends TransportSingleCustomO
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean paramAsBoolean(String key, Boolean defaultValue) {
|
||||
if (INCLUDE_DEFAULTS.equals(key)) {
|
||||
return true;
|
||||
|
@ -129,6 +129,7 @@ public class OptimizeRequest extends BroadcastOperationRequest<OptimizeRequest>
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
maxNumSegments = in.readInt();
|
||||
@ -137,6 +138,7 @@ public class OptimizeRequest extends BroadcastOperationRequest<OptimizeRequest>
|
||||
upgrade = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeInt(maxNumSegments);
|
||||
|
@ -348,10 +348,12 @@ public class BenchmarkExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Response response) {
|
||||
manage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable e) {
|
||||
try {
|
||||
if (errorMessages.size() < 5) {
|
||||
|
@ -405,6 +405,7 @@ public class BenchmarkService extends AbstractLifecycleComponent<BenchmarkServic
|
||||
countDown = new CountDown(size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract T newInstance();
|
||||
|
||||
protected abstract void sendResponse();
|
||||
@ -426,6 +427,7 @@ public class BenchmarkService extends AbstractLifecycleComponent<BenchmarkServic
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String executor() {
|
||||
return ThreadPool.Names.SAME;
|
||||
}
|
||||
@ -669,6 +671,7 @@ public class BenchmarkService extends AbstractLifecycleComponent<BenchmarkServic
|
||||
this.patterns = patterns;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean match(BenchmarkMetaData.Entry entry) {
|
||||
return entry.state() == BenchmarkMetaData.State.STARTED && Regex.simpleMatch(this.patterns, benchmarkId);
|
||||
}
|
||||
|
@ -573,6 +573,7 @@ public class TransportShardBulkAction extends TransportShardReplicationOperation
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void shardOperationOnReplica(ReplicaOperationRequest shardRequest) {
|
||||
IndexShard indexShard = indicesService.indexServiceSafe(shardRequest.shardId.getIndex()).shardSafe(shardRequest.shardId.id());
|
||||
final BulkShardRequest request = shardRequest.request;
|
||||
|
@ -125,6 +125,7 @@ public class DeleteRequest extends ShardReplicationOperationRequest<DeleteReques
|
||||
/**
|
||||
* The type of the document to delete.
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return type;
|
||||
}
|
||||
@ -140,6 +141,7 @@ public class DeleteRequest extends ShardReplicationOperationRequest<DeleteReques
|
||||
/**
|
||||
* The id of the document to delete.
|
||||
*/
|
||||
@Override
|
||||
public String id() {
|
||||
return id;
|
||||
}
|
||||
@ -167,6 +169,7 @@ public class DeleteRequest extends ShardReplicationOperationRequest<DeleteReques
|
||||
* Controls the shard routing of the request. Using this value to hash the shard
|
||||
* and not the id.
|
||||
*/
|
||||
@Override
|
||||
public DeleteRequest routing(String routing) {
|
||||
if (routing != null && routing.length() == 0) {
|
||||
this.routing = null;
|
||||
@ -180,6 +183,7 @@ public class DeleteRequest extends ShardReplicationOperationRequest<DeleteReques
|
||||
* Controls the shard routing of the delete request. Using this value to hash the shard
|
||||
* and not the id.
|
||||
*/
|
||||
@Override
|
||||
public String routing() {
|
||||
return this.routing;
|
||||
}
|
||||
|
@ -104,6 +104,7 @@ public class DeleteRequestBuilder extends ShardReplicationOperationRequestBuilde
|
||||
/**
|
||||
* Set the replication type for this operation.
|
||||
*/
|
||||
@Override
|
||||
public DeleteRequestBuilder setReplicationType(ReplicationType replicationType) {
|
||||
request.replicationType(replicationType);
|
||||
return this;
|
||||
@ -112,6 +113,7 @@ public class DeleteRequestBuilder extends ShardReplicationOperationRequestBuilde
|
||||
/**
|
||||
* Sets the consistency level. Defaults to {@link org.elasticsearch.action.WriteConsistencyLevel#DEFAULT}.
|
||||
*/
|
||||
@Override
|
||||
public DeleteRequestBuilder setConsistencyLevel(WriteConsistencyLevel consistencyLevel) {
|
||||
request.consistencyLevel(consistencyLevel);
|
||||
return this;
|
||||
|
@ -199,6 +199,7 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest<Del
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
sourceUnsafe = false;
|
||||
@ -207,6 +208,7 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest<Del
|
||||
types = in.readStringArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeBytesReference(source);
|
||||
|
@ -137,6 +137,7 @@ public class DeleteByQueryRequestBuilder extends IndicesReplicationOperationRequ
|
||||
/**
|
||||
* The replication type to use with this operation.
|
||||
*/
|
||||
@Override
|
||||
public DeleteByQueryRequestBuilder setReplicationType(ReplicationType replicationType) {
|
||||
request.replicationType(replicationType);
|
||||
return this;
|
||||
@ -145,11 +146,13 @@ public class DeleteByQueryRequestBuilder extends IndicesReplicationOperationRequ
|
||||
/**
|
||||
* The replication type to use with this operation.
|
||||
*/
|
||||
@Override
|
||||
public DeleteByQueryRequestBuilder setReplicationType(String replicationType) {
|
||||
request.replicationType(replicationType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeleteByQueryRequestBuilder setConsistencyLevel(WriteConsistencyLevel consistencyLevel) {
|
||||
request.consistencyLevel(consistencyLevel);
|
||||
return this;
|
||||
|
@ -34,10 +34,12 @@ public class ExplainAction extends ClientAction<ExplainRequest, ExplainResponse,
|
||||
super(NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExplainRequestBuilder newRequestBuilder(Client client) {
|
||||
return new ExplainRequestBuilder(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExplainResponse newResponse() {
|
||||
return new ExplainResponse();
|
||||
}
|
||||
|
@ -163,6 +163,7 @@ public class ExplainRequestBuilder extends SingleShardOperationRequestBuilder<Ex
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doExecute(ActionListener<ExplainResponse> listener) {
|
||||
if (sourceBuilder != null) {
|
||||
request.source(sourceBuilder);
|
||||
|
@ -95,6 +95,7 @@ public class ExplainResponse extends ActionResponse {
|
||||
return getResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
index = in.readString();
|
||||
@ -109,6 +110,7 @@ public class ExplainResponse extends ActionResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(index);
|
||||
|
@ -84,6 +84,7 @@ public class TransportExplainAction extends TransportShardSingleOperationAction<
|
||||
super.doExecute(request, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String executor() {
|
||||
return ThreadPool.Names.GET; // Or use Names.SEARCH?
|
||||
}
|
||||
@ -146,10 +147,12 @@ public class TransportExplainAction extends TransportShardSingleOperationAction<
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExplainRequest newRequest() {
|
||||
return new ExplainRequest();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ExplainResponse newResponse() {
|
||||
return new ExplainResponse();
|
||||
}
|
||||
|
@ -247,6 +247,7 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
|
||||
/**
|
||||
* The type of the indexed document.
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return type;
|
||||
}
|
||||
@ -262,6 +263,7 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
|
||||
/**
|
||||
* The id of the indexed document. If not set, will be automatically generated.
|
||||
*/
|
||||
@Override
|
||||
public String id() {
|
||||
return id;
|
||||
}
|
||||
@ -278,6 +280,7 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
|
||||
* Controls the shard routing of the request. Using this value to hash the shard
|
||||
* and not the id.
|
||||
*/
|
||||
@Override
|
||||
public IndexRequest routing(String routing) {
|
||||
if (routing != null && routing.length() == 0) {
|
||||
this.routing = null;
|
||||
@ -291,6 +294,7 @@ public class IndexRequest extends ShardReplicationOperationRequest<IndexRequest>
|
||||
* Controls the shard routing of the request. Using this value to hash the shard
|
||||
* and not the id.
|
||||
*/
|
||||
@Override
|
||||
public String routing() {
|
||||
return this.routing;
|
||||
}
|
||||
|
@ -256,6 +256,7 @@ public class IndexRequestBuilder extends ShardReplicationOperationRequestBuilder
|
||||
/**
|
||||
* Set the replication type for this operation.
|
||||
*/
|
||||
@Override
|
||||
public IndexRequestBuilder setReplicationType(ReplicationType replicationType) {
|
||||
request.replicationType(replicationType);
|
||||
return this;
|
||||
@ -264,6 +265,7 @@ public class IndexRequestBuilder extends ShardReplicationOperationRequestBuilder
|
||||
/**
|
||||
* Sets the consistency level. Defaults to {@link org.elasticsearch.action.WriteConsistencyLevel#DEFAULT}.
|
||||
*/
|
||||
@Override
|
||||
public IndexRequestBuilder setConsistencyLevel(WriteConsistencyLevel consistencyLevel) {
|
||||
request.consistencyLevel(consistencyLevel);
|
||||
return this;
|
||||
@ -272,6 +274,7 @@ public class IndexRequestBuilder extends ShardReplicationOperationRequestBuilder
|
||||
/**
|
||||
* Set the replication type for this operation.
|
||||
*/
|
||||
@Override
|
||||
public IndexRequestBuilder setReplicationType(String replicationType) {
|
||||
request.replicationType(replicationType);
|
||||
return this;
|
||||
|
@ -67,6 +67,7 @@ public class SearchResponse extends ActionResponse implements StatusToXContent {
|
||||
this.shardFailures = shardFailures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestStatus status() {
|
||||
if (shardFailures.length == 0) {
|
||||
if (successfulShards == 0 && totalShards > 0) {
|
||||
|
@ -85,6 +85,7 @@ public class ShardSearchFailure implements ShardOperationFailedException {
|
||||
return this.shardTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestStatus status() {
|
||||
return this.status;
|
||||
}
|
||||
@ -114,6 +115,7 @@ public class ShardSearchFailure implements ShardOperationFailedException {
|
||||
/**
|
||||
* The reason of the failure.
|
||||
*/
|
||||
@Override
|
||||
public String reason() {
|
||||
return this.reason;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ public abstract class AbstractListenableActionFuture<T, L> extends AdapterAction
|
||||
return threadPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(final ActionListener<T> listener) {
|
||||
internalAddListener(listener);
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ public abstract class HandledTransportAction<Request extends ActionRequest, Resp
|
||||
* Call to get an instance of type Request
|
||||
* @return Request
|
||||
*/
|
||||
@Override
|
||||
public abstract Request newInstance();
|
||||
|
||||
@Override
|
||||
|
@ -45,6 +45,7 @@ public class QuerySourceBuilder implements ToXContent {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||
builder.startObject();
|
||||
if (queryBuilder != null) {
|
||||
|
@ -41,6 +41,7 @@ public abstract class TransportMasterNodeReadOperationAction<Request extends Mas
|
||||
this.forceLocal = settings.getAsBoolean(FORCE_LOCAL_SETTING, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean localExecute(Request request) {
|
||||
if (forceLocal != null) {
|
||||
return forceLocal;
|
||||
|
@ -143,6 +143,7 @@ public class TermVectorsRequest extends SingleShardOperationRequest<TermVectorsR
|
||||
/**
|
||||
* Returns the type of document to get the term vector for.
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return type;
|
||||
}
|
||||
@ -150,6 +151,7 @@ public class TermVectorsRequest extends SingleShardOperationRequest<TermVectorsR
|
||||
/**
|
||||
* Returns the id of document the term vector is requested for.
|
||||
*/
|
||||
@Override
|
||||
public String id() {
|
||||
return id;
|
||||
}
|
||||
@ -191,10 +193,12 @@ public class TermVectorsRequest extends SingleShardOperationRequest<TermVectorsR
|
||||
/**
|
||||
* @return The routing for this request.
|
||||
*/
|
||||
@Override
|
||||
public String routing() {
|
||||
return routing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TermVectorsRequest routing(String routing) {
|
||||
this.routing = routing;
|
||||
return this;
|
||||
|
@ -133,6 +133,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
/**
|
||||
* The type of the indexed document.
|
||||
*/
|
||||
@Override
|
||||
public String type() {
|
||||
return type;
|
||||
}
|
||||
@ -148,6 +149,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
/**
|
||||
* The id of the indexed document.
|
||||
*/
|
||||
@Override
|
||||
public String id() {
|
||||
return id;
|
||||
}
|
||||
@ -164,6 +166,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
* Controls the shard routing of the request. Using this value to hash the shard
|
||||
* and not the id.
|
||||
*/
|
||||
@Override
|
||||
public UpdateRequest routing(String routing) {
|
||||
if (routing != null && routing.length() == 0) {
|
||||
this.routing = null;
|
||||
@ -177,6 +180,7 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
||||
* Controls the shard routing of the request. Using this value to hash the shard
|
||||
* and not the id.
|
||||
*/
|
||||
@Override
|
||||
public String routing() {
|
||||
return this.routing;
|
||||
}
|
||||
|
@ -286,6 +286,7 @@ public abstract class AbstractClient implements Client {
|
||||
* @param request The put request
|
||||
* @return The result future
|
||||
*/
|
||||
@Override
|
||||
public ActionFuture<DeleteIndexedScriptResponse> deleteIndexedScript(DeleteIndexedScriptRequest request){
|
||||
return execute(DeleteIndexedScriptAction.INSTANCE, request);
|
||||
}
|
||||
@ -294,6 +295,7 @@ public abstract class AbstractClient implements Client {
|
||||
/**
|
||||
* Delete an indexed script
|
||||
*/
|
||||
@Override
|
||||
public DeleteIndexedScriptRequestBuilder prepareDeleteIndexedScript(){
|
||||
return DeleteIndexedScriptAction.INSTANCE.newRequestBuilder(this);
|
||||
}
|
||||
@ -304,6 +306,7 @@ public abstract class AbstractClient implements Client {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DeleteIndexedScriptRequestBuilder prepareDeleteIndexedScript(@Nullable String scriptLang, String id){
|
||||
return prepareDeleteIndexedScript().setScriptLang(scriptLang).setId(id);
|
||||
}
|
||||
|
@ -302,6 +302,7 @@ public abstract class AbstractClusterAdminClient implements ClusterAdminClient {
|
||||
execute(PendingClusterTasksAction.INSTANCE, request, listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionFuture<PutRepositoryResponse> putRepository(PutRepositoryRequest request) {
|
||||
return execute(PutRepositoryAction.INSTANCE, request);
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ public class DiskUsage {
|
||||
return getTotalBytes() - getFreeBytes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + nodeId + "][" + nodeName + "] free: " + new ByteSizeValue(getFreeBytes()) +
|
||||
"[" + Strings.format1Decimals(getFreeDiskAsPercentage(), "%") + "]";
|
||||
|
@ -33,6 +33,7 @@ public abstract class ClusterStateUpdateRequest<T extends ClusterStateUpdateRequ
|
||||
/**
|
||||
* Returns the maximum time interval to wait for acknowledgements
|
||||
*/
|
||||
@Override
|
||||
public TimeValue ackTimeout() {
|
||||
return ackTimeout;
|
||||
}
|
||||
@ -50,6 +51,7 @@ public abstract class ClusterStateUpdateRequest<T extends ClusterStateUpdateRequ
|
||||
* Returns the maximum time interval to wait for the request to
|
||||
* be completed on the master node
|
||||
*/
|
||||
@Override
|
||||
public TimeValue masterNodeTimeout() {
|
||||
return masterNodeTimeout;
|
||||
}
|
||||
|
@ -152,6 +152,7 @@ public class ClusterBlock implements Serializable, Streamable, ToXContent {
|
||||
RestStatus.writeTo(out, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(id).append(",").append(description).append(", blocks ");
|
||||
|
@ -375,6 +375,7 @@ public class MetaDataMappingService extends AbstractComponent {
|
||||
clusterService.submitStateUpdateTask("update-mapping [" + index + "][" + type + "] / node [" + nodeId + "], order [" + order + "]", Priority.HIGH, new ProcessedClusterStateUpdateTask() {
|
||||
private volatile List<MappingTask> allTasks;
|
||||
|
||||
@Override
|
||||
public void onFailure(String source, Throwable t) {
|
||||
listener.onFailure(t);
|
||||
}
|
||||
|
@ -248,6 +248,7 @@ public class ImmutableShardRouting implements Streamable, Serializable, ShardRou
|
||||
* @param out {@link StreamOutput} to write shard information to
|
||||
* @throws IOException if something happens during write
|
||||
*/
|
||||
@Override
|
||||
public void writeToThin(StreamOutput out) throws IOException {
|
||||
out.writeLong(version);
|
||||
if (currentNodeId != null) {
|
||||
|
@ -762,6 +762,7 @@ public class RoutingNodes implements Iterable<RoutingNode> {
|
||||
return shard = delegate.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
delegate.remove();
|
||||
RoutingNodes.this.remove(shard);
|
||||
|
@ -34,5 +34,6 @@ public interface ShardIterator extends ShardsIterator, Comparable<ShardIterator>
|
||||
/**
|
||||
* Resets the iterator.
|
||||
*/
|
||||
@Override
|
||||
void reset();
|
||||
}
|
||||
|
@ -880,6 +880,7 @@ public class BalancedShardsAllocator extends AbstractComponent implements Shards
|
||||
return removed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Node(").append(id).append(")");
|
||||
|
@ -120,6 +120,7 @@ public class AllocationDeciders extends AllocationDecider {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Decision canAllocate(ShardRouting shardRouting, RoutingAllocation allocation) {
|
||||
Decision.Multi ret = new Decision.Multi();
|
||||
for (AllocationDecider allocationDecider : allocations) {
|
||||
@ -138,6 +139,7 @@ public class AllocationDeciders extends AllocationDecider {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Decision canAllocate(RoutingNode node, RoutingAllocation allocation) {
|
||||
Decision.Multi ret = new Decision.Multi();
|
||||
for (AllocationDecider allocationDecider : allocations) {
|
||||
|
@ -283,6 +283,7 @@ public class DiskThresholdDecider extends AllocationDecider {
|
||||
return shardSize == null ? 0 : shardSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
|
||||
|
||||
// Always allow allocation if the decider is disabled
|
||||
@ -437,6 +438,7 @@ public class DiskThresholdDecider extends AllocationDecider {
|
||||
return allocation.decision(Decision.YES, NAME, "enough disk for shard on node, free: [%s]", new ByteSizeValue(freeBytes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Decision canRemain(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
|
||||
if (!enabled) {
|
||||
return allocation.decision(Decision.YES, NAME, "disk threshold decider disabled");
|
||||
|
@ -43,6 +43,7 @@ public class ReplicaAfterPrimaryActiveAllocationDecider extends AllocationDecide
|
||||
return canAllocate(shardRouting, allocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Decision canAllocate(ShardRouting shardRouting, RoutingAllocation allocation) {
|
||||
if (shardRouting.primary()) {
|
||||
return allocation.decision(Decision.YES, NAME, "shard is primary");
|
||||
|
@ -82,6 +82,7 @@ public class SnapshotInProgressAllocationDecider extends AllocationDecider {
|
||||
* re-balanced to the given allocation. The default is
|
||||
* {@link Decision#ALWAYS}.
|
||||
*/
|
||||
@Override
|
||||
public Decision canRebalance(ShardRouting shardRouting, RoutingAllocation allocation) {
|
||||
return canMove(shardRouting, allocation);
|
||||
}
|
||||
@ -90,6 +91,7 @@ public class SnapshotInProgressAllocationDecider extends AllocationDecider {
|
||||
* Returns a {@link Decision} whether the given shard routing can be
|
||||
* allocated on the given node. The default is {@link Decision#ALWAYS}.
|
||||
*/
|
||||
@Override
|
||||
public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, RoutingAllocation allocation) {
|
||||
return canMove(shardRouting, allocation);
|
||||
}
|
||||
|
@ -103,6 +103,7 @@ public class ThrottlingAllocationDecider extends AllocationDecider {
|
||||
return canAllocate(node, allocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Decision canAllocate(RoutingNode node, RoutingAllocation allocation) {
|
||||
int currentRecoveries = 0;
|
||||
for (MutableShardRouting shard : node) {
|
||||
|
@ -128,6 +128,7 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
|
||||
return this.nodeSettingsService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInitialStateBlock(ClusterBlock block) throws ElasticsearchIllegalStateException {
|
||||
if (lifecycle.started()) {
|
||||
throw new ElasticsearchIllegalStateException("can't set initial block when started");
|
||||
@ -188,22 +189,27 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
|
||||
return operationRouting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClusterState state() {
|
||||
return this.clusterState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFirst(ClusterStateListener listener) {
|
||||
priorityClusterStateListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLast(ClusterStateListener listener) {
|
||||
lastClusterStateListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(ClusterStateListener listener) {
|
||||
clusterStateListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(ClusterStateListener listener) {
|
||||
clusterStateListeners.remove(listener);
|
||||
priorityClusterStateListeners.remove(listener);
|
||||
@ -228,6 +234,7 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
|
||||
localNodeMasterListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(final TimeValue timeout, final TimeoutClusterStateListener listener) {
|
||||
if (lifecycle.stoppedOrClosed()) {
|
||||
listener.onClose();
|
||||
@ -254,10 +261,12 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitStateUpdateTask(final String source, final ClusterStateUpdateTask updateTask) {
|
||||
submitStateUpdateTask(source, Priority.NORMAL, updateTask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitStateUpdateTask(final String source, Priority priority, final ClusterStateUpdateTask updateTask) {
|
||||
if (!lifecycle.started()) {
|
||||
return;
|
||||
|
@ -76,6 +76,7 @@ public final class Priority implements Comparable<Priority> {
|
||||
return values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Priority p) {
|
||||
return (this.value < p.value) ? -1 : ((this.value > p.value) ? 1 : 0);
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public class FsBlobContainer extends AbstractBlobContainer {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableMap<String, BlobMetaData> listBlobs() throws IOException {
|
||||
Path[] files = FileSystemUtils.files(path);
|
||||
if (files.length == 0) {
|
||||
|
@ -220,6 +220,7 @@ public class ChildMemoryCircuitBreaker implements CircuitBreaker {
|
||||
/**
|
||||
* @return the name of the breaker
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ public class MemoryCircuitBreaker implements CircuitBreaker {
|
||||
* Method used to trip the breaker
|
||||
* @throws CircuitBreakingException
|
||||
*/
|
||||
@Override
|
||||
public void circuitBreak(String fieldName, long bytesNeeded) throws CircuitBreakingException {
|
||||
this.trippedCount.incrementAndGet();
|
||||
final String message = "Data too large, data for field [" + fieldName + "] would be larger than limit of [" +
|
||||
@ -94,6 +95,7 @@ public class MemoryCircuitBreaker implements CircuitBreaker {
|
||||
* @return number of "used" bytes so far
|
||||
* @throws CircuitBreakingException
|
||||
*/
|
||||
@Override
|
||||
public double addEstimateBytesAndMaybeBreak(long bytes, String label) throws CircuitBreakingException {
|
||||
// short-circuit on no data allowed, immediately throwing an exception
|
||||
if (memoryBytesLimit == 0) {
|
||||
@ -146,6 +148,7 @@ public class MemoryCircuitBreaker implements CircuitBreaker {
|
||||
* @param bytes number of bytes to add to the breaker
|
||||
* @return number of "used" bytes so far
|
||||
*/
|
||||
@Override
|
||||
public long addWithoutBreaking(long bytes) {
|
||||
long u = used.addAndGet(bytes);
|
||||
if (logger.isTraceEnabled()) {
|
||||
@ -158,6 +161,7 @@ public class MemoryCircuitBreaker implements CircuitBreaker {
|
||||
/**
|
||||
* @return the number of aggregated "used" bytes so far
|
||||
*/
|
||||
@Override
|
||||
public long getUsed() {
|
||||
return this.used.get();
|
||||
}
|
||||
@ -165,6 +169,7 @@ public class MemoryCircuitBreaker implements CircuitBreaker {
|
||||
/**
|
||||
* @return the number of bytes that can be added before the breaker trips
|
||||
*/
|
||||
@Override
|
||||
public long getLimit() {
|
||||
return this.memoryBytesLimit;
|
||||
}
|
||||
@ -172,6 +177,7 @@ public class MemoryCircuitBreaker implements CircuitBreaker {
|
||||
/**
|
||||
* @return the constant multiplier the breaker uses for aggregations
|
||||
*/
|
||||
@Override
|
||||
public double getOverhead() {
|
||||
return this.overheadConstant;
|
||||
}
|
||||
@ -179,6 +185,7 @@ public class MemoryCircuitBreaker implements CircuitBreaker {
|
||||
/**
|
||||
* @return the number of times the breaker has been tripped
|
||||
*/
|
||||
@Override
|
||||
public long getTrippedCount() {
|
||||
return this.trippedCount.get();
|
||||
}
|
||||
@ -186,6 +193,7 @@ public class MemoryCircuitBreaker implements CircuitBreaker {
|
||||
/**
|
||||
* @return the name of the breaker
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return FIELDDATA;
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ public class IdentityHashSet<E>
|
||||
* @return an Iterator over the elements in this set
|
||||
* @see ConcurrentModificationException
|
||||
*/
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
return map.keySet().iterator();
|
||||
}
|
||||
@ -64,6 +65,7 @@ public class IdentityHashSet<E>
|
||||
*
|
||||
* @return the number of elements in this set (its cardinality)
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return map.size();
|
||||
}
|
||||
@ -73,6 +75,7 @@ public class IdentityHashSet<E>
|
||||
*
|
||||
* @return <tt>true</tt> if this set contains no elements
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return map.isEmpty();
|
||||
}
|
||||
@ -86,6 +89,7 @@ public class IdentityHashSet<E>
|
||||
* @param o element whose presence in this set is to be tested
|
||||
* @return <tt>true</tt> if this set contains the specified element
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return map.containsKey(o);
|
||||
}
|
||||
@ -102,6 +106,7 @@ public class IdentityHashSet<E>
|
||||
* @return <tt>true</tt> if this set did not already contain the specified
|
||||
* element
|
||||
*/
|
||||
@Override
|
||||
public boolean add(E e) {
|
||||
return map.put(e, PRESENT) == null;
|
||||
}
|
||||
@ -118,6 +123,7 @@ public class IdentityHashSet<E>
|
||||
* @param o object to be removed from this set, if present
|
||||
* @return <tt>true</tt> if the set contained the specified element
|
||||
*/
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return map.remove(o) == PRESENT;
|
||||
}
|
||||
@ -126,6 +132,7 @@ public class IdentityHashSet<E>
|
||||
* Removes all of the elements from this set.
|
||||
* The set will be empty after this call returns.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
map.clear();
|
||||
}
|
||||
@ -136,6 +143,7 @@ public class IdentityHashSet<E>
|
||||
*
|
||||
* @return a shallow copy of this set
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
try {
|
||||
IdentityHashSet<E> newSet = (IdentityHashSet<E>) super.clone();
|
||||
|
@ -126,6 +126,7 @@ public final class GeoPoint {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[" + lat + ", " + lon + "]";
|
||||
}
|
||||
|
@ -109,6 +109,7 @@ public class HttpDownloadHelper {
|
||||
/**
|
||||
* begin a download
|
||||
*/
|
||||
@Override
|
||||
public void beginDownload() {
|
||||
|
||||
}
|
||||
@ -116,12 +117,14 @@ public class HttpDownloadHelper {
|
||||
/**
|
||||
* tick handler
|
||||
*/
|
||||
@Override
|
||||
public void onTick() {
|
||||
}
|
||||
|
||||
/**
|
||||
* end a download
|
||||
*/
|
||||
@Override
|
||||
public void endDownload() {
|
||||
|
||||
}
|
||||
@ -157,6 +160,7 @@ public class HttpDownloadHelper {
|
||||
/**
|
||||
* begin a download
|
||||
*/
|
||||
@Override
|
||||
public void beginDownload() {
|
||||
writer.print("Downloading ");
|
||||
dots = 0;
|
||||
@ -165,6 +169,7 @@ public class HttpDownloadHelper {
|
||||
/**
|
||||
* tick handler
|
||||
*/
|
||||
@Override
|
||||
public void onTick() {
|
||||
writer.print(".");
|
||||
if (dots++ > 50) {
|
||||
@ -176,6 +181,7 @@ public class HttpDownloadHelper {
|
||||
/**
|
||||
* end a download
|
||||
*/
|
||||
@Override
|
||||
public void endDownload() {
|
||||
writer.println("DONE");
|
||||
writer.flush();
|
||||
@ -205,6 +211,7 @@ public class HttpDownloadHelper {
|
||||
progress = p;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
success = get();
|
||||
|
@ -52,6 +52,7 @@ public abstract class AbstractModule implements Module {
|
||||
|
||||
Binder binder;
|
||||
|
||||
@Override
|
||||
public final synchronized void configure(Binder builder) {
|
||||
checkState(this.binder == null, "Re-entry is not allowed.");
|
||||
|
||||
|
@ -64,42 +64,52 @@ abstract class AbstractProcessor implements ElementVisitor<Boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visit(Message message) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visit(ScopeBinding scopeBinding) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visit(InjectionRequest injectionRequest) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visit(StaticInjectionRequest staticInjectionRequest) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visit(TypeConverterBinding typeConverterBinding) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Boolean visit(Binding<T> binding) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Boolean visit(ProviderLookup<T> providerLookup) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visit(PrivateElements privateElements) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Boolean visit(MembersInjectorLookup<T> lookup) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean visit(TypeListenerBinding binding) {
|
||||
return false;
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ class BindingProcessor extends AbstractProcessor {
|
||||
|
||||
command.acceptTargetVisitor(new BindingTargetVisitor<T, Void>() {
|
||||
|
||||
@Override
|
||||
public Void visit(InstanceBinding<? extends T> binding) {
|
||||
Set<InjectionPoint> injectionPoints = binding.getInjectionPoints();
|
||||
T instance = binding.getInstance();
|
||||
@ -82,6 +83,7 @@ class BindingProcessor extends AbstractProcessor {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(ProviderInstanceBinding<? extends T> binding) {
|
||||
Provider<? extends T> provider = binding.getProviderInstance();
|
||||
Set<InjectionPoint> injectionPoints = binding.getInjectionPoints();
|
||||
@ -94,6 +96,7 @@ class BindingProcessor extends AbstractProcessor {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(ProviderKeyBinding<? extends T> binding) {
|
||||
Key<? extends Provider<? extends T>> providerKey = binding.getProviderKey();
|
||||
BoundProviderFactory<T> boundProviderFactory
|
||||
@ -106,6 +109,7 @@ class BindingProcessor extends AbstractProcessor {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(LinkedKeyBinding<? extends T> binding) {
|
||||
Key<? extends T> linkedKey = binding.getLinkedKey();
|
||||
if (key.equals(linkedKey)) {
|
||||
@ -120,6 +124,7 @@ class BindingProcessor extends AbstractProcessor {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(UntargettedBinding<? extends T> untargetted) {
|
||||
// Error: Missing implementation.
|
||||
// Example: bind(Date.class).annotatedWith(Red.class);
|
||||
@ -143,6 +148,7 @@ class BindingProcessor extends AbstractProcessor {
|
||||
}
|
||||
|
||||
uninitializedBindings.add(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
((InjectorImpl) binding.getInjector()).initializeBinding(
|
||||
@ -156,18 +162,22 @@ class BindingProcessor extends AbstractProcessor {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(ExposedBinding<? extends T> binding) {
|
||||
throw new IllegalArgumentException("Cannot apply a non-module element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(ConvertedConstantBinding<? extends T> binding) {
|
||||
throw new IllegalArgumentException("Cannot apply a non-module element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(ConstructorBinding<? extends T> binding) {
|
||||
throw new IllegalArgumentException("Cannot apply a non-module element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(ProviderBinding<? extends T> binding) {
|
||||
throw new IllegalArgumentException("Cannot apply a non-module element");
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ class BoundProviderFactory<T> implements InternalFactory<T>, CreationListener {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notify(Errors errors) {
|
||||
try {
|
||||
providerFactory = injector.getInternalFactory(providerKey, errors.withSource(source));
|
||||
@ -50,6 +51,7 @@ class BoundProviderFactory<T> implements InternalFactory<T>, CreationListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(Errors errors, InternalContext context, Dependency<?> dependency)
|
||||
throws ErrorsException {
|
||||
errors = errors.withSource(providerKey);
|
||||
|
@ -30,11 +30,13 @@ class ConstantFactory<T> implements InternalFactory<T> {
|
||||
this.initializable = initializable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(Errors errors, InternalContext context, Dependency dependency)
|
||||
throws ErrorsException {
|
||||
return initializable.get(errors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(ConstantFactory.class)
|
||||
.add("value", initializable)
|
||||
|
@ -50,21 +50,25 @@ class ConstructorBindingImpl<T> extends BindingImpl<T> implements ConstructorBin
|
||||
factory.constructorInjector = injector.constructors.get(getKey().getTypeLiteral(), errors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor) {
|
||||
checkState(factory.constructorInjector != null, "not initialized");
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InjectionPoint getConstructor() {
|
||||
checkState(factory.constructorInjector != null, "Binding is not ready");
|
||||
return factory.constructorInjector.getConstructionProxy().getInjectionPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<InjectionPoint> getInjectableMembers() {
|
||||
checkState(factory.constructorInjector != null, "Binding is not ready");
|
||||
return factory.constructorInjector.getInjectableMembers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Dependency<?>> getDependencies() {
|
||||
return Dependency.forInjectionPoints(new ImmutableSet.Builder<InjectionPoint>()
|
||||
.add(getConstructor())
|
||||
@ -72,6 +76,7 @@ class ConstructorBindingImpl<T> extends BindingImpl<T> implements ConstructorBin
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(Binder binder) {
|
||||
throw new UnsupportedOperationException("This element represents a synthetic binding.");
|
||||
}
|
||||
@ -88,6 +93,7 @@ class ConstructorBindingImpl<T> extends BindingImpl<T> implements ConstructorBin
|
||||
private static class Factory<T> implements InternalFactory<T> {
|
||||
private ConstructorInjector<T> constructorInjector;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public T get(Errors errors, InternalContext context, Dependency<?> dependency)
|
||||
throws ErrorsException {
|
||||
|
@ -31,6 +31,7 @@ class ConstructorInjectorStore {
|
||||
|
||||
private final FailableCache<TypeLiteral<?>, ConstructorInjector<?>> cache
|
||||
= new FailableCache<TypeLiteral<?>, ConstructorInjector<?>>() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected ConstructorInjector<?> create(TypeLiteral<?> type, Errors errors)
|
||||
throws ErrorsException {
|
||||
|
@ -38,6 +38,7 @@ class DefaultConstructionProxyFactory<T> implements ConstructionProxyFactory<T>
|
||||
this.injectionPoint = injectionPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstructionProxy<T> create() {
|
||||
@SuppressWarnings("unchecked") // the injection point is for a constructor of T
|
||||
final Constructor<T> constructor = (Constructor<T>) injectionPoint.getMember();
|
||||
@ -49,6 +50,7 @@ class DefaultConstructionProxyFactory<T> implements ConstructionProxyFactory<T>
|
||||
}
|
||||
|
||||
return new ConstructionProxy<T>() {
|
||||
@Override
|
||||
public T newInstance(Object... arguments) throws InvocationTargetException {
|
||||
try {
|
||||
return constructor.newInstance(arguments);
|
||||
@ -59,10 +61,12 @@ class DefaultConstructionProxyFactory<T> implements ConstructionProxyFactory<T>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InjectionPoint getInjectionPoint() {
|
||||
return injectionPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constructor<T> getConstructor() {
|
||||
return constructor;
|
||||
}
|
||||
|
@ -46,12 +46,14 @@ class DeferredLookups implements Lookups {
|
||||
new LookupProcessor(errors).process(injector, lookups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Provider<T> getProvider(Key<T> key) {
|
||||
ProviderLookup<T> lookup = new ProviderLookup<>(key, key);
|
||||
lookups.add(lookup);
|
||||
return lookup.getProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> type) {
|
||||
MembersInjectorLookup<T> lookup = new MembersInjectorLookup<>(type, type);
|
||||
lookups.add(lookup);
|
||||
|
@ -59,6 +59,7 @@ final class EncounterImpl<T> implements TypeEncounter<T> {
|
||||
: ImmutableList.copyOf(injectionListeners);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(MembersInjector<? super T> membersInjector) {
|
||||
checkState(valid, "Encounters may not be used after hear() returns.");
|
||||
|
||||
@ -69,6 +70,7 @@ final class EncounterImpl<T> implements TypeEncounter<T> {
|
||||
membersInjectors.add(membersInjector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(InjectionListener<? super T> injectionListener) {
|
||||
checkState(valid, "Encounters may not be used after hear() returns.");
|
||||
|
||||
@ -79,35 +81,42 @@ final class EncounterImpl<T> implements TypeEncounter<T> {
|
||||
injectionListeners.add(injectionListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addError(String message, Object... arguments) {
|
||||
checkState(valid, "Encounters may not be used after hear() returns.");
|
||||
errors.addMessage(message, arguments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addError(Throwable t) {
|
||||
checkState(valid, "Encounters may not be used after hear() returns.");
|
||||
errors.errorInUserCode(t, "An exception was caught and reported. Message: %s", t.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addError(Message message) {
|
||||
checkState(valid, "Encounters may not be used after hear() returns.");
|
||||
errors.addMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Provider<T> getProvider(Key<T> key) {
|
||||
checkState(valid, "Encounters may not be used after hear() returns.");
|
||||
return lookups.getProvider(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Provider<T> getProvider(Class<T> type) {
|
||||
return getProvider(Key.get(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral) {
|
||||
checkState(valid, "Encounters may not be used after hear() returns.");
|
||||
return lookups.getMembersInjector(typeLiteral);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> MembersInjector<T> getMembersInjector(Class<T> type) {
|
||||
return getMembersInjector(TypeLiteral.get(type));
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ class ExposedKeyFactory<T> implements InternalFactory<T>, BindingProcessor.Creat
|
||||
this.privateElements = privateElements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notify(Errors errors) {
|
||||
InjectorImpl privateInjector = (InjectorImpl) privateElements.getInjector();
|
||||
BindingImpl<T> explicitBinding = privateInjector.state.getExplicitBinding(key);
|
||||
@ -49,6 +50,7 @@ class ExposedKeyFactory<T> implements InternalFactory<T>, BindingProcessor.Creat
|
||||
this.delegate = explicitBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(Errors errors, InternalContext context, Dependency<?> dependency)
|
||||
throws ErrorsException {
|
||||
return delegate.getInternalFactory().get(errors, context, dependency);
|
||||
|
@ -39,6 +39,7 @@ class FactoryProxy<T> implements InternalFactory<T>, BindingProcessor.CreationLi
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notify(final Errors errors) {
|
||||
try {
|
||||
targetFactory = injector.getInternalFactory(targetKey, errors.withSource(source));
|
||||
@ -47,6 +48,7 @@ class FactoryProxy<T> implements InternalFactory<T>, BindingProcessor.CreationLi
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(Errors errors, InternalContext context, Dependency<?> dependency)
|
||||
throws ErrorsException {
|
||||
return targetFactory.get(errors.withSource(targetKey), context, dependency);
|
||||
|
@ -53,41 +53,50 @@ class InheritingState implements State {
|
||||
this.lock = (parent == State.NONE) ? this : parent.lock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public State parent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked") // we only put in BindingImpls that match their key types
|
||||
public <T> BindingImpl<T> getExplicitBinding(Key<T> key) {
|
||||
Binding<?> binding = explicitBindings.get(key);
|
||||
return binding != null ? (BindingImpl<T>) binding : parent.getExplicitBinding(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Key<?>, Binding<?>> getExplicitBindingsThisLevel() {
|
||||
return explicitBindings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putBinding(Key<?> key, BindingImpl<?> binding) {
|
||||
explicitBindingsMutable.put(key, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scope getScope(Class<? extends Annotation> annotationType) {
|
||||
Scope scope = scopes.get(annotationType);
|
||||
return scope != null ? scope : parent.getScope(annotationType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAnnotation(Class<? extends Annotation> annotationType, Scope scope) {
|
||||
scopes.put(annotationType, scope);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<MatcherAndConverter> getConvertersThisLevel() {
|
||||
return converters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConverter(MatcherAndConverter matcherAndConverter) {
|
||||
converters.add(matcherAndConverter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatcherAndConverter getConverter(
|
||||
String stringValue, TypeLiteral<?> type, Errors errors, Object source) {
|
||||
MatcherAndConverter matchingConverter = null;
|
||||
@ -104,10 +113,12 @@ class InheritingState implements State {
|
||||
return matchingConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTypeListener(TypeListenerBinding listenerBinding) {
|
||||
listenerBindings.add(listenerBinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TypeListenerBinding> getTypeListenerBindings() {
|
||||
List<TypeListenerBinding> parentBindings = parent.getTypeListenerBindings();
|
||||
List<TypeListenerBinding> result
|
||||
@ -117,11 +128,13 @@ class InheritingState implements State {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blacklist(Key<?> key) {
|
||||
parent.blacklist(key);
|
||||
blacklistedKeys.add(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlacklisted(Key<?> key) {
|
||||
return blacklistedKeys.contains(key);
|
||||
}
|
||||
@ -144,6 +157,7 @@ class InheritingState implements State {
|
||||
this.explicitBindingsMutable.putAll(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object lock() {
|
||||
return lock;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ class Initializables {
|
||||
*/
|
||||
static <T> Initializable<T> of(final T instance) {
|
||||
return new Initializable<T>() {
|
||||
@Override
|
||||
public T get(Errors errors) throws ErrorsException {
|
||||
return instance;
|
||||
}
|
||||
|
@ -132,6 +132,7 @@ class Initializer {
|
||||
* Reentrant. If {@code instance} was registered for injection at injector-creation time, this
|
||||
* method will ensure that all its members have been injected before returning.
|
||||
*/
|
||||
@Override
|
||||
public T get(Errors errors) throws ErrorsException {
|
||||
if (ready.getCount() == 0) {
|
||||
return instance;
|
||||
|
@ -109,6 +109,7 @@ class InjectionRequestProcessor extends AbstractProcessor {
|
||||
void injectMembers() {
|
||||
try {
|
||||
injector.callInContext(new ContextualCallable<Void>() {
|
||||
@Override
|
||||
public Void call(InternalContext context) {
|
||||
for (SingleMemberInjector injector : memberInjectors) {
|
||||
injector.inject(errors, context, null);
|
||||
|
@ -193,6 +193,7 @@ class InjectorBuilder {
|
||||
injector.callInContext(new ContextualCallable<Void>() {
|
||||
Dependency<?> dependency = Dependency.get(binding.getKey());
|
||||
|
||||
@Override
|
||||
public Void call(InternalContext context) {
|
||||
context.setDependency(dependency);
|
||||
Errors errorsForBinding = errors.withSource(dependency);
|
||||
@ -224,64 +225,78 @@ class InjectorBuilder {
|
||||
this.delegateInjector = delegateInjector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectMembers(Object o) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Injector.injectMembers(Object) is not supported in Stage.TOOL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Key<?>, Binding<?>> getBindings() {
|
||||
return this.delegateInjector.getBindings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Binding<T> getBinding(Key<T> key) {
|
||||
return this.delegateInjector.getBinding(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Binding<T> getBinding(Class<T> type) {
|
||||
return this.delegateInjector.getBinding(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<Binding<T>> findBindingsByType(TypeLiteral<T> type) {
|
||||
return this.delegateInjector.findBindingsByType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injector getParent() {
|
||||
return delegateInjector.getParent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injector createChildInjector(Iterable<? extends Module> modules) {
|
||||
return delegateInjector.createChildInjector(modules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injector createChildInjector(Module... modules) {
|
||||
return delegateInjector.createChildInjector(modules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Provider<T> getProvider(Key<T> key) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Injector.getProvider(Key<T>) is not supported in Stage.TOOL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Provider<T> getProvider(Class<T> type) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Injector.getProvider(Class<T>) is not supported in Stage.TOOL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Injector.getMembersInjector(TypeLiteral<T>) is not supported in Stage.TOOL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> MembersInjector<T> getMembersInjector(Class<T> type) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Injector.getMembersInjector(Class<T>) is not supported in Stage.TOOL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getInstance(Key<T> key) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Injector.getInstance(Key<T>) is not supported in Stage.TOOL");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getInstance(Class<T> type) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Injector.getInstance(Class<T>) is not supported in Stage.TOOL");
|
||||
|
@ -63,6 +63,7 @@ class InjectorImpl implements Injector, Lookups {
|
||||
localContext = parent.localContext;
|
||||
} else {
|
||||
localContext = new ThreadLocal<Object[]>() {
|
||||
@Override
|
||||
protected Object[] initialValue() {
|
||||
return new Object[1];
|
||||
}
|
||||
@ -83,6 +84,7 @@ class InjectorImpl implements Injector, Lookups {
|
||||
bindingsMultimap.put(binding.getKey().getTypeLiteral(), binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<Binding<T>> findBindingsByType(TypeLiteral<T> type) {
|
||||
return bindingsMultimap.getAll(type);
|
||||
}
|
||||
@ -90,6 +92,7 @@ class InjectorImpl implements Injector, Lookups {
|
||||
/**
|
||||
* Returns the binding for {@code key}
|
||||
*/
|
||||
@Override
|
||||
public <T> BindingImpl<T> getBinding(Key<T> key) {
|
||||
Errors errors = new Errors(key);
|
||||
try {
|
||||
@ -119,14 +122,17 @@ class InjectorImpl implements Injector, Lookups {
|
||||
return getJustInTimeBinding(key, errors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Binding<T> getBinding(Class<T> type) {
|
||||
return getBinding(Key.get(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injector getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injector createChildInjector(Iterable<? extends Module> modules) {
|
||||
return new InjectorBuilder()
|
||||
.parentInjector(this)
|
||||
@ -134,6 +140,7 @@ class InjectorImpl implements Injector, Lookups {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injector createChildInjector(Module... modules) {
|
||||
return createChildInjector(ImmutableList.copyOf(modules));
|
||||
}
|
||||
@ -230,20 +237,24 @@ class InjectorImpl implements Injector, Lookups {
|
||||
static <T> InternalFactory<Provider<T>> createInternalFactory(Binding<T> providedBinding) {
|
||||
final Provider<T> provider = providedBinding.getProvider();
|
||||
return new InternalFactory<Provider<T>>() {
|
||||
@Override
|
||||
public Provider<T> get(Errors errors, InternalContext context, Dependency dependency) {
|
||||
return provider;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key<? extends T> getProvidedKey() {
|
||||
return providedBinding.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super Provider<T>, V> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(Binder binder) {
|
||||
throw new UnsupportedOperationException("This element represents a synthetic binding.");
|
||||
}
|
||||
@ -329,22 +340,27 @@ class InjectorImpl implements Injector, Lookups {
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key<String> getSourceKey() {
|
||||
return originalBinding.getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Dependency<?>> getDependencies() {
|
||||
return ImmutableSet.<Dependency<?>>of(Dependency.get(getSourceKey()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(Binder binder) {
|
||||
throw new UnsupportedOperationException("This element represents a synthetic binding.");
|
||||
}
|
||||
@ -488,6 +504,7 @@ class InjectorImpl implements Injector, Lookups {
|
||||
= getBindingOrThrow(providerKey, errors);
|
||||
|
||||
InternalFactory<T> internalFactory = new InternalFactory<T>() {
|
||||
@Override
|
||||
public T get(Errors errors, InternalContext context, Dependency dependency)
|
||||
throws ErrorsException {
|
||||
errors = errors.withSource(providerKey);
|
||||
@ -543,6 +560,7 @@ class InjectorImpl implements Injector, Lookups {
|
||||
final BindingImpl<? extends T> targetBinding = getBindingOrThrow(targetKey, errors);
|
||||
|
||||
InternalFactory<T> internalFactory = new InternalFactory<T>() {
|
||||
@Override
|
||||
public T get(Errors errors, InternalContext context, Dependency<?> dependency)
|
||||
throws ErrorsException {
|
||||
return targetBinding.getInternalFactory().get(
|
||||
@ -652,6 +670,7 @@ class InjectorImpl implements Injector, Lookups {
|
||||
}
|
||||
|
||||
// not test-covered
|
||||
@Override
|
||||
public Map<Key<?>, Binding<?>> getBindings() {
|
||||
return state.getExplicitBindingsThisLevel();
|
||||
}
|
||||
@ -727,12 +746,14 @@ class InjectorImpl implements Injector, Lookups {
|
||||
*/
|
||||
MembersInjectorStore membersInjectorStore;
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked") // the members injector type is consistent with instance's type
|
||||
public void injectMembers(Object instance) {
|
||||
MembersInjector membersInjector = getMembersInjector(instance.getClass());
|
||||
membersInjector.injectMembers(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral) {
|
||||
Errors errors = new Errors(typeLiteral);
|
||||
try {
|
||||
@ -742,10 +763,12 @@ class InjectorImpl implements Injector, Lookups {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> MembersInjector<T> getMembersInjector(Class<T> type) {
|
||||
return getMembersInjector(TypeLiteral.get(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Provider<T> getProvider(Class<T> type) {
|
||||
return getProvider(Key.get(type));
|
||||
}
|
||||
@ -771,10 +794,12 @@ class InjectorImpl implements Injector, Lookups {
|
||||
|
||||
final Dependency<T> dependency = Dependency.get(key);
|
||||
return new Provider<T>() {
|
||||
@Override
|
||||
public T get() {
|
||||
final Errors errors = new Errors(dependency);
|
||||
try {
|
||||
T t = callInContext(new ContextualCallable<T>() {
|
||||
@Override
|
||||
public T call(InternalContext context) throws ErrorsException {
|
||||
context.setDependency(dependency);
|
||||
try {
|
||||
@ -798,6 +823,7 @@ class InjectorImpl implements Injector, Lookups {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Provider<T> getProvider(final Key<T> key) {
|
||||
Errors errors = new Errors(key);
|
||||
try {
|
||||
@ -809,10 +835,12 @@ class InjectorImpl implements Injector, Lookups {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getInstance(Key<T> key) {
|
||||
return getProvider(key).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getInstance(Class<T> type) {
|
||||
return getProvider(type).get();
|
||||
}
|
||||
@ -838,6 +866,7 @@ class InjectorImpl implements Injector, Lookups {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(Injector.class)
|
||||
.add("bindings", state.getExplicitBindingsThisLevel().values())
|
||||
|
@ -190,15 +190,18 @@ class InjectorShell {
|
||||
this.injector = injector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injector get(Errors errors, InternalContext context, Dependency<?> dependency)
|
||||
throws ErrorsException {
|
||||
return injector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Injector get() {
|
||||
return injector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Provider<Injector>";
|
||||
}
|
||||
@ -218,6 +221,7 @@ class InjectorShell {
|
||||
}
|
||||
|
||||
private static class LoggerFactory implements InternalFactory<Logger>, Provider<Logger> {
|
||||
@Override
|
||||
public Logger get(Errors errors, InternalContext context, Dependency<?> dependency) {
|
||||
InjectionPoint injectionPoint = dependency.getInjectionPoint();
|
||||
return injectionPoint == null
|
||||
@ -225,10 +229,12 @@ class InjectorShell {
|
||||
: Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Logger get() {
|
||||
return Logger.getAnonymousLogger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Provider<Logger>";
|
||||
}
|
||||
@ -241,6 +247,7 @@ class InjectorShell {
|
||||
this.stage = checkNotNull(stage, "stage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(Binder binder) {
|
||||
binder = binder.withSource(SourceProvider.UNKNOWN_SOURCE);
|
||||
binder.bind(Stage.class).toInstance(stage);
|
||||
|
@ -39,6 +39,7 @@ class InternalFactoryToProviderAdapter<T> implements InternalFactory<T> {
|
||||
this.source = checkNotNull(source, "source");
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(Errors errors, InternalContext context, Dependency<?> dependency)
|
||||
throws ErrorsException {
|
||||
try {
|
||||
|
@ -382,18 +382,22 @@ public class Key<T> {
|
||||
static enum NullAnnotationStrategy implements AnnotationStrategy {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public boolean hasAttributes() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationStrategy withoutAttributes() {
|
||||
throw new UnsupportedOperationException("Key already has no attributes.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Annotation getAnnotation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Annotation> getAnnotationType() {
|
||||
return null;
|
||||
}
|
||||
@ -413,18 +417,22 @@ public class Key<T> {
|
||||
this.annotation = checkNotNull(annotation, "annotation");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAttributes() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationStrategy withoutAttributes() {
|
||||
return new AnnotationTypeStrategy(getAnnotationType(), annotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Annotation getAnnotation() {
|
||||
return annotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Annotation> getAnnotationType() {
|
||||
return annotation.annotationType();
|
||||
}
|
||||
@ -463,18 +471,22 @@ public class Key<T> {
|
||||
this.annotation = annotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAttributes() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationStrategy withoutAttributes() {
|
||||
throw new UnsupportedOperationException("Key already has no attributes.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Annotation getAnnotation() {
|
||||
return annotation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Annotation> getAnnotationType() {
|
||||
return annotationType;
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ class MembersInjectorImpl<T> implements MembersInjector<T> {
|
||||
return memberInjectors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectMembers(T instance) {
|
||||
Errors errors = new Errors(typeLiteral);
|
||||
try {
|
||||
@ -66,6 +67,7 @@ class MembersInjectorImpl<T> implements MembersInjector<T> {
|
||||
}
|
||||
|
||||
injector.callInContext(new ContextualCallable<Void>() {
|
||||
@Override
|
||||
public Void call(InternalContext context) throws ErrorsException {
|
||||
injectMembers(instance, errors, context);
|
||||
return null;
|
||||
|
@ -46,7 +46,9 @@ public interface PrivateBinder extends Binder {
|
||||
*/
|
||||
AnnotatedElementBuilder expose(TypeLiteral<?> type);
|
||||
|
||||
@Override
|
||||
PrivateBinder withSource(Object source);
|
||||
|
||||
@Override
|
||||
PrivateBinder skipSources(Class... classesToSkip);
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ public abstract class PrivateModule implements Module {
|
||||
*/
|
||||
private PrivateBinder binder;
|
||||
|
||||
@Override
|
||||
public final synchronized void configure(Binder binder) {
|
||||
checkState(this.binder == null, "Re-entry is not allowed.");
|
||||
|
||||
|
@ -36,10 +36,12 @@ class ProviderToInternalFactoryAdapter<T> implements Provider<T> {
|
||||
this.internalFactory = internalFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get() {
|
||||
final Errors errors = new Errors();
|
||||
try {
|
||||
T t = injector.callInContext(new ContextualCallable<T>() {
|
||||
@Override
|
||||
public T call(InternalContext context) throws ErrorsException {
|
||||
Dependency dependency = context.getDependency();
|
||||
return internalFactory.get(errors, context, dependency);
|
||||
|
@ -55,5 +55,6 @@ public interface Scope {
|
||||
* {@code "Scopes.SINGLETON"}, {@code "ServletScopes.SESSION"} and
|
||||
* {@code "ServletScopes.REQUEST"}.
|
||||
*/
|
||||
@Override
|
||||
String toString();
|
||||
}
|
||||
|
@ -37,12 +37,14 @@ public class Scopes {
|
||||
* One instance per {@link Injector}. Also see {@code @}{@link Singleton}.
|
||||
*/
|
||||
public static final Scope SINGLETON = new Scope() {
|
||||
@Override
|
||||
public <T> Provider<T> scope(Key<T> key, final Provider<T> creator) {
|
||||
return new Provider<T>() {
|
||||
|
||||
private volatile T instance;
|
||||
|
||||
// DCL on a volatile is safe as of Java 5, which we obviously require.
|
||||
@Override
|
||||
@SuppressWarnings("DoubleCheckedLocking")
|
||||
public T get() {
|
||||
if (instance == null) {
|
||||
@ -61,6 +63,7 @@ public class Scopes {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(Locale.ROOT, "%s[%s]", creator, SINGLETON);
|
||||
}
|
||||
@ -86,6 +89,7 @@ public class Scopes {
|
||||
* @since 2.0
|
||||
*/
|
||||
public static final Scope NO_SCOPE = new Scope() {
|
||||
@Override
|
||||
public <T> Provider<T> scope(Key<T> key, Provider<T> unscoped) {
|
||||
return unscoped;
|
||||
}
|
||||
|
@ -45,10 +45,12 @@ class SingleFieldInjector implements SingleMemberInjector {
|
||||
factory = injector.getInternalFactory(dependency.getKey(), errors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InjectionPoint getInjectionPoint() {
|
||||
return injectionPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inject(Errors errors, InternalContext context, Object o) {
|
||||
errors = errors.withSource(dependency);
|
||||
|
||||
|
@ -54,6 +54,7 @@ class SingleMethodInjector implements SingleMemberInjector {
|
||||
}
|
||||
|
||||
return new MethodInvoker() {
|
||||
@Override
|
||||
public Object invoke(Object target, Object... parameters)
|
||||
throws IllegalAccessException, InvocationTargetException {
|
||||
return method.invoke(target, parameters);
|
||||
@ -61,10 +62,12 @@ class SingleMethodInjector implements SingleMemberInjector {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public InjectionPoint getInjectionPoint() {
|
||||
return injectionPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inject(Errors errors, InternalContext context, Object o) {
|
||||
Object[] parameters;
|
||||
try {
|
||||
|
@ -36,54 +36,67 @@ import java.util.Map;
|
||||
interface State {
|
||||
|
||||
static final State NONE = new State() {
|
||||
@Override
|
||||
public State parent() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> BindingImpl<T> getExplicitBinding(Key<T> key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Key<?>, Binding<?>> getExplicitBindingsThisLevel() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putBinding(Key<?> key, BindingImpl<?> binding) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scope getScope(Class<? extends Annotation> scopingAnnotation) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAnnotation(Class<? extends Annotation> annotationType, Scope scope) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConverter(MatcherAndConverter matcherAndConverter) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatcherAndConverter getConverter(String stringValue, TypeLiteral<?> type, Errors errors,
|
||||
Object source) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<MatcherAndConverter> getConvertersThisLevel() {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTypeListener(TypeListenerBinding typeListenerBinding) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TypeListenerBinding> getTypeListenerBindings() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void blacklist(Key<?> key) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlacklisted(Key<?> key) {
|
||||
return true;
|
||||
}
|
||||
@ -96,6 +109,7 @@ interface State {
|
||||
public void makeAllBindingsToEagerSingletons(Injector injector) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object lock() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ class TypeConverterBindingProcessor extends AbstractProcessor {
|
||||
convertToPrimitiveType(double.class, Double.class);
|
||||
|
||||
convertToClass(Character.class, new TypeConverter() {
|
||||
@Override
|
||||
public Object convert(String value, TypeLiteral<?> toType) {
|
||||
value = value.trim();
|
||||
if (value.length() != 1) {
|
||||
@ -74,6 +75,7 @@ class TypeConverterBindingProcessor extends AbstractProcessor {
|
||||
});
|
||||
|
||||
convertToClasses(Matchers.subclassesOf(Enum.class), new TypeConverter() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(String value, TypeLiteral<?> toType) {
|
||||
return Enum.valueOf((Class) toType.getRawType(), value);
|
||||
@ -87,6 +89,7 @@ class TypeConverterBindingProcessor extends AbstractProcessor {
|
||||
|
||||
internalConvertToTypes(
|
||||
new AbstractMatcher<TypeLiteral<?>>() {
|
||||
@Override
|
||||
public boolean matches(TypeLiteral<?> typeLiteral) {
|
||||
return typeLiteral.getRawType() == Class.class;
|
||||
}
|
||||
@ -97,6 +100,7 @@ class TypeConverterBindingProcessor extends AbstractProcessor {
|
||||
}
|
||||
},
|
||||
new TypeConverter() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(String value, TypeLiteral<?> toType) {
|
||||
try {
|
||||
@ -123,6 +127,7 @@ class TypeConverterBindingProcessor extends AbstractProcessor {
|
||||
"parse" + Strings.capitalize(primitiveType.getName()), String.class);
|
||||
|
||||
TypeConverter typeConverter = new TypeConverter() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(String value, TypeLiteral<?> toType) {
|
||||
try {
|
||||
@ -153,6 +158,7 @@ class TypeConverterBindingProcessor extends AbstractProcessor {
|
||||
private void convertToClasses(final Matcher<? super Class<?>> typeMatcher,
|
||||
TypeConverter converter) {
|
||||
internalConvertToTypes(new AbstractMatcher<TypeLiteral<?>>() {
|
||||
@Override
|
||||
public boolean matches(TypeLiteral<?> typeLiteral) {
|
||||
Type type = typeLiteral.getType();
|
||||
if (!(type instanceof Class)) {
|
||||
|
@ -279,6 +279,7 @@ public class FactoryProvider<F> implements Provider<F>, HasDependencies {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Dependency<?>> getDependencies() {
|
||||
List<Dependency<?>> dependencies = Lists.newArrayList();
|
||||
for (AssistedConstructor<?> constructor : factoryMethodToConstructor.values()) {
|
||||
@ -291,8 +292,10 @@ public class FactoryProvider<F> implements Provider<F>, HasDependencies {
|
||||
return ImmutableSet.copyOf(dependencies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public F get() {
|
||||
InvocationHandler invocationHandler = new InvocationHandler() {
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] creationArgs) throws Throwable {
|
||||
// pass methods from Object.class to the proxy
|
||||
if (method.getDeclaringClass().equals(Object.class)) {
|
||||
|
@ -49,10 +49,12 @@ final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {
|
||||
* if a factory method parameter isn't annotated, it gets this annotation.
|
||||
*/
|
||||
static final Assisted DEFAULT_ANNOTATION = new Assisted() {
|
||||
@Override
|
||||
public String value() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Annotation> annotationType() {
|
||||
return Assisted.class;
|
||||
}
|
||||
@ -133,6 +135,7 @@ final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {
|
||||
new Class[]{factoryRawType}, this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public F get() {
|
||||
return factory;
|
||||
}
|
||||
@ -185,6 +188,7 @@ final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {
|
||||
final Key<?> returnType = returnTypesByMethod.get(method);
|
||||
|
||||
Module assistedModule = new AbstractModule() {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked") // raw keys are necessary for the args array and return value
|
||||
protected void configure() {
|
||||
Binder binder = binder().withSource(method);
|
||||
@ -211,6 +215,7 @@ final class FactoryProvider2<F> implements InvocationHandler, Provider<F> {
|
||||
* When a factory method is invoked, we create a child injector that binds all parameters, then
|
||||
* use that to get an instance of the return type.
|
||||
*/
|
||||
@Override
|
||||
public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable {
|
||||
if (method.getDeclaringClass() == Object.class) {
|
||||
return method.invoke(this, args);
|
||||
|
@ -41,24 +41,29 @@ public class BindingBuilder<T> extends AbstractBindingBuilder<T>
|
||||
super(binder, elements, source, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingBuilder<T> annotatedWith(Class<? extends Annotation> annotationType) {
|
||||
annotatedWithInternal(annotationType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingBuilder<T> annotatedWith(Annotation annotation) {
|
||||
annotatedWithInternal(annotation);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingBuilder<T> to(Class<? extends T> implementation) {
|
||||
return to(Key.get(implementation));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingBuilder<T> to(TypeLiteral<? extends T> implementation) {
|
||||
return to(Key.get(implementation));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingBuilder<T> to(Key<? extends T> linkedKey) {
|
||||
checkNotNull(linkedKey, "linkedKey");
|
||||
checkNotTargetted();
|
||||
@ -68,6 +73,7 @@ public class BindingBuilder<T> extends AbstractBindingBuilder<T>
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toInstance(T instance) {
|
||||
checkNotTargetted();
|
||||
|
||||
@ -92,6 +98,7 @@ public class BindingBuilder<T> extends AbstractBindingBuilder<T>
|
||||
base.getSource(), base.getKey(), base.getScoping(), injectionPoints, instance));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingBuilder<T> toProvider(Provider<? extends T> provider) {
|
||||
checkNotNull(provider, "provider");
|
||||
checkNotTargetted();
|
||||
@ -113,10 +120,12 @@ public class BindingBuilder<T> extends AbstractBindingBuilder<T>
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingBuilder<T> toProvider(Class<? extends Provider<? extends T>> providerType) {
|
||||
return toProvider(Key.get(providerType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingBuilder<T> toProvider(Key<? extends Provider<? extends T>> providerKey) {
|
||||
checkNotNull(providerKey, "providerKey");
|
||||
checkNotTargetted();
|
||||
|
@ -52,16 +52,19 @@ public abstract class BindingImpl<T> implements Binding<T> {
|
||||
this.scoping = scoping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key<T> getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
private volatile Provider<T> provider;
|
||||
|
||||
@Override
|
||||
public Provider<T> getProvider() {
|
||||
if (provider == null) {
|
||||
if (injector == null) {
|
||||
@ -89,10 +92,12 @@ public abstract class BindingImpl<T> implements Binding<T> {
|
||||
return this instanceof InstanceBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> V acceptVisitor(ElementVisitor<V> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> V acceptScopingVisitor(BindingScopingVisitor<V> visitor) {
|
||||
return scoping.acceptVisitor(visitor);
|
||||
}
|
||||
|
@ -41,52 +41,64 @@ public final class ConstantBindingBuilderImpl<T>
|
||||
super(binder, elements, source, (Key<T>) NULL_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantBindingBuilder annotatedWith(Class<? extends Annotation> annotationType) {
|
||||
annotatedWithInternal(annotationType);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstantBindingBuilder annotatedWith(Annotation annotation) {
|
||||
annotatedWithInternal(annotation);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void to(final String value) {
|
||||
toConstant(String.class, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void to(final int value) {
|
||||
toConstant(Integer.class, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void to(final long value) {
|
||||
toConstant(Long.class, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void to(final boolean value) {
|
||||
toConstant(Boolean.class, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void to(final double value) {
|
||||
toConstant(Double.class, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void to(final float value) {
|
||||
toConstant(Float.class, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void to(final short value) {
|
||||
toConstant(Short.class, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void to(final char value) {
|
||||
toConstant(Character.class, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void to(final Class<?> value) {
|
||||
toConstant(Class.class, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends Enum<E>> void to(final E value) {
|
||||
toConstant(value.getDeclaringClass(), value);
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ public class ConstructionContext<T> {
|
||||
|
||||
T delegate;
|
||||
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args)
|
||||
throws Throwable {
|
||||
if (delegate == null) {
|
||||
|
@ -441,6 +441,7 @@ public final class Errors implements Serializable {
|
||||
|
||||
List<Message> result = Lists.newArrayList(root.errors);
|
||||
CollectionUtil.timSort(result, new Comparator<Message>() {
|
||||
@Override
|
||||
public int compare(Message a, Message b) {
|
||||
return a.getSource().compareTo(b.getSource());
|
||||
}
|
||||
@ -554,16 +555,19 @@ public final class Errors implements Serializable {
|
||||
|
||||
private static final Collection<Converter<?>> converters = ImmutableList.of(
|
||||
new Converter<Class>(Class.class) {
|
||||
@Override
|
||||
public String toString(Class c) {
|
||||
return c.getName();
|
||||
}
|
||||
},
|
||||
new Converter<Member>(Member.class) {
|
||||
@Override
|
||||
public String toString(Member member) {
|
||||
return MoreTypes.toString(member);
|
||||
}
|
||||
},
|
||||
new Converter<Key>(Key.class) {
|
||||
@Override
|
||||
public String toString(Key key) {
|
||||
if (key.getAnnotationType() != null) {
|
||||
return key.getTypeLiteral() + " annotated with "
|
||||
|
@ -43,22 +43,27 @@ public class ExposedBindingImpl<T> extends BindingImpl<T> implements ExposedBind
|
||||
this.privateElements = privateElements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Dependency<?>> getDependencies() {
|
||||
return ImmutableSet.<Dependency<?>>of(Dependency.get(Key.get(Injector.class)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrivateElements getPrivateElements() {
|
||||
return privateElements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingImpl<T> withScoping(Scoping scoping) {
|
||||
return new ExposedBindingImpl<>(getSource(), getKey(), scoping, privateElements);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExposedBindingImpl<T> withKey(Key<T> key) {
|
||||
return new ExposedBindingImpl<>(getSource(), key, getScoping(), privateElements);
|
||||
}
|
||||
@ -72,6 +77,7 @@ public class ExposedBindingImpl<T> extends BindingImpl<T> implements ExposedBind
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(Binder binder) {
|
||||
throw new UnsupportedOperationException("This element represents a synthetic binding.");
|
||||
}
|
||||
|
@ -42,12 +42,14 @@ public class ExposureBuilder<T> implements AnnotatedElementBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void annotatedWith(Class<? extends Annotation> annotationType) {
|
||||
com.google.common.base.Preconditions.checkNotNull(annotationType, "annotationType");
|
||||
checkNotAnnotated();
|
||||
key = Key.get(key.getTypeLiteral(), annotationType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void annotatedWith(Annotation annotation) {
|
||||
com.google.common.base.Preconditions.checkNotNull(annotation, "annotation");
|
||||
checkNotAnnotated();
|
||||
|
@ -54,32 +54,39 @@ public class InstanceBindingImpl<T> extends BindingImpl<T> implements InstanceBi
|
||||
return this.provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<InjectionPoint> getInjectionPoints() {
|
||||
return injectionPoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Dependency<?>> getDependencies() {
|
||||
return instance instanceof HasDependencies
|
||||
? ImmutableSet.copyOf(((HasDependencies) instance).getDependencies())
|
||||
: Dependency.forInjectionPoints(injectionPoints);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingImpl<T> withScoping(Scoping scoping) {
|
||||
return new InstanceBindingImpl<>(getSource(), getKey(), scoping, injectionPoints, instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingImpl<T> withKey(Key<T> key) {
|
||||
return new InstanceBindingImpl<>(getSource(), key, getScoping(), injectionPoints, instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(Binder binder) {
|
||||
// instance bindings aren't scoped
|
||||
binder.withSource(getSource()).bind(getKey()).toInstance(instance);
|
||||
|
@ -38,22 +38,27 @@ public final class LinkedBindingImpl<T> extends BindingImpl<T> implements Linked
|
||||
this.targetKey = targetKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key<? extends T> getLinkedKey() {
|
||||
return targetKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingImpl<T> withScoping(Scoping scoping) {
|
||||
return new LinkedBindingImpl<>(getSource(), getKey(), scoping, targetKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingImpl<T> withKey(Key<T> key) {
|
||||
return new LinkedBindingImpl<>(getSource(), key, getScoping(), targetKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(Binder binder) {
|
||||
getScoping().applyTo(binder.withSource(getSource()).bind(getKey()).to(getLinkedKey()));
|
||||
}
|
||||
|
@ -41,22 +41,27 @@ public final class LinkedProviderBindingImpl<T>
|
||||
this.providerKey = providerKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> V acceptTargetVisitor(BindingTargetVisitor<? super T, V> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key<? extends Provider<? extends T>> getProviderKey() {
|
||||
return providerKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingImpl<T> withScoping(Scoping scoping) {
|
||||
return new LinkedProviderBindingImpl<>(getSource(), getKey(), scoping, providerKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BindingImpl<T> withKey(Key<T> key) {
|
||||
return new LinkedProviderBindingImpl<>(getSource(), key, getScoping(), providerKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTo(Binder binder) {
|
||||
getScoping().applyTo(binder.withSource(getSource())
|
||||
.bind(getKey()).toProvider(getProviderKey()));
|
||||
|
@ -462,18 +462,22 @@ public class MoreTypes {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type[] getActualTypeArguments() {
|
||||
return typeArguments.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getRawType() {
|
||||
return rawType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getOwnerType() {
|
||||
return ownerType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullySpecified() {
|
||||
if (ownerType != null && !MoreTypes.isFullySpecified(ownerType)) {
|
||||
return false;
|
||||
@ -519,10 +523,12 @@ public class MoreTypes {
|
||||
this.componentType = canonicalize(componentType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getGenericComponentType() {
|
||||
return componentType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullySpecified() {
|
||||
return MoreTypes.isFullySpecified(componentType);
|
||||
}
|
||||
@ -574,14 +580,17 @@ public class MoreTypes {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type[] getUpperBounds() {
|
||||
return new Type[]{upperBound};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type[] getLowerBounds() {
|
||||
return lowerBound != null ? new Type[]{lowerBound} : EMPTY_TYPE_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullySpecified() {
|
||||
return MoreTypes.isFullySpecified(upperBound)
|
||||
&& (lowerBound == null || MoreTypes.isFullySpecified(lowerBound));
|
||||
@ -633,18 +642,22 @@ public class MoreTypes {
|
||||
this.memberKey = memberKey(member);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getDeclaringClass() {
|
||||
return declaringClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getModifiers() {
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSynthetic() {
|
||||
return synthetic;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user