@Override public boolean isAbstract() { return Modifier.isAbstract(this.introspectedMethod.getModifiers()); }
@Override public boolean isAbstract() { return Modifier.isAbstract(this.introspectedClass.getModifiers()); }
/** Determines if the supplied Class object represents an abstract type. */ static public boolean isAbstract (Class c) { return Modifier.isAbstract(c.getModifiers()); }
/** Determines if the supplied Class object represents an abstract type. */ static public boolean isAbstract (Class c) { return Modifier.isAbstract(c.getModifiers()); }
/** Return true if the method includes the {@code abstract} modifier. */ public boolean isAbstract () { return Modifier.isAbstract(method.getModifiers()); }
/** Return true if the method includes the {@code abstract} modifier. */ public boolean isAbstract () { return Modifier.isAbstract(method.getModifiers()); }
public ReflectiveElementFactory(Class<? extends E> elementClass) { Assert.notNull(elementClass, "Element class must not be null"); Assert.isTrue(!elementClass.isInterface(), "Element class must not be an interface type"); Assert.isTrue(!Modifier.isAbstract(elementClass.getModifiers()), "Element class cannot be an abstract class"); this.elementClass = elementClass; }
private static boolean typeIsPrivateAbstractInnerClass(Class<?> type, int modifiers) { return Modifier.isPrivate(modifiers) && Modifier.isAbstract(modifiers) && type.getEnclosingClass() != null; }
@Nullable private static List<Method> findConcreteMethodsOnInterfaces(Class<?> clazz) { List<Method> result = null; for (Class<?> ifc : clazz.getInterfaces()) { for (Method ifcMethod : ifc.getMethods()) { if (!Modifier.isAbstract(ifcMethod.getModifiers())) { if (result == null) { result = new ArrayList<>(); } result.add(ifcMethod); } } } return result; }
/** Returns true if the method is abstract. */ public final boolean isAbstract() { return Modifier.isAbstract(getModifiers()); }
private boolean canCreateCopy(Class<?> requiredType) { return (!requiredType.isInterface() && !Modifier.isAbstract(requiredType.getModifiers()) && Modifier.isPublic(requiredType.getModifiers()) && ClassUtils.hasConstructor(requiredType)); }
@SuppressWarnings("unchecked") private static Collection<Object> createCollection(Class<?> type, int len) { if (type.isAssignableFrom(ArrayList.class)) { return new ArrayList<Object>(len); } if (type.isAssignableFrom(HashSet.class)) { return new HashSet<Object>(len); } if (!type.isInterface() && !Modifier.isAbstract(type.getModifiers())) { try { return (Collection<Object>) type.newInstance(); } catch (Exception e) { // ignore } } return new ArrayList<Object>(); }
@SuppressWarnings("unchecked") private static Collection<Object> createCollection(Class<?> type, int len) { if (type.isAssignableFrom(ArrayList.class)) { return new ArrayList<Object>(len); } if (type.isAssignableFrom(HashSet.class)) { return new HashSet<Object>(len); } if (!type.isInterface() && !Modifier.isAbstract(type.getModifiers())) { try { return (Collection<Object>) type.newInstance(); } catch (Exception e) { // ignore } } return new ArrayList<Object>(); }
private static Class<?>[] filterAbstractClasses(final Class<?>[] classes) { final List<Class<?>> filteredList= new ArrayList<Class<?>>(classes.length); for (final Class<?> clazz : classes) { if (!Modifier.isAbstract(clazz.getModifiers())) { filteredList.add(clazz); } } return filteredList.toArray(new Class<?>[filteredList.size()]); } }
private void checkNotAbstract(Field field) { if(Modifier.isAbstract(field.getType().getModifiers())) { throw new MockitoException("the type '" + field.getType().getSimpleName() + "' is an abstract class."); } }
/** * Match the specified method by {@link Method} reference or method name. * <p>For backwards compatibility reasons, in a scenario with overloaded * non-abstract methods of the given name, only the no-arg variant of a * method will be turned into a container-driven lookup method. * <p>In case of a provided {@link Method}, only straight matches will * be considered, usually demarcated by the {@code @Lookup} annotation. */ @Override public boolean matches(Method method) { if (this.method != null) { return method.equals(this.method); } else { return (method.getName().equals(getMethodName()) && (!isOverloaded() || Modifier.isAbstract(method.getModifiers()) || method.getParameterCount() == 0)); } }
@Override public <T> Class<? extends T> mockClass(MockFeatures<T> features) { boolean subclassingRequired = !features.interfaces.isEmpty() || features.serializableMode != SerializableMode.NONE || Modifier.isAbstract(features.mockedType.getModifiers()); checkSupportedCombination(subclassingRequired, features); synchronized (this) { triggerRetransformation(features); } return subclassingRequired ? subclassEngine.mockClass(features) : features.mockedType; }
public Object answer(InvocationOnMock invocation) throws Throwable { if (Modifier.isAbstract(invocation.getMethod().getModifiers())) { return RETURNS_DEFAULTS.answer(invocation); } return invocation.callRealMethod(); }
@Override public void validate(Class<?> aspectClass) throws AopConfigException { // If the parent has the annotation and isn't abstract it's an error if (aspectClass.getSuperclass().getAnnotation(Aspect.class) != null && !Modifier.isAbstract(aspectClass.getSuperclass().getModifiers())) { throw new AopConfigException("[" + aspectClass.getName() + "] cannot extend concrete aspect [" + aspectClass.getSuperclass().getName() + "]"); } AjType<?> ajType = AjTypeSystem.getAjType(aspectClass); if (!ajType.isAspect()) { throw new NotAnAtAspectException(aspectClass); } if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOW) { throw new AopConfigException(aspectClass.getName() + " uses percflow instantiation model: " + "This is not supported in Spring AOP."); } if (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOWBELOW) { throw new AopConfigException(aspectClass.getName() + " uses percflowbelow instantiation model: " + "This is not supported in Spring AOP."); } }
void doTestNulls(Class<?> cls, Visibility visibility) throws ParameterNotInstantiableException, IllegalAccessException, InvocationTargetException, FactoryMethodReturnsNullException { if (!Modifier.isAbstract(cls.getModifiers())) { nullPointerTester.testConstructors(cls, visibility); } nullPointerTester.testStaticMethods(cls, visibility); if (hasInstanceMethodToTestNulls(cls, visibility)) { Object instance = instantiate(cls); if (instance != null) { nullPointerTester.testInstanceMethods(instance, visibility); } } }