class TrieBasedPolicyEnforcer implements Enforcer {

    @Override
    public JsonObject buildJsonView(final ResourceKey resourceKey,
            final Iterable<JsonField> jsonFields,
            final AuthorizationContext authorizationContext,
            final Permissions permissions) {

        checkResourceKey(resourceKey);
        checkNotNull(jsonFields, "JSON fields");
        checkPermissions(permissions);

        final JsonKey typeKey = JsonKey.of(resourceKey.getResourceType());

        if (inheritedTrie.hasChild(typeKey)) {
            final PolicyTrie start = inheritedTrie.seekToLeastAncestor(PolicyTrie.getJsonKeyIterator(resourceKey));
            return start.buildJsonView(jsonFields, authorizationContext.getAuthorizationSubjectIds(), permissions);
        } else {
            return JsonFactory.newObject();
        }
    }

    private  TrieBasedPolicyEnforcer(final Iterable<PolicyEntry> policy);

}