class AbstractLocation implements Location {

    @Override
    public boolean hasName(String name, Set<Language> languages) {
        Validate.notNull(name, "name must not be null");
        Validate.notNull(languages, "languages must not be null");
        if (equalName(getPrimaryName(), name)) {
            return true;
        }
        for (AlternativeName alternativeName : getAlternativeNames()) {
            String currentName = alternativeName.getName();
            Language currentLang = alternativeName.getLanguage();
            if (equalName(currentName, name) && (currentLang == null || languages.contains(currentLang))) {
                return true;
            }
        }
        return false;
    }

}