Skip to content

mP1/walkingkooka-resource-annotation-processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status License Language grade: Java Total alerts J2CL compatible

walkingkooka-resource-annotation-processor

An annotation processor that generates a provider for any class marked with walkingkooka.resource.TextResourceAware. This is particularly useful for any runtime environment such as J2CL where java.lang.Class#getResourceAsStream is not supported but using files as text is still required.

Note it is not currently possible to specify the charset encoding for any text file. Theres is a ticket to add support to specify a Charset and this will require changing using FileObject#openInputStream rather than FileObject#getCharContent.

package sample;

@walkingkooka.resource.TextResourceAware(normalizeSpace = true, fileExtension = ".txt2")
public class TextFile {
  // members not copied to generated class
}

generates...

package sample;

public final class TextFileProvider implements walkingkooka.resource.TextResource {
    
    @Override
    public String text() {
       return "content   of   sample/TextFile.txt2";
    }
}

usage

new TextFileProvider().text(); // returns "content   of   sample/TextFile.txt2"

About

An annotation processor that generates a TextResource implementation for a class marked with @TextResourceAware

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages