private static Optional<String> roleNotAllowedToBePlayed(Role role, Thing thing) {
        TypeImpl<?, ?> currentConcept = (TypeImpl<?, ?>) thing.type();

        boolean satisfiesPlays = false;
        while (currentConcept != null) {
            Map<Role, Boolean> plays = currentConcept.directPlays();

            for (Map.Entry<Role, Boolean> playsEntry : plays.entrySet()) {
                Role rolePlayed = playsEntry.getKey();
                Boolean required = playsEntry.getValue();
                if (rolePlayed.label().equals(role.label())) {
                    satisfiesPlays = true;

                    // Assert unique relation for this role type
                    if (required && !CommonUtil.containsOnly(thing.relations(role), 1)) {
                        return Optional.of(VALIDATION_REQUIRED_RELATION.getMessage(thing.id(), thing.type().label(), role.label(), thing.relations(role).count()));
                    }
                }
            }
            currentConcept = (TypeImpl) currentConcept.sup();
        }

        if (satisfiesPlays) {
            return Optional.empty();
        } else {
            return Optional.of(VALIDATION_CASTING.getMessage(thing.type().label(), thing.id(), role.label()));
        }
    }
private static Optional < String > roleNotAllowedToBePlayed ( Role role , Thing thing ) { TypeImpl < ? , ? > currentConcept = ( TypeImpl < ? , ? > ) thing . type ( ) ; boolean satisfiesPlays = false ; while ( currentConcept != null ) { Map < Role , Boolean > plays = currentConcept . directPlays ( ) ; for ( Map . Entry < Role , Boolean > playsEntry : plays . entrySet ( ) ) { Role rolePlayed = playsEntry . getKey ( ) ; Boolean required = playsEntry . getValue ( ) ; if ( rolePlayed . label ( ) . equals ( role . label ( ) ) ) { satisfiesPlays = true ; if ( required && ! CommonUtil . containsOnly ( thing . relations ( role ) , 1 ) ) { return Optional . of ( VALIDATION_REQUIRED_RELATION . getMessage ( thing . id ( ) , thing . type ( ) . label ( ) , role . label ( ) , thing . relations ( role ) . count ( ) ) ) ; } } } currentConcept = ( TypeImpl ) currentConcept . sup ( ) ; } if ( satisfiesPlays ) { return Optional . empty ( ) ; } else { return Optional . of ( VALIDATION_CASTING . getMessage ( thing . type ( ) . label ( ) , thing . id ( ) , role . label ( ) ) ) ; } }
Checks  if the plays edge has been added between the roleplayer's Type and
the Role being played.
Also checks that required Role are satisfied

@param role  The Role which the role-player is playing
@param thing the role-player
@return an error if one is found