Package ej.property

Class PropertyPermission

    • Constructor Detail

      • PropertyPermission

        public PropertyPermission​(String parentName,
                                  String key,
                                  String action)
        Creates a permission for the given property.

        The action can be one of GET_ACTION, SET_ACTION or REMOVE_ACTION.

        Parameters:
        parentName - the name of the service loader or service registry.
        key - the property key.
        action - the action realized with the service.
    • Method Detail

      • getActions

        public String getActions()
        Description copied from class: Permission
        Returns the actions as a String. This is abstract so subclasses can defer creating a String representation until one is needed. Subclasses should always return actions in what they consider to be their canonical form. For example, two FilePermission objects created via the following:
         perm1 = new FilePermission(p1, "read,write");
         perm2 = new FilePermission(p2, "write,read");
         
        both return "read,write" when the getActions method is invoked.
        Specified by:
        getActions in class Permission
        Returns:
        the actions of this Permission.
      • getKey

        public String getKey()
        Gets the property key handled by this permission.
        Returns:
        the property key.
      • equals

        public boolean equals​(@Nullable
                              Object obj)
        Description copied from class: Permission
        Checks two Permission objects for equality.

        Do not use the equals method for making access control decisions; use the implies method.

        Specified by:
        equals in class Permission
        Parameters:
        obj - the object we are testing for equality with this object.
        Returns:
        true if both Permission objects are equivalent.
        See Also:
        Object.hashCode(), HashMap
      • hashCode

        public int hashCode()
        Description copied from class: Permission
        Returns the hash code value for this Permission object.

        The required hashCode behavior for Permission Objects is the following:

        • Whenever it is invoked on the same Permission object more than once during an execution of a Java application, the hashCode method must consistently return the same integer. This integer need not remain consistent from one execution of an application to another execution of the same application.
        • If two Permission objects are equal according to the equals method, then calling the hashCode method on each of the two Permission objects must produce the same integer result.
        Specified by:
        hashCode in class Permission
        Returns:
        a hash code value for this object.
        See Also:
        Object.equals(java.lang.Object), System.identityHashCode(java.lang.Object)
      • implies

        public boolean implies​(@Nullable
                               Permission permission)
        Description copied from class: Permission
        Checks if the specified permission's actions are "implied by" this object's actions.

        This must be implemented by subclasses of Permission, as they are the only ones that can impose semantics on a Permission object.

        Specified by:
        implies in class Permission
        Parameters:
        permission - the permission to check against.
        Returns:
        true if the specified permission is implied by this object, false if not.