Kind (String name) { for (Kind kind : ourAvailableKinds) { if (kind != Kind.OTHER && name.regionMatches(true, name.length() - kind.extension.length(), kind.extension, 0, kind.extension.length())) { return kind; } } return Kind.OTHER; }