Class 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.

    • 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 package packageName.
        Parameters:
        packageName - the package to use for package accessibility test
    • Method Detail

      • isAccessible

        public boolean isAccessible​(Class<?> c)
        Determines whether this AccessibilityPredicate considers a Class accessible.
        Specified by:
        isAccessible in class AccessibilityPredicate
        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 a Method or Constructor accessible. Does not test the accessibility of the containing class.
        Specified by:
        isAccessible in class AccessibilityPredicate
        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 a Field accessible. Does not test the accessibility of the containing class.
        Specified by:
        isAccessible in class AccessibilityPredicate
        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 string
        otherPackage - 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