org.atinject.tck.auto.accessories.SpareTire Maven / Gradle / Ivy
/*
* Copyright (C) 2009 The JSR-330 Expert Group
*
* 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 org.atinject.tck.auto.accessories;
import org.atinject.tck.auto.FuelTank;
import org.atinject.tck.auto.Tire;
import javax.inject.Inject;
public class SpareTire extends Tire {
FuelTank constructorInjection = NEVER_INJECTED;
@Inject FuelTank fieldInjection = NEVER_INJECTED;
FuelTank methodInjection = NEVER_INJECTED;
@Inject static FuelTank staticFieldInjection = NEVER_INJECTED;
static FuelTank staticMethodInjection = NEVER_INJECTED;
@Inject public SpareTire(FuelTank forSupertype, FuelTank forSubtype) {
super(forSupertype);
this.constructorInjection = forSubtype;
}
@Inject void subtypeMethodInjection(FuelTank methodInjection) {
if (!hasSpareTireBeenFieldInjected()) {
methodInjectedBeforeFields = true;
}
this.methodInjection = methodInjection;
}
@Inject static void subtypeStaticMethodInjection(FuelTank methodInjection) {
if (!hasBeenStaticFieldInjected()) {
staticMethodInjectedBeforeStaticFields = true;
}
staticMethodInjection = methodInjection;
}
@Inject private void injectPrivateMethod() {
if (subPrivateMethodInjected) {
similarPrivateMethodInjectedTwice = true;
}
subPrivateMethodInjected = true;
}
@Inject void injectPackagePrivateMethod() {
if (subPackagePrivateMethodInjected) {
similarPackagePrivateMethodInjectedTwice = true;
}
subPackagePrivateMethodInjected = true;
}
@Inject protected void injectProtectedMethod() {
if (subProtectedMethodInjected) {
overriddenProtectedMethodInjectedTwice = true;
}
subProtectedMethodInjected = true;
}
@Inject public void injectPublicMethod() {
if (subPublicMethodInjected) {
overriddenPublicMethodInjectedTwice = true;
}
subPublicMethodInjected = true;
}
private void injectPrivateMethodForOverride() {
superPrivateMethodForOverrideInjected = true;
}
void injectPackagePrivateMethodForOverride() {
superPackagePrivateMethodForOverrideInjected = true;
}
protected void injectProtectedMethodForOverride() {
protectedMethodForOverrideInjected = true;
}
public void injectPublicMethodForOverride() {
publicMethodForOverrideInjected = true;
}
public boolean hasSpareTireBeenFieldInjected() {
return fieldInjection != NEVER_INJECTED;
}
public boolean hasSpareTireBeenMethodInjected() {
return methodInjection != NEVER_INJECTED;
}
public static boolean hasBeenStaticFieldInjected() {
return staticFieldInjection != NEVER_INJECTED;
}
public static boolean hasBeenStaticMethodInjected() {
return staticMethodInjection != NEVER_INJECTED;
}
public boolean packagePrivateMethod2Injected;
@Inject void injectPackagePrivateMethod2() {
packagePrivateMethod2Injected = true;
}
public boolean packagePrivateMethod3Injected;
void injectPackagePrivateMethod3() {
packagePrivateMethod3Injected = true;
}
}