class CreateRrdOperations {

    public List<Operation> create(LookupContext context, boolean recursive, boolean optional) {
        LookupResult lookupResult = context.lookupResult;
        List<Operation> operations = new ArrayList<>();
        lookupResult.templates().stream()
                .filter(template -> optional == template.isOptional())
                .forEach(template -> {
                    int missingMetadata = lookupResult.missingMetadata(template);
                    if (missingMetadata != ALL_PRESENT) {

                        ResourceAddress address;
                        Operation.Builder builder = null;

                        if (missingMetadata == NOTHING_PRESENT) {
                            address = template.resolve(securityContextStatementContext);
                            builder = new Operation.Builder(address, READ_RESOURCE_DESCRIPTION_OPERATION)
                                    .param(ACCESS_CONTROL, COMBINED_DESCRIPTIONS)
                                    .param(OPERATIONS, true);

                        } else if (missingMetadata == RESOURCE_DESCRIPTION_PRESENT) {
                            address = template.resolve(securityContextStatementContext);
                            builder = new Operation.Builder(address, READ_RESOURCE_DESCRIPTION_OPERATION)
                                    .param(ACCESS_CONTROL, TRIM_DESCRIPTIONS)
                                    .param(OPERATIONS, true);

                        } else if (missingMetadata == SECURITY_CONTEXT_PRESENT) {
                            address = template.resolve(resourceDescriptionStatementContext);
                            builder = new Operation.Builder(address, READ_RESOURCE_DESCRIPTION_OPERATION)
                                    .param(OPERATIONS, true);
                        }

                        if (builder != null) {
                            if (recursive) {
                                builder.param(RECURSIVE_DEPTH, depth);
                            }
                            builder.param(LOCALE, locale);
                            operations.add(builder.build());
                        }
                    }
                });
        return operations;
    }

      CreateRrdOperations(Environment environment, StatementContext statementContext, String locale, int depth);

}