core/src/main/java/org/springframework/security/access/hierarchicalroles/RoleHierarchyImpl.java
private void buildRolesReachableInOneStepMap() {
		this.rolesReachableInOneStepMap = new HashMap<GrantedAuthority, Set<GrantedAuthority>>();
		try (BufferedReader bufferedReader = new BufferedReader(
				new StringReader(this.roleHierarchyStringRepresentation))) {
			for (String readLine; (readLine = bufferedReader.readLine()) != null;) {
				String[] roles = readLine.split(" > ");
				for (int i = 1; i < roles.length; i++) {
					GrantedAuthority higherRole = new SimpleGrantedAuthority(
							roles[i - 1].replaceAll("^\\s+|\\s+$", ""));
					GrantedAuthority lowerRole = new SimpleGrantedAuthority(roles[i].replaceAll("^\\s+|\\s+$", ""));
					Set<GrantedAuthority> rolesReachableInOneStepSet;
					if (!this.rolesReachableInOneStepMap.containsKey(higherRole)) {
						rolesReachableInOneStepSet = new HashSet<GrantedAuthority>();
						this.rolesReachableInOneStepMap.put(higherRole, rolesReachableInOneStepSet);
					} else {
						rolesReachableInOneStepSet = this.rolesReachableInOneStepMap.get(higherRole);
					}
					addReachableRoles(rolesReachableInOneStepSet, lowerRole);
					if (logger.isDebugEnabled()) {
						logger.debug("buildRolesReachableInOneStepMap() - From role " + higherRole
								+ " one can reach role " + lowerRole + " in one step.");
					}
				}
			}
		} catch (IOException e) {
			throw new IllegalStateException(e);
		}
	}
private void buildRolesReachableInOneStepMap() {
		this.rolesReachableInOneStepMap = new HashMap<GrantedAuthority, Set<GrantedAuthority>>();
		try (BufferedReader bufferedReader = new BufferedReader(
				new StringReader(this.roleHierarchyStringRepresentation))) {
			for (String readLine; (readLine = bufferedReader.readLine()) != null;) {
				String[] roles = readLine.split(" > ");
				for (int i = 1; i < roles.length; i++) {
					GrantedAuthority higherRole = new SimpleGrantedAuthority(
							roles[i - 1].replaceAll("^\\s+|\\s+$", ""));
					GrantedAuthority lowerRole = new SimpleGrantedAuthority(roles[i].replaceAll("^\\s+|\\s+$", ""));
					Set<GrantedAuthority> rolesReachableInOneStepSet;
					if (!this.rolesReachableInOneStepMap.containsKey(higherRole)) {
						rolesReachableInOneStepSet = new HashSet<GrantedAuthority>();
						this.rolesReachableInOneStepMap.put(higherRole, rolesReachableInOneStepSet);
					} else {
						rolesReachableInOneStepSet = this.rolesReachableInOneStepMap.get(higherRole);
					}
					addReachableRoles(rolesReachableInOneStepSet, lowerRole);
					if (logger.isDebugEnabled()) {
						logger.debug("buildRolesReachableInOneStepMap() - From role " + higherRole
								+ " one can reach role " + lowerRole + " in one step.");
					}
				}
			}
		} catch (IOException e) {
			throw new IllegalStateException(e);
		}
	}
Parse input and build the map for the roles reachable in one step: the higher role
will become a key that references a set of the reachable lower roles.