class PoliciesModelFactory {

    public static ResourceKey newResourceKey(final CharSequence typeWithPath) {
        if (typeWithPath instanceof ResourceKey) {
            return (ResourceKey) typeWithPath;
        }

        argumentNotEmpty(typeWithPath, "typeWithPath");

        final Validator validator = NoControlCharactersValidator.getInstance(typeWithPath);
        if (!validator.isValid()) {
            throw PolicyEntryInvalidException.newBuilder()
                    .message("The Policy Resource " + typeWithPath + " is invalid")
                    .description(validator.getReason().orElse(null))
                    .build();
        }

        final String[] typeWithPathSplit = splitTypeWithPath(typeWithPath.toString());
        return ImmutableResourceKey.newInstance(typeWithPathSplit[0], JsonPointer.of(typeWithPathSplit[1]));
    }

    private  PoliciesModelFactory();

}