Package randoop.reflection
Class AccessibilityPredicate.PackageAccessibilityPredicate
- java.lang.Object
-
- randoop.reflection.AccessibilityPredicate
-
- randoop.reflection.AccessibilityPredicate.PackageAccessibilityPredicate
-
- Enclosing class:
- AccessibilityPredicate
public static class AccessibilityPredicate.PackageAccessibilityPredicate extends AccessibilityPredicate
A predicate that tests for accessibility of a class, method, constructor, or field relative to a particular package.- A top-level class is accessible from the package if it is public, or if it is package-private in the given package.
- An element is accessible from the package if it is either public, or, if in the same package, then not private.
The predicate is used to determine what can be accessed from a Randoop-generated JUnit test in the given package. So, this class does not implement Java's full accessibility rules; those for subclasses and default-accessibility are not relevant to this predicate.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class randoop.reflection.AccessibilityPredicate
AccessibilityPredicate.PackageAccessibilityPredicate
-
-
Field Summary
Fields Modifier and Type Field Description private String
packageName
The package name from which to test accessibility of elements.-
Fields inherited from class randoop.reflection.AccessibilityPredicate
IS_ANY, IS_NOT_PRIVATE, IS_PUBLIC
-
-
Constructor Summary
Constructors Constructor Description PackageAccessibilityPredicate(String packageName)
Create a predicate that tests accessibility.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
isAccessible(int mods, Package otherPackage)
Test accessibility as indicated by the modifier bit string and/or package.boolean
isAccessible(Class<?> c)
Determines whether this AccessibilityPredicate considers aClass
accessible.boolean
isAccessible(Executable e)
Determines whether this AccessibilityPredicate considers aMethod
orConstructor
accessible.boolean
isAccessible(Field f)
Determines whether this AccessibilityPredicate considers aField
accessible.String
toString()
-
-
-
Field Detail
-
packageName
private final String packageName
The package name from which to test accessibility of elements.
-
-
Constructor Detail
-
PackageAccessibilityPredicate
public PackageAccessibilityPredicate(String packageName)
Create a predicate that tests accessibility. Class members must either be public, or accessible relative to the given packagepackageName
.- Parameters:
packageName
- the package to use for package accessibility test
-
-
Method Detail
-
isAccessible
public boolean isAccessible(Class<?> c)
Determines whether this AccessibilityPredicate considers aClass
accessible.- Specified by:
isAccessible
in classAccessibilityPredicate
- Parameters:
c
- the class object to check- Returns:
- true if class is public or package private in
packageName
, false otherwise
-
isAccessible
public boolean isAccessible(Executable e)
Determines whether this AccessibilityPredicate considers aMethod
orConstructor
accessible. Does not test the accessibility of the containing class.- Specified by:
isAccessible
in classAccessibilityPredicate
- Parameters:
e
- the method/constructor object to check- Returns:
- true if method/constructor is public or a member of a class in
packageName
and not private, false otherwise
-
isAccessible
public boolean isAccessible(Field f)
Determines whether this AccessibilityPredicate considers aField
accessible. Does not test the accessibility of the containing class.- Specified by:
isAccessible
in classAccessibilityPredicate
- Parameters:
f
- the field object to check- Returns:
- true if field is public or member of a class in
packageName
and not private, false otherwise
-
isAccessible
private boolean isAccessible(int mods, Package otherPackage)
Test accessibility as indicated by the modifier bit string and/or package.- Parameters:
mods
- the modifier bit stringotherPackage
- the package to test for relative accessibility- Returns:
- true if public set in modifiers or if otherPackage is the same as packageName and private is not set in modifiers, false otherwise
-
-