Skip to content

Commit

Permalink
Merge pull request #12 from /issues/3
Browse files Browse the repository at this point in the history
Add support for inheritance
Close #3
  • Loading branch information
alexengrig authored Jul 14, 2021
2 parents f73a21b + f2e17e9 commit 990d29b
Show file tree
Hide file tree
Showing 59 changed files with 1,807 additions and 235 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: java
jdk:
- openjdk8
install:
- mvn install -Dgpg.skip=true -B -V
- mvn install -Dgpg.skip=true -Djar.finalName=metter -B -V
- cd demo
- gradle test
- cd ..
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@

Metter (***met***a get***ter*** / set***ter***) is an annotation processor for generating getter and setter suppliers.

Ignores private methods.
- Supports [Lombok](https://github.com/rzwitserloot/lombok) annotations: `@Data`, `@Getter` and `@Setter`.
- Supports inheritance (getters/setters of superclasses).
- Ignores private methods.

Supports [Lombok](https://github.com/rzwitserloot/lombok) annotations: `@Data`, `@Getter` and `@Setter`.
[See](demo) examples.

## Table of Contents

Expand Down Expand Up @@ -400,9 +402,9 @@ The generation solution is faster than the reflection solution (reflection is sl
This project is [licensed](LICENSE) under [Apache License, version 2.0](https://www.apache.org/licenses/LICENSE-2.0).

[JetBrains Mono typeface](https://www.jetbrains.com/lp/mono)
used in [logo](docs/images/metter-logo.png)
and [preview](docs/images/metter-preview.png)
is [licensed](https://www.jetbrains.com/lp/mono/#license)
under [Apache License, version 2.0](https://www.apache.org/licenses/LICENSE-2.0).
under [Apache License, version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
and it used in [logo](docs/images/metter-logo.png)
and [preview](docs/images/metter-preview.png).

[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgit.luolix.top%2Falexengrig%2Fmetter.svg?type=large)](https://app.fossa.com/projects/git%2Bgit.luolix.top%2Falexengrig%2Fmetter?ref=badge_large)
35 changes: 35 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# metter demo

- [Simple domain](src/main/java/dev/alexengrig/metter/demo/simple/SimpleDomain.java)
- [Domain with custom name](src/main/java/dev/alexengrig/metter/demo/naming/NamedDomain.java)
- [Excluding](src/main/java/dev/alexengrig/metter/demo/excluding)
- [Domain with excluded getters/setters](src/main/java/dev/alexengrig/metter/demo/excluding/ExcludedDomain.java)
- [Inherited domain with excluded getters/setters](src/main/java/dev/alexengrig/metter/demo/excluding/InheritedExcludedDomain.java)
- [Including](src/main/java/dev/alexengrig/metter/demo/including)
- [Domain with included getters/setters](src/main/java/dev/alexengrig/metter/demo/including/IncludedDomain.java)
- [Inherited domain with included getters/setters](src/main/java/dev/alexengrig/metter/demo/including/InheritedIncludedDomain.java)
- [Including and excluding](src/main/java/dev/alexengrig/metter/demo/includingandexcluding)
- [Domain with included and excluded getters/setters](src/main/java/dev/alexengrig/metter/demo/includingandexcluding/IncludedAndExcludedDomain.java)
- [Inherited domain with included and excluded getters/setters](src/main/java/dev/alexengrig/metter/demo/includingandexcluding/InheritedIncludedAndExcludedDomain.java)
- [Inheritance](src/main/java/dev/alexengrig/metter/demo/inheritance)
- [Lombok Data annotation](src/main/java/dev/alexengrig/metter/demo/lombokdata)
- [Domain with Lombok Data annotation](src/main/java/dev/alexengrig/metter/demo/lombokdata/LombokDataDomain.java)
- [Inherited domain with Lombok Data annotation](src/main/java/dev/alexengrig/metter/demo/lombokdata/InheritedLombokDataDomain.java)
- [Lombok Getter and Setter annotations on class](src/main/java/dev/alexengrig/metter/demo/lombokgetterandsetter)
- [Domain with Lombok Getter and Setter annotations on class](src/main/java/dev/alexengrig/metter/demo/lombokgetterandsetter/LombokGetterAndSetterDomain.java)
- [Inherited domain with Lombok Getter and Setter annotations on class](src/main/java/dev/alexengrig/metter/demo/lombokgetterandsetter/InheritedLombokGetterAndSetterDomain.java)
- [Lombok Getter and Setter annotations on field](src/main/java/dev/alexengrig/metter/demo/lombokgettersandsetters)
- [Domain with Lombok Getter and Setter annotations on field](src/main/java/dev/alexengrig/metter/demo/lombokgettersandsetters/LombokGettersAndSettersDomain.java)
- [Inherited domain with Lombok Getter and Setter annotations on field](src/main/java/dev/alexengrig/metter/demo/lombokgettersandsetters/InheritedLombokGettersAndSettersDomain.java)
- [Private getters and setters](src/main/java/dev/alexengrig/metter/demo/privategettersandsetters)
- [Domain with private getters and setters](src/main/java/dev/alexengrig/metter/demo/privategettersandsetters/PrivateGettersAndSettersDomain.java)
- [Inherited domain with private getters and setters](src/main/java/dev/alexengrig/metter/demo/privategettersandsetters/InheritedPrivateGettersAndSettersDomain.java)
- [Lombok Getter and Setter annotations on class with private access](src/main/java/dev/alexengrig/metter/demo/privatelombokgetterandsetter)
- [Domain with Lombok Getter and Setter annotations on class with private access](src/main/java/dev/alexengrig/metter/demo/privatelombokgetterandsetter/PrivateLombokGetterAndSetterDomain.java)
- [Inherited domain with Lombok Getter and Setter annotations on class with private access](src/main/java/dev/alexengrig/metter/demo/privatelombokgetterandsetter/InheritedPrivateLombokGetterAndSetterDomain.java)
- [Lombok Getter and Setter annotations on field with private access](src/main/java/dev/alexengrig/metter/demo/privatelombokgettersandsetters)
- [Domain with Lombok Getter and Setter annotations on field with private access](src/main/java/dev/alexengrig/metter/demo/privatelombokgettersandsetters/PrivateLombokGettersAndSettersDomain.java)
- [Inherited domain with Lombok Getter and Setter annotations on field with private access](src/main/java/dev/alexengrig/metter/demo/privatelombokgettersandsetters/InheritedPrivateLombokGettersAndSettersDomain.java)
- [Domain without package](src/main/java/NoPackageDomain.java)

- [Motivation code](src/main/java/dev/alexengrig/metter/motivation)
6 changes: 3 additions & 3 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ plugins {
}

group 'dev.alexengrig'
version '0.1.1'
version '0.2.0-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
compileOnly files('../target/metter-0.2.0-SNAPSHOT.jar')
annotationProcessor files('../target/metter-0.2.0-SNAPSHOT.jar')
compileOnly files('../target/metter.jar')
annotationProcessor files('../target/metter.jar')

compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2020-2021 Alexengrig Dev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.alexengrig.metter.demo.excluding;

import dev.alexengrig.metter.annotation.GetterSupplier;
import dev.alexengrig.metter.annotation.SetterSupplier;

@GetterSupplier(excludedFields = {"excluded", "alsoExcluded"})
@SetterSupplier(excludedFields = {"excluded", "alsoExcluded"})
public class InheritedExcludedDomain extends ExcludedDomain {
private int alsoExcluded;

public InheritedExcludedDomain(int integer, int excluded, int alsoExcluded) {
super(integer, excluded);
this.alsoExcluded = alsoExcluded;
}

public int getAlsoExcluded() {
return alsoExcluded;
}

public void setAlsoExcluded(int alsoExcluded) {
this.alsoExcluded = alsoExcluded;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2020-2021 Alexengrig Dev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.alexengrig.metter.demo.including;

import dev.alexengrig.metter.annotation.GetterSupplier;
import dev.alexengrig.metter.annotation.SetterSupplier;

@GetterSupplier(includedFields = {"included", "alsoIncluded"})
@SetterSupplier(includedFields = {"included", "alsoIncluded"})
public class InheritedIncludedDomain extends IncludedDomain {
private int alsoIncluded;
private int alsoIgnored;

public InheritedIncludedDomain(int included, int ignored, int alsoIncluded, int alsoIgnored) {
super(included, ignored);
this.alsoIncluded = alsoIncluded;
this.alsoIgnored = alsoIgnored;
}

public int getAlsoIncluded() {
return alsoIncluded;
}

public void setAlsoIncluded(int alsoIncluded) {
this.alsoIncluded = alsoIncluded;
}

public int getAlsoIgnored() {
return alsoIgnored;
}

public void setAlsoIgnored(int alsoIgnored) {
this.alsoIgnored = alsoIgnored;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2020-2021 Alexengrig Dev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.alexengrig.metter.demo.includingandexcluding;

import dev.alexengrig.metter.annotation.GetterSupplier;
import dev.alexengrig.metter.annotation.SetterSupplier;

@GetterSupplier(includedFields = {"included", "alsoIncluded"}, excludedFields = {"excluded", "alsoExcluded"})
@SetterSupplier(includedFields = {"included", "alsoIncluded"}, excludedFields = {"excluded", "alsoExcluded"})
public class InheritedIncludedAndExcludedDomain extends IncludedAndExcludedDomain {
private int alsoIncluded;
private int alsoIgnored;
private int alsoExcluded;

public InheritedIncludedAndExcludedDomain(int included, int ignored, int excluded, int alsoIncluded, int alsoIgnored, int alsoExcluded) {
super(included, ignored, excluded);
this.alsoIncluded = alsoIncluded;
this.alsoIgnored = alsoIgnored;
this.alsoExcluded = alsoExcluded;
}

public int getAlsoIncluded() {
return alsoIncluded;
}

public void setAlsoIncluded(int alsoIncluded) {
this.alsoIncluded = alsoIncluded;
}

public int getAlsoIgnored() {
return alsoIgnored;
}

public void setAlsoIgnored(int alsoIgnored) {
this.alsoIgnored = alsoIgnored;
}

public int getAlsoExcluded() {
return alsoExcluded;
}

public void setAlsoExcluded(int alsoExcluded) {
this.alsoExcluded = alsoExcluded;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2020-2021 Alexengrig Dev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.alexengrig.metter.demo.inheritance;

import dev.alexengrig.metter.annotation.GetterSupplier;
import dev.alexengrig.metter.annotation.SetterSupplier;

@GetterSupplier
@SetterSupplier
public class FatherDomain {
private int fatherInt;

public FatherDomain(int fatherInt) {
this.fatherInt = fatherInt;
}

public int getFatherInt() {
return fatherInt;
}

public void setFatherInt(int fatherInt) {
this.fatherInt = fatherInt;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2020-2021 Alexengrig Dev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.alexengrig.metter.demo.inheritance;

import dev.alexengrig.metter.annotation.GetterSupplier;
import dev.alexengrig.metter.annotation.SetterSupplier;

@GetterSupplier
@SetterSupplier
public class GrandsonDomain extends SonDomain {
private int grandsonInt;

public GrandsonDomain(int fatherInt, int sonInt, int grandsonInt) {
super(fatherInt, sonInt);
this.grandsonInt = grandsonInt;
}

public int getGrandsonInt() {
return grandsonInt;
}

public void setGrandsonInt(int grandsonInt) {
this.grandsonInt = grandsonInt;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright 2020-2021 Alexengrig Dev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.alexengrig.metter.demo.inheritance;

import dev.alexengrig.metter.annotation.GetterSupplier;
import dev.alexengrig.metter.annotation.SetterSupplier;

@GetterSupplier
@SetterSupplier
public class SonDomain extends FatherDomain {
private int sonInt;

public SonDomain(int fatherInt, int sonInt) {
super(fatherInt);
this.sonInt = sonInt;
}

public int getSonInt() {
return sonInt;
}

public void setSonInt(int sonInt) {
this.sonInt = sonInt;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2020-2021 Alexengrig Dev.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package dev.alexengrig.metter.demo.lombokdata;

import dev.alexengrig.metter.annotation.GetterSupplier;
import dev.alexengrig.metter.annotation.SetterSupplier;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@GetterSupplier
@SetterSupplier
@EqualsAndHashCode(callSuper = true)
public class InheritedLombokDataDomain extends LombokDataDomain {
private long longer;

public InheritedLombokDataDomain(int integer, boolean bool, long longer) {
super(integer, bool);
this.longer = longer;
}
}
Loading

0 comments on commit 990d29b

Please sign in to comment.