-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🚑 @SuppressWarning annotation copied without value - compile err…
…or (#126) fix: Copy annotations to components with values
- Loading branch information
1 parent
8752e48
commit 0a01528
Showing
9 changed files
with
150 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
modules/auto-record-tests/src/test/resources/in/AnnotationWithValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package pl.com.labaj.autorecord.testcase; | ||
|
||
/*- | ||
* Copyright © 2023 Auto Record | ||
* | ||
* 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. | ||
*/ | ||
|
||
import pl.com.labaj.autorecord.AutoRecord; | ||
import pl.com.labaj.autorecord.Memoized; | ||
import pl.com.labaj.autorecord.annotations.ClassProperty; | ||
import pl.com.labaj.autorecord.annotations.SourceProperty; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import static java.util.Objects.isNull; | ||
|
||
@AutoRecord | ||
interface AnnotationWithValue { | ||
@Nullable | ||
Integer id(); | ||
|
||
@SourceProperty | ||
@ClassProperty(priority = 9) | ||
@SuppressWarnings("DataFlowIssue") | ||
@Memoized | ||
default String idToString() { | ||
if (isNull(id())) { | ||
return "absent"; | ||
} | ||
|
||
return Integer.toString(id()); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
modules/auto-record-tests/src/test/resources/out/AnnotationWithValueRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package pl.com.labaj.autorecord.testcase; | ||
|
||
/*- | ||
* Copyright © 2023 Auto Record | ||
* | ||
* 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. | ||
*/ | ||
|
||
import static java.util.Objects.requireNonNullElseGet; | ||
|
||
import java.lang.Integer; | ||
import java.lang.Override; | ||
import java.lang.String; | ||
import java.lang.SuppressWarnings; | ||
import javax.annotation.Nullable; | ||
import javax.annotation.processing.Generated; | ||
import pl.com.labaj.autorecord.GeneratedWithAutoRecord; | ||
import pl.com.labaj.autorecord.Memoized; | ||
import pl.com.labaj.autorecord.annotations.ClassProperty; | ||
import pl.com.labaj.autorecord.annotations.SourceProperty; | ||
import pl.com.labaj.autorecord.memoizer.Memoizer; | ||
|
||
@Generated("pl.com.labaj.autorecord.AutoRecord") | ||
@GeneratedWithAutoRecord | ||
record AnnotationWithValueRecord(@Nullable Integer id, | ||
@SourceProperty @ClassProperty(priority = 9) @Nullable Memoizer<String> idToStringMemoizer) implements AnnotationWithValue { | ||
AnnotationWithValueRecord { | ||
idToStringMemoizer = requireNonNullElseGet(idToStringMemoizer, Memoizer::new); | ||
} | ||
|
||
AnnotationWithValueRecord(@Nullable Integer id) { | ||
this(id, new Memoizer<>()); | ||
} | ||
|
||
@SourceProperty | ||
@ClassProperty(priority = 9) | ||
@SuppressWarnings({"DataFlowIssue"}) | ||
@Memoized | ||
@Override | ||
public String idToString() { | ||
return idToStringMemoizer.computeIfAbsent(AnnotationWithValue.super::idToString); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters