@Override
    public boolean hasLink(String name1, String name2, String... domain) {
        if(super.hasLink(name1, name2, domain)) {
            return true;
        }
        // check name1's groups
        if (domain.length == 1) {
            try {
                List<String> groups = Optional.ofNullable(super.getRoles(name1)).orElse(new ArrayList<>());
                for(String group : groups) {
                    if(hasLink(group, name2, domain)) {
                        return true;
                    }
                }
            } catch (Error e) {
                return false;
            }
        }
        return false;
    }
@ Override public boolean hasLink ( String name1 , String name2 , String ... domain ) { if ( super . hasLink ( name1 , name2 , domain ) ) { return true ; } if ( domain . length == 1 ) { try { List < String > groups = Optional . ofNullable ( super . getRoles ( name1 ) ) . orElse ( new ArrayList < > ( ) ) ; for ( String group : groups ) { if ( hasLink ( group , name2 , domain ) ) { return true ; } } } catch ( Error e ) { return false ; } } return false ; }
hasLink determines whether role: name1 inherits role: name2.
domain is a prefix to the roles.