Code Monkey home page Code Monkey logo

tcmj-pug-enums's People

Contributors

tcmj avatar

Stargazers

 avatar

Watchers

 avatar

tcmj-pug-enums's Issues

[maven-plugin] New Property to change ClassBuilder (java source code generator)

before

  • atm we use the java poet source code builder which is one of three possibilites

after

  • we have a optional configuration property to set one of
    • com.tcmj.pug.enums.builder.impl.JavaPoetEnumBuilder
    • com.tcmj.pug.enums.builder.impl.CodeModelEnumBuilder
    • com.tcmj.pug.enums.builder.impl.StringBufferEnumBuilder (own implementation)

further implementation details

  • value should be the full class ref (like above)
  • this should leave a possibility to implement a custom ClassBuilder which could be added as further dependency on the maven plugin

thougths

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 .

use cases

  • switch between existing implementations
  • implement your very own one (testcase: try to extend one and e.g. add a custom getVersion method)

ClassBuilder should integrate better with EnumData from DataProvider

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.

Cosmetic: Change system parameter names

description:

variable names start with tcmj.iso.generate.enum and should start with tcmj.pug.enums

usecases:

  1. readability/cosmetics
  2. uniqueness

implementation hints:

affects all maven plugin parameter names if specified by system parameters

Maven plugin does not work without subfields

description:

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)

what should happen instead:

execution without error

MetaDataExtractor.getClassNameSimple does not work

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();
  }
  • extend unit tests and fix this snippet using some kind of regex

Feature: Override Subfield Names

description:

add ability to change default behavour of automatic extraction of sub field variable names

usecases:

  1. change variable names for better readability/understanding of purpose
  2. invalid characters/additions (eg. additional text in parentheses)
  3. wrong column header labels
  4. missing column headers

implementation hints:

add maven plugin parameter to add custom column field names used for the subfields
EnumModel#setFieldNames(String[])

[maven-plugin] Prefix to use number based columns as enum constants

description

a enum value has to begin with a alphanumeric value and not a number
we need a prefix option

example

|0100|foo|
|0200|bar|

what we need

  • we could simply use a naming strategy with a fixed prefix like NO_
  • we could add a new config property to prefix the constants
  • ...

usecases

  • overcome the restriction of: numbers are not allowed as java enum constants
  • use numerics as constants like country code, field numbers, and so on

Fix File Encoding Issues when writing java files

  • clean utf-8 support and
  • ability to change the encoding
  • due to platform needs

-default to utf-8
-ability to change it with the standard maven property ?
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

Value Extraction in URLHtmlDataProvider fits not every use case

*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

NamingStrategyConversions

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

Subcolumns must be ordered

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)```

[maven-plugin] New goal to verify / check for changes

description

  • another maven goal enum:verify to check for updates
  • should offer several options
  • strict-mode which creates a new enum and applies a diff to detect changes
  • Notification only mode about possible changes
  • here we also need the common option to fail the build (this is another issue)
  • light-mode if amount of constants changes (more/less)
  • also option if value changes (subcolumns / constants)

use case

  • detect changes without changing a preexisting enum
  • see above options

development details

  • maybe a MD5 hash which can be generated and put into an additional config property
  • maybe we can use a serialVerisionUUID to do the diff
  • or store these diff data in a further file?

Refactor ExportOptions

Implementation 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

Skip specific records

description:

add ability to remove some records of the input data

usecases:

  1. unwanted entries
  2. sum rows, totals, grouping bands

implementation hints:

this can be implemented by defining the value of the constant column
or we can use line numbers ?

[maven-plugin] Missing parameters 'encoding'

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

JDBCDataProvider

description:

Add a new dataprovider to connect to a jdbc database for data exctraction

usecases:

  1. use tabledata for enum creation
  2. just an additional dataprovider

implementation hints:

Parameter: SQL

NamingStrategy is not implemented correctly

*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 ?

Ability to define javadoc on class level in maven-plugin

description:

add ability to define javadoc description per configuration in the maven plugin

usecases:

  1. define description
  2. define location

implementation hints:

add maven plugin parameter and use already available functionality in class EnumModel

Do not override existing files (Option)

FEATURE REQUEST ๐Ÿ˜

  • for the maven plugin
  • for the programming library

Common Description

  • Files should not been overridden
  • instead someone should use the maven clean plugin to delete the generate source folder

Use Cases

  • this is a common behavour - nothing should been overriden
  • you can make changes and they do not get lost
  • we can use also use a option to control this feature

Refactor: CleanUp Fluent API Spaghetti Code

description:

Fluent API seems to be quite a mess and should be refactored

usecases:

  1. cleaner code
  2. less implementation logic

implementation hints:

split up to have one fluent builder for each module
use them all at one parent builder

[maven-plugin] Option to fail the build or not

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

DataProvider should not define class name and package

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

Order of subdata columns doesn't affect enum

BUG Report

Error Description

if you define subdata columns for your enum the ordering gets lost

also see issue #15

Expectation / How should it work

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

maven-plugin configuration / source code snippet

   <subDataColumns>
      <column>2</column>
      <column>1</column>
      <column>3</column>
   </subDataColumns>

Environment

๐Ÿ”˜ Java Version **Oracle JDK v 1.8 **
๐Ÿ”˜ Maven Version 3.3.3
๐Ÿ”˜ pug-enums Version 1.3.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.