tcmj / tcmj-pug-enums Goto Github PK
View Code? Open in Web Editor NEWMaven Plugin and Java Framework to create java enum classes from html tables and other sources.
Maven Plugin and Java Framework to create java enum classes from html tables and other sources.
initially i thought it could be done via dependency exclusion
but this feature is allready a improvement request to maven
it seems that you can only exclude transitive dependencies but not direct dependencies .
After loading Data into EnumData object using a Dataprovider you have to copy all fields step by step into the ClassBuilder object.
It would be better to provide a way to set a EnumData object initially.
At the moment each ClassBuilder declares its own new EnumData object.
variable names start with tcmj.iso.generate.enum
and should start with tcmj.pug.enums
affects all maven plugin parameter names if specified by system parameters
Exception when you don't define any subfields
java.lang.NullPointerException: NameTypeValue.Value at java.util.Objects.requireNonNull(Objects.java:228) at com.tcmj.pug.enums.api.Fluent.lambda$chain$0(Fluent.java:275) at java.lang.Iterable.forEach(Iterable.java:75) at com.tcmj.pug.enums.api.Fluent.chain(Fluent.java:273) at com.tcmj.pug.enums.api.Fluent.access$800(Fluent.java:16) at com.tcmj.pug.enums.api.Fluent$MyStepFormatterOption.end(Fluent.java:91)
execution without error
See: Commit-Label-23423
ba464c8
atm there is a very bad quick fix
public static String getClassNameSimple(String source) {
String a = getClassNameSimple0(source);
if (a != null && a.indexOf(" ") != -1) {
a = getClassNameSimple1(source);
}
return a.trim();
}
*to fine tune enum data creation
add ability to change default behavour of automatic extraction of sub field variable names
add maven plugin parameter to add custom column field names used for the subfields
EnumModel#setFieldNames(String[])
a enum value has to begin with a alphanumeric value and not a number
we need a prefix option
|0100|foo|
|0200|bar|
NO_
-default to utf-8
-ability to change it with the standard maven property ?
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
*CodePointer: com.tcmj.pug.enums.datasources.impl.URLHtmlDataProvider#getValue
What
*It is merely not possible to cover all cases to extract values of a html data table cell.
*Html is a bad player because of its many ways you can format data
Solution
*We can give the opertunity to define some regex rules like NamingStrategyPatterns
*Or afterward replacement for this cases which results in the same
Examples:
constantName from='Bolivia (Plurinational State of)' to='Boliviaplurinationalstateof'
constantName from='Bonaire, Sint Eustatius and Saba' to='Bonairesinteustatiusandsaba'
constantName from='Bosnia and Herzegovina' to='Bosniaandherzegovina'
.harmonize must not remove the space character <- this is needed to chain another NS
if you define subcolumns the order bust be sorted
eg. 3,4,5 works
4,5,3 does not work
at com.tcmj.pug.enums.builder.impl.JavaPoetEnumBuilder.build(JavaPoetEnumBuilder.java:80)
at com.tcmj.pug.enums.api.fluent.Fluent.build(Fluent.java:151)
at com.tcmj.pug.enums.example.fluent.WikipediaExample3.main(WikipediaExample3.java:28)
Caused by: java.lang.IllegalArgumentException: unused arguments: expected 2, received 3
at com.squareup.javapoet.Util.checkArgument(Util.java:64)
at com.squareup.javapoet.CodeBlock$Builder.add(CodeBlock.java:243)
at com.squareup.javapoet.TypeSpec.anonymousClassBuilder(TypeSpec.java:115)
at com.tcmj.pug.enums.builder.impl.JavaPoetEnumBuilder.writeEnumConstants(JavaPoetEnumBuilder.java:156)
at com.tcmj.pug.enums.builder.impl.JavaPoetEnumBuilder.build(JavaPoetEnumBuilder.java:45)```
enum:verify
to check for updatesImplementation of ExportOptions is very bad
Thought it would work but it didn't very well
Need another Pattern to handle this
Usually we need various Options for various exporters
FileExporter:
Needs PrefixPath + Packages converted to directories + ClassName + .java
...to be continued
add ability to remove some records of the input data
this can be implemented by defining the value of the constant column
or we can use line numbers ?
The encoding parameter of the maven plugin has been implemented as mandatory instead of optional.
[ERROR] Failed to execute goal com.tcmj.plugins:pug-enum-maven-plugin:1.3.3:generate-enum (my-country-enum) on project pug-enum-examples-no2: The parameters 'encoding' for goal com.tcmj.plugins:pug-enum-maven-plugin:1.3.3:generate-enum are missing or invalid -> [Help 1]
a workaround would be to define the property
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
As by design there should be a warning which says that the build is platform dependent therefore
the fallback is using the system encoding
Version: 1.3.3
Add a new dataprovider to connect to a jdbc database for data exctraction
Parameter: SQL
*it should be used to apply changes for constant names (eg toUpperCase)
*currently used only for PoetJavaEnumBuilder
*but not for all others
*think of changing the data map in EnumData. Currently the key will be used for the constant name
*maybe adding a String to NameTypeValue ?
add ability to define javadoc description per configuration in the maven plugin
add maven plugin parameter and use already available functionality in class EnumModel
There is a nice way to test your maven plugin
http://maven.apache.org/plugin-testing/maven-plugin-testing-harness/getting-started/index.html
Fluent API seems to be quite a mess and should be refactored
split up to have one fluent builder for each module
use them all at one parent builder
atm all subfields get String as datatype
we should implement a property
<fieldClasses>
<value>Integer</value>
<value>Double</value>
</fieldClasses>
implement a failOnError property for the maven goal
use case:
you don't want to fail the build if eg no internet connection is available
and:
the default value should be set to true
developer feedback:
if the execute method in the mojo throws a exception the build will fail.
in the catch block you can decide to rethrow or not depending on the new property
I think it should not be part of the dataprovider to define java class name and package.
try to leave it empty
it should be set on the classbuilder instead!
A DataProvider should only load raw data - possibly use a namingstrategy to achive it
if you define subdata columns for your enum the ordering gets lost
also see issue #15
eg. i want a enum with subs of column 3,8,2,4 and i will get 2,3,4,8
the ordering should be preserved
<subDataColumns>
<column>2</column>
<column>1</column>
<column>3</column>
</subDataColumns>
๐ | Java Version | **Oracle JDK v 1.8 ** |
---|---|---|
๐ | Maven Version | 3.3.3 |
๐ | pug-enums Version | 1.3.4 |
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.