All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dagger.internal.MembersInjectors Maven / Gradle / Ivy

There is a newer version: 2.52
Show newest version
/*
 * Copyright (C) 2014 The Dagger Authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package dagger.internal;

import static dagger.internal.Preconditions.checkNotNull;

import dagger.MembersInjector;
import javax.inject.Inject;

/**
 * Basic {@link MembersInjector} implementations used by the framework.
 */
public final class MembersInjectors {
  /**
   * Returns a {@link MembersInjector} implementation that injects no members
   *
   * 

Note that there is no verification that the type being injected does not have {@link Inject} * members, so care should be taken to ensure appropriate use. */ @SuppressWarnings("unchecked") public static MembersInjector noOp() { return (MembersInjector) NoOpMembersInjector.INSTANCE; } private static enum NoOpMembersInjector implements MembersInjector { INSTANCE; @Override public void injectMembers(Object instance) { checkNotNull(instance, "Cannot inject members into a null reference"); } } private MembersInjectors() {} }