Class ReservedWordSymbolProvider.Builder

    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • build

        public SymbolProvider build()
        Builds a SymbolProvider implementation that wraps another symbol provider and escapes its results.

        This might not always be the right solution. For example, symbol providers often need to recursively resolve symbols to create shapes like arrays and maps. In these cases, delegating would be awkward or impossible since the symbol provider being wrapped would also need access to the wrapper. In cases like this, use buildEscaper() and pass that into the SymbolProvider directly.

        Returns:
        Returns the built SymbolProvider that delegates to another.
      • buildEscaper

        public ReservedWordSymbolProvider.Escaper buildEscaper()
        Builds a SymbolProvider.Escaper that is used to manually escape Symbols and member names.
        Returns:
        Returns the built escaper.
      • symbolProvider

        public ReservedWordSymbolProvider.Builder symbolProvider​(SymbolProvider delegate)
        Sets the delegate symbol provider.

        This is only required when calling build() to build a SymbolProvider that delegates to another provider.

        Parameters:
        delegate - Symbol provider to delegate to.
        Returns:
        Returns the builder
      • filenameReservedWords

        public ReservedWordSymbolProvider.Builder filenameReservedWords​(ReservedWords filenameReservedWords)
        Sets the reserved word implementation for file names.

        If not provided, file names are not passed through a reserved words implementation after calling the delegate.

        Parameters:
        filenameReservedWords - Reserved word implementation for namespaces.
        Returns:
        Returns the builder.
      • namespaceReservedWords

        public ReservedWordSymbolProvider.Builder namespaceReservedWords​(ReservedWords namespaceReservedWords)
        Sets the reserved word implementation for namespace names.

        If not provided, namespace names are not passed through a reserved words implementation after calling the delegate.

        Parameters:
        namespaceReservedWords - Reserved word implementation for namespaces.
        Returns:
        Returns the builder.
      • nameReservedWords

        public ReservedWordSymbolProvider.Builder nameReservedWords​(ReservedWords nameReservedWords)
        Sets the reserved word implementation for names (structures names, class names, etc.).

        If not provided, names are not passed through a reserved words implementation after calling the delegate.

        Parameters:
        nameReservedWords - Reserved word implementation for containers.
        Returns:
        Returns the builder.
      • memberReservedWords

        public ReservedWordSymbolProvider.Builder memberReservedWords​(ReservedWords memberReservedWords)
        Sets the reserved word implementation for members.

        If not provided, member names are not passed through a reserved words implementation after calling the delegate.

        Parameters:
        memberReservedWords - Reserved word implementation for members.
        Returns:
        Returns the builder.
      • escapePredicate

        public ReservedWordSymbolProvider.Builder escapePredicate​(java.util.function.BiPredicate<Shape,​Symbol> escapePredicate)
        Sets a predicate that is used to control when a shape + symbol combination should be checked if it's a reserved word.

        The predicate is invoked when toSymbol is called. It is used to disable/enable escaping reserved words based on the shape and symbol. The given predicate accepts the Shape and the Symbol that was created for the shape and returns true if reserved word checks should be made or false if reserved word checks should not be made. For example, some code generators only escape words that have namespaces to differentiate between language built-ins and user-defined types.

        By default, all symbols are checked for reserved words.

        Parameters:
        escapePredicate - Predicate that returns true if escaping should be checked.
        Returns:
        Returns the builder.