https://github.com/making/csng
CSNG is an annotation processor that simply generates property names as constants.
https://github.com/making/csng
Last synced: 12 months ago
JSON representation
CSNG is an annotation processor that simply generates property names as constants.
- Host: GitHub
- URL: https://github.com/making/csng
- Owner: making
- License: apache-2.0
- Created: 2020-04-05T14:13:39.000Z (about 6 years ago)
- Default Branch: develop
- Last Pushed: 2020-04-06T13:59:37.000Z (about 6 years ago)
- Last Synced: 2025-04-06T07:43:11.524Z (about 1 year ago)
- Language: Java
- Homepage:
- Size: 141 KB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CSNG (Compile Safe Name Generator)
[](https://www.apache.org/licenses/LICENSE-2.0) [](https://maven-badges.herokuapp.com/maven-central/am.ik.csng/csng) [](https://www.javadoc.io/doc/am.ik.csng/csng) [](https://github.com/making/csng/actions)
CSNG is an annotation processor that simply generates property names as constants.
## How to use
For Maven:
```xml
am.ik.csng
csng
0.4.0
true
```
For Gradle:
```
annotationProcessor 'am.ik.csng:csng:0.4.0'
```
## Examples
### Java Beans
```java
package test;
import am.ik.csng.CompileSafeName;
public class CarBean {
@CompileSafeName
private String name;
@CompileSafeName
private int gas;
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public int getGas() {
return this.gas;
}
public void setGas(int gas) {
this.gas = gas;
}
}
```
generates
```java
package test;
public final class _CarBeanName {
public static final String LOWER_CAMEL = "carBean";
public static final String UPPER_CAMEL = "CarBean";
public static final String LOWER_UNDERSCORE = "car_bean";
public static final String UPPER_UNDERSCORE = "CAR_BEAN";
public static final class Name {
public static final String LOWER_CAMEL = "name";
public static final String UPPER_CAMEL = "Name";
public static final String LOWER_UNDERSCORE = "name";
public static final String UPPER_UNDERSCORE = "NAME";
}
public static final class Gas {
public static final String LOWER_CAMEL = "gas";
public static final String UPPER_CAMEL = "Gas";
public static final String LOWER_UNDERSCORE = "gas";
public static final String UPPER_UNDERSCORE = "GAS";
}
}
```
### Constructor
```java
package test;
import am.ik.csng.CompileSafeParameters;
public class Car {
private final String name;
private final int gas;
@CompileSafeParameters
public Car(String name, int gas) {
this.name = name;
this.gas = gas;
}
public String name() {
return this.name;
}
public int gas() {
return this.gas;
}
}
```
generates
```java
package test;
public final class _CarParameters {
public static final String LOWER_CAMEL = "Car";
public static final String UPPER_CAMEL = "Car";
public static final String LOWER_UNDERSCORE = "Car";
public static final String UPPER_UNDERSCORE = "Car";
public static final class Name {
public static final String LOWER_CAMEL = "name";
public static final String UPPER_CAMEL = "Name";
public static final String LOWER_UNDERSCORE = "name";
public static final String UPPER_UNDERSCORE = "NAME";
}
public static final class Gas {
public static final String LOWER_CAMEL = "gas";
public static final String UPPER_CAMEL = "Gas";
public static final String LOWER_UNDERSCORE = "gas";
public static final String UPPER_UNDERSCORE = "GAS";
}
}
```
## Required
* Java 8+
## License
Licensed under the Apache License, Version 2.0.