You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2025/02/20 23:01:17 UTC
(causeway) branch main updated: CAUSEWAY-3859: Java record refactoring (part 29)
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/causeway.git
The following commit(s) were added to refs/heads/main by this push:
new 000f5cc0a70 CAUSEWAY-3859: Java record refactoring (part 29)
000f5cc0a70 is described below
commit 000f5cc0a70e5123ce73f10ff2e4958285491ba6
Author: andi-huber <ah...@apache.org>
AuthorDate: Thu Feb 20 23:50:34 2025 +0100
CAUSEWAY-3859: Java record refactoring (part 29)
---
.../services/metamodel/MetaModelServiceMenu.java | 7 +-
.../org/apache/causeway/applib/value/Blob.java | 10 +-
.../causeway/applib/value/NamedWithMimeType.java | 4 +-
.../org/apache/causeway/applib/value/Password.java | 25 ++--
.../applib/value/semantics/TemporalSupport.java | 16 +--
.../value/semantics/ValueSemanticsAbstract.java | 2 +-
.../value/semantics/ValueSemanticsProvider.java | 7 +-
.../apache/causeway/commons/functional/Either.java | 139 ++++++++++-----------
.../causeway/commons/functional/Railway.java | 15 +--
.../apache/causeway/commons/functional/Try.java | 27 ++--
.../apache/causeway/commons/graph/GraphUtils.java | 13 +-
.../causeway/commons/internal/base/_Tuples.java | 76 -----------
.../commons/internal/debug/xray/XrayModel.java | 19 ++-
.../commons/internal/primitives/_Ints.java | 81 ++++++------
.../commons/internal/primitives/_Longs.java | 58 ++++-----
.../internal/reflection/_GenericResolver.java | 66 ++++++----
.../internal/reflection/_MethodFacades.java | 24 ++--
.../org/apache/causeway/commons/io/HashUtils.java | 19 ++-
.../org/apache/causeway/commons/io/ZipUtils.java | 55 ++++----
.../causeway/commons/collections/CanTest.java | 19 ++-
.../causeway/commons/graph/GraphUtilsTest.java | 24 ++--
.../commons/internal/reflection/_Expectations.java | 19 ++-
.../core/config/CausewayConfiguration.java | 19 ++-
.../DataSourceIntrospectionService.java | 8 +-
.../causeway/core/metamodel/consent/Consent.java | 19 ++-
.../facets/object/value/ValueFacetAbstract.java | 2 +-
.../specloader/validator/ValidationFailure.java | 30 ++---
.../specloader/validator/ValidationFailures.java | 6 +-
.../valuesemantics/BigDecimalValueSemantics.java | 12 +-
.../valuesemantics/LocaleValueSemantics.java | 10 +-
.../temporal/TemporalValueSemanticsProvider.java | 20 +--
.../value/JavaTimeValueSemanticsProviderTest.java | 14 +--
...anticsProvider_configureDecimalFormat_Test.java | 2 +-
.../IdStringifierForSerializable_Test.java | 10 +-
.../core/runtimeservices/executor/_Xray.java | 12 +-
.../core/runtimeservices/publish/_Xray.java | 30 ++---
.../session/InteractionServiceDefault.java | 2 +-
.../core/runtimeservices/session/_Xray.java | 2 +-
.../transaction/TransactionServiceSpring.java | 18 ++-
.../causeway/core/security/util/XrayUtil.java | 15 ++-
.../confmenu/ConfigurationViewServiceDefault.java | 2 +-
.../CausewayWebAppContextInitializer.java | 12 +-
.../applib/value/CalendarEventSemantics.java | 4 +-
.../commons/integration/changetracking/_Xray.java | 8 +-
.../testdomain/fixtures/EntityTestFixtures.java | 7 +-
.../DomainModelTest_usingGoodDomain.java | 4 +-
.../domainmodel/jdo/DomainModelTest.java | 6 +-
.../injecting/jdo/JdoEntityInjectingTest.java | 2 +-
.../injecting/jpa/JpaEntityInjectingTest.java | 2 +-
.../value/ActionInteractionProbeImpl.java | 38 +++---
.../testdomain/value/ValueSemanticsTester.java | 2 +-
.../h2console/ui/webmodule/WebModuleH2Console.java | 2 +-
.../hsqldbmgr/dom/services/HsqlDbManagerMenu.java | 2 +-
.../applib/validate/DomainModelValidator.java | 36 +++---
54 files changed, 445 insertions(+), 638 deletions(-)
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/MetaModelServiceMenu.java b/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/MetaModelServiceMenu.java
index 7de6e9dc51b..84a350d5ae0 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/MetaModelServiceMenu.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/services/metamodel/MetaModelServiceMenu.java
@@ -257,10 +257,9 @@ public class ActionDomainEvent extends MetaModelServiceMenu.ActionDomainEvent<do
// -- HELPER
- @lombok.Value
- static class MetaModelServiceAndConfig {
- MetaModelService metaModelService;
- Config config;
+ static record MetaModelServiceAndConfig(
+ MetaModelService metaModelService,
+ Config config) {
}
private Config defaultConfig(
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/value/Blob.java b/api/applib/src/main/java/org/apache/causeway/applib/value/Blob.java
index 0d07bd76f2a..17bf661baee 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/value/Blob.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/value/Blob.java
@@ -182,9 +182,8 @@ public Clob toClob(final @NonNull Charset charset) {
*/
@SneakyThrows
public void writeBytesTo(final @Nullable OutputStream os) {
- if(os==null) {
- return;
- }
+ if(os==null) return;
+
if(bytes!=null) {
os.write(bytes);
}
@@ -203,9 +202,8 @@ public void writeBytesTo(final @Nullable OutputStream os) {
*/
@SneakyThrows
public void writeTo(final @Nullable File file) {
- if(file==null) {
- return; // just ignore
- }
+ if(file==null) return; // just ignore
+
try(var os = new FileOutputStream(file)){
writeBytesTo(os);
}
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/value/NamedWithMimeType.java b/api/applib/src/main/java/org/apache/causeway/applib/value/NamedWithMimeType.java
index d856dc05f4b..5d92c65262a 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/value/NamedWithMimeType.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/value/NamedWithMimeType.java
@@ -47,11 +47,11 @@ public sealed interface NamedWithMimeType
/**
* @deprecated use {@link #name()} instead
*/
- default String getName() { return name(); }
+ @Deprecated default String getName() { return name(); }
/**
* @deprecated use {@link #mimeType()} instead
*/
- default MimeType getMimeType() { return mimeType(); }
+ @Deprecated default MimeType getMimeType() { return mimeType(); }
@Override
default int compareTo(final NamedWithMimeType o) {
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/value/Password.java b/api/applib/src/main/java/org/apache/causeway/applib/value/Password.java
index 6a135ecd75f..0facb79d17d 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/value/Password.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/value/Password.java
@@ -38,27 +38,18 @@
@Named(CausewayModuleApplib.NAMESPACE + ".value.Password")
@Value
@XmlAccessorType(XmlAccessType.FIELD)
-// @XmlJavaTypeAdapter(Password.JaxbToStringAdapter.class) // TODO: not automatically registered because not secure enough. Instead we should set up some sort of mechanism to encrypt.
-@lombok.Value
-public class Password implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private final String password;
+//TODO: not automatically registered because not encrypted
+// @XmlJavaTypeAdapter(Password.JaxbToStringAdapter.class)
+public record Password(String password) implements Serializable {
public static Password of(final String password) {
return new Password(password);
}
- // in support of XML un-marshaling
- @SuppressWarnings("unused")
- private Password() {
- this("");
- }
-
- public Password(final String password) {
- this.password = password;
- }
+ /**
+ * @deprecated use {@link #password()} instead
+ */
+ @Deprecated public String getPassword() { return password(); }
public boolean checkPassword(final String password) {
return Objects.equals(this.password, password);
@@ -81,7 +72,7 @@ public Password unmarshal(final String str) throws Exception {
@Override
public String marshal(final Password password) throws Exception {
return password != null
- ? password.getPassword()
+ ? password.password()
: null;
}
}
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/value/semantics/TemporalSupport.java b/api/applib/src/main/java/org/apache/causeway/applib/value/semantics/TemporalSupport.java
index 9235e387a3d..a04846434c8 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/value/semantics/TemporalSupport.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/value/semantics/TemporalSupport.java
@@ -28,21 +28,17 @@
import org.apache.causeway.commons.functional.Either;
-import lombok.Value;
-import lombok.experimental.Accessors;
-
/**
* Decomposes arbitrary time representing values of type T into a canonical representation.
*/
public interface TemporalSupport<T> extends TemporalCharacteristicsProvider {
- @Value @Accessors(fluent=true) // record candidate
- public static class TemporalDecomposition implements Serializable {
- private static final long serialVersionUID = 1L;
- private final Temporal localTemporal;
- private final Optional<Either<ZoneId, ZoneOffset>> zoneOrOffset;
- TemporalCharacteristic temporalCharacteristic;
- OffsetCharacteristic offsetCharacteristic;
+ public record TemporalDecomposition(
+ Temporal localTemporal,
+ Optional<Either<ZoneId, ZoneOffset>> zoneOrOffset,
+ TemporalCharacteristic temporalCharacteristic,
+ OffsetCharacteristic offsetCharacteristic
+ ) implements Serializable {
}
/**
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/value/semantics/ValueSemanticsAbstract.java b/api/applib/src/main/java/org/apache/causeway/applib/value/semantics/ValueSemanticsAbstract.java
index 5400fdc0f04..54ad4494328 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/value/semantics/ValueSemanticsAbstract.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/value/semantics/ValueSemanticsAbstract.java
@@ -112,7 +112,7 @@ public IdStringifier<T> getIdStringifier() {
*/
protected UserLocale getUserLocale(final ValueSemanticsProvider.@Nullable Context context) {
return Optional.ofNullable(context)
- .map(ValueSemanticsProvider.Context::getInteractionContext)
+ .map(ValueSemanticsProvider.Context::interactionContext)
.map(InteractionContext::getLocale)
.orElseGet(UserLocale::getDefault);
}
diff --git a/api/applib/src/main/java/org/apache/causeway/applib/value/semantics/ValueSemanticsProvider.java b/api/applib/src/main/java/org/apache/causeway/applib/value/semantics/ValueSemanticsProvider.java
index 8d86b276944..c28cc0c4897 100644
--- a/api/applib/src/main/java/org/apache/causeway/applib/value/semantics/ValueSemanticsProvider.java
+++ b/api/applib/src/main/java/org/apache/causeway/applib/value/semantics/ValueSemanticsProvider.java
@@ -53,10 +53,9 @@
*/
public interface ValueSemanticsProvider<T> {
- @lombok.Value(staticConstructor = "of")
- class Context {
- private final @Nullable Identifier featureIdentifier;
- private final @Nullable InteractionContext interactionContext;
+ record Context(
+ @Nullable Identifier featureIdentifier,
+ @Nullable InteractionContext interactionContext) {
}
Class<T> getCorrespondingClass();
diff --git a/commons/src/main/java/org/apache/causeway/commons/functional/Either.java b/commons/src/main/java/org/apache/causeway/commons/functional/Either.java
index 06f08b8c8e2..a9c078e8416 100644
--- a/commons/src/main/java/org/apache/causeway/commons/functional/Either.java
+++ b/commons/src/main/java/org/apache/causeway/commons/functional/Either.java
@@ -24,9 +24,7 @@
import java.util.function.Consumer;
import java.util.function.Function;
-import lombok.AccessLevel;
import org.jspecify.annotations.NonNull;
-import lombok.RequiredArgsConstructor;
/**
* The {@link Either} type represents a value of one of two possible types (a disjoint union),
@@ -37,7 +35,8 @@
*
* @since 2.0 {@index}
*/
-public interface Either<L, R> {
+public sealed interface Either<L, R>
+permits Either.Left, Either.Right {
// -- FACTORIES
@@ -87,149 +86,139 @@ void accept(
// -- LEFT
- @lombok.Value
- @RequiredArgsConstructor(access=AccessLevel.PROTECTED)
- static final class Left<L, R> implements Either<L, R>, Serializable {
- private static final long serialVersionUID = 1L;
+ static record Left<L, R>(L _left) implements Either<L, R>, Serializable {
- private final L left;
-
- @Override public Optional<L> left() { return Optional.ofNullable(left); }
+ @Override public Optional<L> left() { return Optional.ofNullable(_left); }
@Override public Optional<R> right() { return Optional.empty(); }
- @Override public L leftIfAny() { return left; }
+ @Override public L leftIfAny() { return _left; }
@Override public R rightIfAny() { return null; }
@Override public final boolean isLeft() { return true; }
@Override public final boolean isRight() { return false; }
@Override public final <T> Either<T, R> mapLeft(final @NonNull Function<L, T> leftMapper){
- return Either.left(leftMapper.apply(left)); }
+ return Either.left(leftMapper.apply(_left)); }
@Override public final <T> Either<L, T> mapRight(final @NonNull Function<R, T> rightMapper){
- return Either.left(left); }
+ return Either.left(_left); }
@Override
public final <X, Y> Either<X, Y> map(
final @NonNull Function<L, X> leftMapper,
final @NonNull Function<R, Y> rightMapper){
- return Either.left(leftMapper.apply(left));
+ return Either.left(leftMapper.apply(_left));
}
@Override
public final <T> T fold(final @NonNull BiFunction<L, R, T> biMapper){
- return biMapper.apply(left, null);
+ return biMapper.apply(_left, null);
}
@Override
public final <T> T fold(
final @NonNull Function<L, T> leftMapper,
final @NonNull Function<R, T> rightMapper){
- return leftMapper.apply(left);
+ return leftMapper.apply(_left);
}
@Override
public final void accept(
final @NonNull Consumer<L> leftConsumer,
final @NonNull Consumer<R> rightConsumer) {
- leftConsumer.accept(left);
+ leftConsumer.accept(_left);
}
}
// -- RIGHT
- @lombok.Value
- @RequiredArgsConstructor(access=AccessLevel.PROTECTED)
- static final class Right<L, R> implements Either<L, R>, Serializable {
- private static final long serialVersionUID = 1L;
-
- private final R right;
+ static record Right<L, R>(R _right) implements Either<L, R>, Serializable {
@Override public Optional<L> left() { return Optional.empty(); }
- @Override public Optional<R> right() { return Optional.ofNullable(right); }
+ @Override public Optional<R> right() { return Optional.ofNullable(_right); }
@Override public L leftIfAny() { return null; }
- @Override public R rightIfAny() { return right; }
+ @Override public R rightIfAny() { return _right; }
@Override public final boolean isLeft() { return false; }
@Override public final boolean isRight() { return true; }
@Override public final <T> Either<T, R> mapLeft(final @NonNull Function<L, T> leftMapper){
- return Either.right(right); }
+ return Either.right(_right); }
@Override public final <T> Either<L, T> mapRight(final @NonNull Function<R, T> rightMapper){
- return Either.right(rightMapper.apply(right)); }
+ return Either.right(rightMapper.apply(_right)); }
@Override
public final <X, Y> Either<X, Y> map(
final @NonNull Function<L, X> leftMapper,
final @NonNull Function<R, Y> rightMapper){
- return Either.right(rightMapper.apply(right));
+ return Either.right(rightMapper.apply(_right));
}
@Override
public final <T> T fold(final @NonNull BiFunction<L, R, T> biMapper){
- return biMapper.apply(null, right);
+ return biMapper.apply(null, _right);
}
@Override
public final <T> T fold(
final @NonNull Function<L, T> leftMapper,
final @NonNull Function<R, T> rightMapper){
- return rightMapper.apply(right);
+ return rightMapper.apply(_right);
}
@Override
public final void accept(
final @NonNull Consumer<L> leftConsumer,
final @NonNull Consumer<R> rightConsumer) {
- rightConsumer.accept(right);
+ rightConsumer.accept(_right);
}
}
- // -- TYPE COMPOSITION
-
- @FunctionalInterface
- public static interface HasEither<L, R> extends Either<L, R> {
-
- Either<L, R> getEither();
-
- @Override default Optional<L> left() { return getEither().left(); }
- @Override default Optional<R> right() { return getEither().right(); }
-
- @Override default L leftIfAny() { return getEither().leftIfAny(); }
- @Override default R rightIfAny() { return getEither().rightIfAny(); }
-
- @Override default boolean isLeft() { return getEither().isLeft(); }
- @Override default boolean isRight() { return getEither().isRight(); }
-
- @Override default <T> Either<T, R> mapLeft(final @NonNull Function<L, T> leftMapper){
- return getEither().mapLeft(leftMapper); }
- @Override default <T> Either<L, T> mapRight(final @NonNull Function<R, T> rightMapper){
- return getEither().mapRight(rightMapper); }
-
- @Override default <X, Y> Either<X, Y> map(
- final @NonNull Function<L, X> leftMapper,
- final @NonNull Function<R, Y> rightMapper){
- return getEither().map(leftMapper, rightMapper);
- }
-
- @Override default <T> T fold(final @NonNull BiFunction<L, R, T> biMapper){
- return getEither().fold(biMapper);
- }
-
- @Override default <T> T fold(
- final @NonNull Function<L, T> leftMapper,
- final @NonNull Function<R, T> rightMapper){
- return getEither().fold(leftMapper, rightMapper);
- }
-
- @Override default void accept(
- final @NonNull Consumer<L> leftConsumer,
- final @NonNull Consumer<R> rightConsumer) {
- getEither().accept(leftConsumer, rightConsumer);
- }
-
- }
+// // -- TYPE COMPOSITION
+//
+// @FunctionalInterface
+// public static interface HasEither<L, R> extends Either<L, R> {
+//
+// Either<L, R> getEither();
+//
+// @Override default Optional<L> left() { return getEither().left(); }
+// @Override default Optional<R> right() { return getEither().right(); }
+//
+// @Override default L leftIfAny() { return getEither().leftIfAny(); }
+// @Override default R rightIfAny() { return getEither().rightIfAny(); }
+//
+// @Override default boolean isLeft() { return getEither().isLeft(); }
+// @Override default boolean isRight() { return getEither().isRight(); }
+//
+// @Override default <T> Either<T, R> mapLeft(final @NonNull Function<L, T> leftMapper){
+// return getEither().mapLeft(leftMapper); }
+// @Override default <T> Either<L, T> mapRight(final @NonNull Function<R, T> rightMapper){
+// return getEither().mapRight(rightMapper); }
+//
+// @Override default <X, Y> Either<X, Y> map(
+// final @NonNull Function<L, X> leftMapper,
+// final @NonNull Function<R, Y> rightMapper){
+// return getEither().map(leftMapper, rightMapper);
+// }
+//
+// @Override default <T> T fold(final @NonNull BiFunction<L, R, T> biMapper){
+// return getEither().fold(biMapper);
+// }
+//
+// @Override default <T> T fold(
+// final @NonNull Function<L, T> leftMapper,
+// final @NonNull Function<R, T> rightMapper){
+// return getEither().fold(leftMapper, rightMapper);
+// }
+//
+// @Override default void accept(
+// final @NonNull Consumer<L> leftConsumer,
+// final @NonNull Consumer<R> rightConsumer) {
+// getEither().accept(leftConsumer, rightConsumer);
+// }
+//
+// }
}
diff --git a/commons/src/main/java/org/apache/causeway/commons/functional/Railway.java b/commons/src/main/java/org/apache/causeway/commons/functional/Railway.java
index f252831c480..94cd51fe23f 100644
--- a/commons/src/main/java/org/apache/causeway/commons/functional/Railway.java
+++ b/commons/src/main/java/org/apache/causeway/commons/functional/Railway.java
@@ -28,7 +28,6 @@
import org.springframework.util.function.ThrowingConsumer;
import org.springframework.util.function.ThrowingFunction;
-import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
/**
@@ -138,12 +137,7 @@ <R> R fold(
// -- SUCCESS
- @lombok.Value
- @RequiredArgsConstructor
- final class Success<F, S> implements Railway<F, S>, Serializable {
- private static final long serialVersionUID = 1L;
-
- private final @NonNull S success;
+ final record Success<F, S>(@NonNull S success) implements Railway<F, S>, Serializable {
@Override public boolean isSuccess() { return true; }
@Override public boolean isFailure() { return false; }
@@ -188,12 +182,7 @@ public Railway<F, S> chain(final @NonNull ThrowingFunction<S, Railway<F, S>> cha
// -- FAILURE
- @lombok.Value
- @RequiredArgsConstructor
- final class Failure<F, S> implements Railway<F, S>, Serializable {
- private static final long serialVersionUID = 1L;
-
- private final @NonNull F failure;
+ final record Failure<F, S>(@NonNull F failure) implements Railway<F, S>, Serializable {
@Override public boolean isSuccess() { return false; }
@Override public boolean isFailure() { return true; }
diff --git a/commons/src/main/java/org/apache/causeway/commons/functional/Try.java b/commons/src/main/java/org/apache/causeway/commons/functional/Try.java
index 0124c598675..8a855e272fd 100644
--- a/commons/src/main/java/org/apache/causeway/commons/functional/Try.java
+++ b/commons/src/main/java/org/apache/causeway/commons/functional/Try.java
@@ -24,14 +24,14 @@
import java.util.concurrent.Callable;
import java.util.function.Supplier;
+import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
+
import org.springframework.util.function.ThrowingConsumer;
import org.springframework.util.function.ThrowingFunction;
import org.apache.causeway.commons.internal.exceptions._Exceptions;
-import org.jspecify.annotations.NonNull;
-import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
/**
@@ -46,7 +46,8 @@
*
* @since 2.0 {@index}
*/
-public interface Try<T> {
+public sealed interface Try<T>
+permits Try.Success, Try.Failure {
// -- FACTORIES
@@ -292,17 +293,12 @@ default T valueAsNonNullElseFail() {
// -- SUCCESS
- @lombok.Value
- @RequiredArgsConstructor
- final class Success<T> implements Try<T>, Serializable {
- private static final long serialVersionUID = 1L;
-
- private final @Nullable T value;
+ record Success<T>(@Nullable T _value) implements Try<T>, Serializable {
@Override public boolean isSuccess() { return true; }
@Override public boolean isFailure() { return false; }
- @Override public Optional<T> getValue() { return Optional.ofNullable(value); }
+ @Override public Optional<T> getValue() { return Optional.ofNullable(_value); }
@Override public Optional<Throwable> getFailure() { return Optional.empty(); }
@Override
@@ -336,7 +332,7 @@ public Success<T> ifFailureFail() {
@Override
public Success<T> ifAbsentFail() {
- if(value==null) throw _Exceptions.noSuchElement();
+ if(_value==null) throw _Exceptions.noSuchElement();
return this;
}
@@ -392,7 +388,7 @@ public Try<T> mapFailureToSuccess(final @NonNull ThrowingFunction<Throwable, T>
@Override
public Try<T> mapEmptyToFailure() {
- return value!=null
+ return _value!=null
? this
: Try.failure(_Exceptions.noSuchElement());
}
@@ -451,12 +447,7 @@ public <L, R> Either<L, R> mapToEither(
// -- FAILURE
- @lombok.Value
- @RequiredArgsConstructor
- final class Failure<T> implements Try<T>, Serializable {
- private static final long serialVersionUID = 1L;
-
- private final @NonNull Throwable throwable;
+ record Failure<T>(@NonNull Throwable throwable) implements Try<T>, Serializable {
@Override public boolean isSuccess() { return false; }
@Override public boolean isFailure() { return true; }
diff --git a/commons/src/main/java/org/apache/causeway/commons/graph/GraphUtils.java b/commons/src/main/java/org/apache/causeway/commons/graph/GraphUtils.java
index 75185ad7ae4..9ef103c0d9e 100644
--- a/commons/src/main/java/org/apache/causeway/commons/graph/GraphUtils.java
+++ b/commons/src/main/java/org/apache/causeway/commons/graph/GraphUtils.java
@@ -33,6 +33,7 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;
+import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.apache.causeway.commons.collections.Can;
@@ -45,7 +46,6 @@
import org.apache.causeway.commons.internal.primitives._Longs;
import lombok.Getter;
-import org.jspecify.annotations.NonNull;
import lombok.experimental.Accessors;
import lombok.experimental.UtilityClass;
@@ -283,11 +283,10 @@ public interface EdgeFormatter<T> {
* @param <T> graph's node type
* @since 2.1, 3.1
*/
- @lombok.Value @Accessors(fluent=true)
- public class Graph<T> {
- private final GraphKernel kernel;
- private final Can<T> nodes;
- private final Map<Long, Object> edgeAttributeByPackedEdgeIndex;
+ public record Graph<T>(
+ GraphKernel kernel,
+ Can<T> nodes,
+ Map<Long, Object> edgeAttributeByPackedEdgeIndex) {
// -- TRAVERSAL
@@ -376,7 +375,7 @@ public Graph<T> filter(final Predicate<T> filter) {
var nodeType = _Casts.<Class<T>>uncheckedCast(nodes.getFirst().get().getClass());
var builder = new GraphBuilder<T>(nodeType, kernel().characteristics);
var isUndirected = kernel().isUndirected();
-
+
nodes.forEach(IndexedConsumer.zeroBased((nodeIndex, node)->{
if(filter.test(node)) {
builder.addNode(node);
diff --git a/commons/src/main/java/org/apache/causeway/commons/internal/base/_Tuples.java b/commons/src/main/java/org/apache/causeway/commons/internal/base/_Tuples.java
deleted file mode 100644
index 7268e6f7c63..00000000000
--- a/commons/src/main/java/org/apache/causeway/commons/internal/base/_Tuples.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.causeway.commons.internal.base;
-
-import lombok.Value;
-
-/**
- * <h1>- internal use only -</h1>
- * <p>
- * Provides Tuples of arity 2,
- * </p>
- * <p>
- * <b>WARNING</b>: Do <b>NOT</b> use any of the classes provided by this package! <br/>
- * These may be changed or removed without notice!
- * </p>
- *
- * @since 2.0
- */
-public final class _Tuples {
-
- private _Tuples(){}
-
- // -- TUPLE 2
-
- public static class Tuple2<T1, T2>{
- private final T1 _1;
- private final T2 _2;
-
- private Tuple2(final T1 _1, final T2 _2) {
- this._1 = _1;
- this._2 = _2;
- }
-
- /**
- * @return first element of this tuple
- */
- public T1 get_1() { return _1; }
- /**
- * @return second element of this tuple
- */
- public T2 get_2() { return _2; }
- }
-
- public static <T1, T2> Tuple2<T1, T2> pair(final T1 _1, final T2 _2) {
- return new Tuple2<T1, T2>(_1, _2);
- }
-
- // -- INDEXED
-
- @Value(staticConstructor = "of")
- public static class Indexed<T>{
- int index;
- T value;
- }
-
- public static <T> Indexed<T> indexed(final int index, final T value) {
- return Indexed.of(index, value);
- }
-
-}
diff --git a/commons/src/main/java/org/apache/causeway/commons/internal/debug/xray/XrayModel.java b/commons/src/main/java/org/apache/causeway/commons/internal/debug/xray/XrayModel.java
index a093d9425c6..56ef3b2da8e 100644
--- a/commons/src/main/java/org/apache/causeway/commons/internal/debug/xray/XrayModel.java
+++ b/commons/src/main/java/org/apache/causeway/commons/internal/debug/xray/XrayModel.java
@@ -29,8 +29,6 @@
import org.apache.causeway.commons.internal.base._Strings;
-import lombok.Value;
-
public interface XrayModel {
enum Stickiness {
@@ -43,11 +41,11 @@ enum Stickiness {
MutableTreeNode rootNode();
default MutableTreeNode getThreadNode(final ThreadMemento threadMemento) {
- return lookupNode(threadMemento.getId())
+ return lookupNode(threadMemento.id())
.orElseGet(()->addContainerNode(
rootNode(),
- threadMemento.getLabel(),
- threadMemento.getId(),
+ threadMemento.label(),
+ threadMemento.id(),
Stickiness.CAN_DELETE_NODE));
}
@@ -94,15 +92,14 @@ public final String toString() {
// -- THREAD UTIL
- @Value(staticConstructor = "of")
- public static class ThreadMemento {
- private final String id;
- private final String label;
- private final String multilinelabel;
+ public record ThreadMemento(
+ String id,
+ String label,
+ String multilinelabel) {
public static ThreadMemento fromCurrentThread() {
var ct = Thread.currentThread();
- return ThreadMemento.of(
+ return new ThreadMemento(
String.format("thread-%d-%s", ct.getId(), ct.getName()),
String.format("Thread-%d [%s]", ct.getId(), ct.getName()),
String.format("Thread-%d\n%s", ct.getId(), ct.getName()));
diff --git a/commons/src/main/java/org/apache/causeway/commons/internal/primitives/_Ints.java b/commons/src/main/java/org/apache/causeway/commons/internal/primitives/_Ints.java
index dca921f8b25..79281b9441a 100644
--- a/commons/src/main/java/org/apache/causeway/commons/internal/primitives/_Ints.java
+++ b/commons/src/main/java/org/apache/causeway/commons/internal/primitives/_Ints.java
@@ -25,18 +25,13 @@
import java.util.function.IntFunction;
import java.util.stream.IntStream;
+import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.apache.causeway.commons.internal.assertions._Assert;
import org.apache.causeway.commons.internal.base._Strings;
import org.apache.causeway.commons.internal.exceptions._Exceptions;
-import lombok.AccessLevel;
-import org.jspecify.annotations.NonNull;
-import lombok.RequiredArgsConstructor;
-import lombok.Value;
-import lombok.experimental.UtilityClass;
-
/**
* <h1>- internal use only -</h1>
* <p>
@@ -49,8 +44,7 @@
*
* @since 2.0
*/
-@UtilityClass
-public class _Ints {
+public record _Ints() {
@FunctionalInterface
public interface BiIntConsumer {
@@ -64,16 +58,17 @@ public interface BiIntFunction<R> {
// -- RANGE
- @Value(staticConstructor = "of")
- public static class Bound {
- int value;
- boolean inclusive;
- public static @NonNull Bound inclusive(final int value) { return of(value, true); }
- public static @NonNull Bound exclusive(final int value) { return of(value, true); }
+ public record Bound(
+ int value,
+ boolean isInclusive) {
+ public static @NonNull Bound inclusive(final int value) { return new Bound(value, true); }
+ public static @NonNull Bound exclusive(final int value) { return new Bound(value, true); }
}
- @RequiredArgsConstructor(access = AccessLevel.PRIVATE)
- public static class Range {
+ public record Range(
+ Bound lowerBound,
+ Bound upperBound,
+ boolean isEmpty) {
public static Range empty() {
return new Range(null, null, true);
@@ -85,23 +80,18 @@ public static Range of(
return new Range(lowerBound, upperBound, false);
}
- private final Bound lowerBound;
- private final Bound upperBound;
- private final boolean empty;
public boolean contains(final int value) {
- if(empty) return false;
+ if(isEmpty) return false;
var isBelowLower = lowerBound.isInclusive()
- ? value < lowerBound.getValue()
- : value <= lowerBound.getValue();
- if(isBelowLower) {
- return false;
- }
+ ? value < lowerBound.value()
+ : value <= lowerBound.value();
+ if(isBelowLower) return false;
+
var isAboveUpper = upperBound.isInclusive()
- ? value > upperBound.getValue()
- : value >= upperBound.getValue();
- if(isAboveUpper) {
- return false;
- }
+ ? value > upperBound.value()
+ : value >= upperBound.value();
+ if(isAboveUpper) return false;
+
return true;
}
/**
@@ -109,10 +99,9 @@ public boolean contains(final int value) {
* @return the value or if not within range, the nearest integer to the value, that is within range
*/
public int bounded(final int value) {
- if(empty) return value; // noop
- if(contains(value)) {
- return value;
- }
+ if(isEmpty) return value; // noop
+ if(contains(value)) return value;
+
final int nearestToLower = nearestToLower();
final int nearestToUpper = nearestToUpper();
final int distanceToLower = value - nearestToLower;
@@ -122,15 +111,15 @@ public int bounded(final int value) {
: nearestToUpper;
}
private int nearestToLower() {
- if(empty) throw _Exceptions.unsupportedOperation();
- return lowerBound.isInclusive() ? lowerBound.getValue() : lowerBound.getValue()+1;
+ if(isEmpty) throw _Exceptions.unsupportedOperation();
+ return lowerBound.isInclusive() ? lowerBound.value() : lowerBound.value()+1;
}
private int nearestToUpper() {
- if(empty) throw _Exceptions.unsupportedOperation();
- return upperBound.isInclusive() ? upperBound.getValue() : upperBound.getValue()-1;
+ if(isEmpty) throw _Exceptions.unsupportedOperation();
+ return upperBound.isInclusive() ? upperBound.value() : upperBound.value()-1;
}
public @NonNull Optional<Range> intersect(final @NonNull Range other) {
- if(empty) return Optional.empty();
+ if(isEmpty) return Optional.empty();
final int s1 = this.nearestToLower();
final int e1 = this.nearestToUpper();
final int s2 = other.nearestToLower();
@@ -144,17 +133,17 @@ private int nearestToUpper() {
}
@Override
public String toString() {
- if(empty) return "[]";
+ if(isEmpty) return "[]";
return String.format("%s%d,%d%S",
- lowerBound.isInclusive() ? '[' : '(', lowerBound.getValue(),
- upperBound.getValue(), upperBound.isInclusive() ? ']' : ')');
+ lowerBound.isInclusive() ? '[' : '(', lowerBound.value(),
+ upperBound.value(), upperBound.isInclusive() ? ']' : ')');
}
public IntStream stream() {
- if(empty) return IntStream.empty();
+ if(isEmpty) return IntStream.empty();
return IntStream.rangeClosed(nearestToLower(), nearestToUpper());
}
public PrimitiveIterator.OfInt iterator() {
- if(empty) return IntStream.empty().iterator();
+ if(isEmpty) return IntStream.empty().iterator();
return new PrimitiveIterator.OfInt() {
int next = nearestToLower();
final int upperIncluded = nearestToUpper();
@@ -236,7 +225,7 @@ public static Range rangeOpenEnded(final int a, final int b) {
* @return optionally the integer represented by the string argument in the specified radix
*
*/
- public OptionalInt parseInt(final String s, final int radix, final Consumer<String> onFailure) {
+ public static OptionalInt parseInt(final String s, final int radix, final Consumer<String> onFailure) {
final long parseResult = parseIntElseLongMaxValue(s, radix, onFailure);
if(isParseSuccess(parseResult)) {
return OptionalInt.of(Math.toIntExact(parseResult));
@@ -246,7 +235,7 @@ public OptionalInt parseInt(final String s, final int radix, final Consumer<Stri
// -- SHORTCUTS
- public OptionalInt parseInt(final String s, final int radix) {
+ public static OptionalInt parseInt(final String s, final int radix) {
return parseInt(s, radix, IGNORE_ERRORS);
}
diff --git a/commons/src/main/java/org/apache/causeway/commons/internal/primitives/_Longs.java b/commons/src/main/java/org/apache/causeway/commons/internal/primitives/_Longs.java
index f6c07d05507..acacb3ad39c 100644
--- a/commons/src/main/java/org/apache/causeway/commons/internal/primitives/_Longs.java
+++ b/commons/src/main/java/org/apache/causeway/commons/internal/primitives/_Longs.java
@@ -28,8 +28,6 @@
import org.apache.causeway.commons.internal.primitives._Ints.BiIntFunction;
import org.jspecify.annotations.NonNull;
-import lombok.Value;
-import lombok.experimental.UtilityClass;
/**
* <h1>- internal use only -</h1>
@@ -43,36 +41,32 @@
*
* @since 2.0
*/
-@UtilityClass
-public class _Longs {
+public record _Longs() {
// -- RANGE
- @Value(staticConstructor = "of")
- public static class Bound {
- long value;
- boolean inclusive;
- public static @NonNull Bound inclusive(final long value) { return of(value, true); }
- public static @NonNull Bound exclusive(final long value) { return of(value, true); }
+ public record Bound(
+ long value,
+ boolean isInclusive) {
+ public static @NonNull Bound inclusive(final long value) { return new Bound(value, true); }
+ public static @NonNull Bound exclusive(final long value) { return new Bound(value, true); }
}
- @Value(staticConstructor = "of")
- public static class Range {
- @NonNull Bound lowerBound;
- @NonNull Bound upperBound;
+ public record Range(
+ @NonNull Bound lowerBound,
+ @NonNull Bound upperBound) {
+
public boolean contains(final long value) {
var isBelowLower = lowerBound.isInclusive()
- ? value < lowerBound.getValue()
- : value <= lowerBound.getValue();
- if(isBelowLower) {
- return false;
- }
+ ? value < lowerBound.value()
+ : value <= lowerBound.value();
+ if(isBelowLower) return false;
+
var isAboveUpper = upperBound.isInclusive()
- ? value > upperBound.getValue()
- : value >= upperBound.getValue();
- if(isAboveUpper) {
- return false;
- }
+ ? value > upperBound.value()
+ : value >= upperBound.value();
+ if(isAboveUpper) return false;
+
return true;
}
/**
@@ -94,17 +88,17 @@ public long bounded(final long value) {
}
private long nearestToLower() {
//if(empty) throw _Exceptions.unsupportedOperation();
- return lowerBound.isInclusive() ? lowerBound.getValue() : lowerBound.getValue()+1;
+ return lowerBound.isInclusive() ? lowerBound.value() : lowerBound.value()+1;
}
private long nearestToUpper() {
//if(empty) throw _Exceptions.unsupportedOperation();
- return upperBound.isInclusive() ? upperBound.getValue() : upperBound.getValue()-1;
+ return upperBound.isInclusive() ? upperBound.value() : upperBound.value()-1;
}
@Override
public String toString() {
return String.format("%s%d,%d%S",
- lowerBound.isInclusive() ? '[' : '(', lowerBound.getValue(),
- upperBound.getValue(), upperBound.isInclusive() ? ']' : ')');
+ lowerBound.isInclusive() ? '[' : '(', lowerBound.value(),
+ upperBound.value(), upperBound.isInclusive() ? ']' : ')');
}
}
@@ -117,7 +111,7 @@ public static Range rangeClosed(final long a, final long b) {
if(a>b) {
throw _Exceptions.illegalArgument("bounds must be ordered in [%d, %d]", a, b);
}
- return Range.of(Bound.inclusive(a), Bound.inclusive(b));
+ return new Range(Bound.inclusive(a), Bound.inclusive(b));
}
/**
@@ -131,7 +125,7 @@ public static Range rangeOpenEnded(final long a, final long b) {
if(a>=b) {
throw _Exceptions.illegalArgument("bounds must be ordered in [%d, %d]", a, b);
}
- return Range.of(Bound.inclusive(a), Bound.exclusive(b));
+ return new Range(Bound.inclusive(a), Bound.exclusive(b));
}
// -- PARSING
@@ -170,7 +164,7 @@ public static Range rangeOpenEnded(final long a, final long b) {
* @implNote Copied over from JDK's {@link Integer#parseInt(String)} to provide a variant
* with minimum potential heap pollution (does not produce stack-traces on parsing failures)
*/
- public OptionalLong parseLong(final @Nullable String s, final int radix, final @NonNull Consumer<String> onFailure) {
+ public static OptionalLong parseLong(final @Nullable String s, final int radix, final @NonNull Consumer<String> onFailure) {
if (s == null) {
onFailure.accept("null");
@@ -256,7 +250,7 @@ public static <X> X unpackAndApply(final long x, final BiIntFunction<X> function
// -- SHORTCUTS
- public OptionalLong parseLong(final String s, final int radix) {
+ public static OptionalLong parseLong(final String s, final int radix) {
return parseLong(s, radix, IGNORE_ERRORS);
}
diff --git a/commons/src/main/java/org/apache/causeway/commons/internal/reflection/_GenericResolver.java b/commons/src/main/java/org/apache/causeway/commons/internal/reflection/_GenericResolver.java
index 43893b9751e..83011199535 100644
--- a/commons/src/main/java/org/apache/causeway/commons/internal/reflection/_GenericResolver.java
+++ b/commons/src/main/java/org/apache/causeway/commons/internal/reflection/_GenericResolver.java
@@ -320,37 +320,39 @@ public ResolvedConstructor resolveConstructor(
// -- IMPLEMENTATIONS
- @lombok.Value @Accessors(fluent=true)
- private static class SimpleTypeOfAnyCardinality implements ResolvedType {
- @Getter(onMethod_={@Override})
- private final @NonNull Class<?> elementType;
- @Getter(onMethod_={@Override})
- private final @NonNull Optional<Class<?>> containerType;
- @Getter(onMethod_={@Override})
- private final @NonNull Optional<CollectionSemantics> collectionSemantics;
+ private record SimpleTypeOfAnyCardinality(
+ @NonNull Class<?> elementType,
+ @NonNull Optional<Class<?>> containerType,
+ @NonNull Optional<CollectionSemantics> collectionSemantics) implements ResolvedType {
}
- @EqualsAndHashCode
- @Getter @Accessors(fluent=true)
- private static class SimpleResolvedMethod implements ResolvedMethod {
-
- private final Method method;
- private final Class<?> implementationClass;
-
- @EqualsAndHashCode.Exclude
- private final Class<?>[] paramTypes;
- @EqualsAndHashCode.Exclude
- private final Class<?> returnType;
- @EqualsAndHashCode.Exclude
- private final boolean isResolved;
+ private record SimpleResolvedMethod(
+ Method method,
+ Class<?> implementationClass,
+ Class<?>[] paramTypes,
+ Class<?> returnType,
+ boolean isResolved
+ ) implements ResolvedMethod {
public SimpleResolvedMethod(final Method method, final Class<?> implementationClass) {
+ this(method, implementationClass,
+ _GenericResolver.resolveParameterTypes(method, implementationClass),
+ GenericTypeResolver.resolveReturnType(method, implementationClass),
+ // not used in canonical constructor ...
+ false);
+ }
+ // canonical constructor
+ public SimpleResolvedMethod(
+ final Method method,
+ final Class<?> implementationClass,
+ final Class<?>[] paramTypes,
+ final Class<?> returnType,
+ final boolean isResolved) {
this.method = method;
this.implementationClass = implementationClass;
- this.paramTypes = _GenericResolver.resolveParameterTypes(method, implementationClass);
- this.returnType = GenericTypeResolver.resolveReturnType(method, implementationClass);
- this.isResolved = isReturnTypeResolved()
- && areParamsResolved();
+ this.paramTypes = paramTypes;
+ this.returnType = returnType;
+ this.isResolved = isReturnTypeResolved() && areParamsResolved();
}
public Optional<ResolvedMethod> guardAgainstCannotResolve() {
return isResolved ? Optional.of(this) : Optional.empty();
@@ -372,6 +374,18 @@ public String toString() {
.map(Class::getSimpleName)
.collect(Collectors.joining(",")));
}
+ @Override
+ public final boolean equals(final Object obj) {
+ return obj instanceof SimpleResolvedMethod other
+ ? Objects.equals(this.method(), other.method())
+ && Objects.equals(this.implementationClass(), other.implementationClass())
+ : false;
+ }
+ @Override
+ public final int hashCode() {
+ return Objects.hash(method(), implementationClass());
+ }
+
//-- HELPER
private boolean areParamsResolved() {
if(isNoArg()) return true; // skip check
@@ -395,7 +409,7 @@ public Stream<Annotation> streamAnnotations() {
_NullSafe.stream(method().getAnnotatedReturnType().getAnnotations()),
_NullSafe.stream(method().getAnnotations()));
}
-
+
// private Try<SimpleResolvedMethod> adopt(final @NonNull ClassLoader classLoader) {
// return Try.call(()->{
// var ownerReloaded = Class.forName(implementationClass.getName(), true, classLoader);
diff --git a/commons/src/main/java/org/apache/causeway/commons/internal/reflection/_MethodFacades.java b/commons/src/main/java/org/apache/causeway/commons/internal/reflection/_MethodFacades.java
index 510226f7f6a..76e35963170 100644
--- a/commons/src/main/java/org/apache/causeway/commons/internal/reflection/_MethodFacades.java
+++ b/commons/src/main/java/org/apache/causeway/commons/internal/reflection/_MethodFacades.java
@@ -92,7 +92,7 @@ public interface ParameterConverter {
* Replaces {@code parameterValue} (if required) to be conform with the {@code parameterType}.
*/
<T> T convert(final Class<T> parameterType, Object parameterValue);
-
+
// -- UTILITY
default Object[] convertAll(
@@ -111,8 +111,9 @@ default Object[] convertAll(
return adaptedExecutionParameters;
}
}
-
- public static interface MethodFacade {
+
+ public static sealed interface MethodFacade
+ permits ParamsAsTupleMethod, RegularMethod {
Class<?>[] getParameterTypes();
Class<?> getParameterType(int paramNum);
@@ -177,10 +178,7 @@ default ResolvedType resolveParameter(final int paramIndex) {
/**
* Wraps a {@link Method}, implemented as a transparent pass through.
*/
- @lombok.Value
- private final static class RegularMethod implements MethodFacade {
-
- private final ResolvedMethod method;
+ private record RegularMethod(ResolvedMethod method) implements MethodFacade {
@Override public Class<?> getDeclaringClass() {
return method.method().getDeclaringClass();
@@ -223,7 +221,7 @@ private final static class RegularMethod implements MethodFacade {
final Class<A> annotationType, final int paramNum) {
return _Annotations.synthesize(method.method().getParameters()[paramNum], annotationType);
}
- @Override public Object[] getArguments(final Object[] executionParameters, ParameterConverter converter) {
+ @Override public Object[] getArguments(final Object[] executionParameters, final ParameterConverter converter) {
return converter.convertAll(method.method(), executionParameters);
}
@Override public boolean isAnnotatedAsNullable() {
@@ -236,11 +234,9 @@ private final static class RegularMethod implements MethodFacade {
}
}
- @lombok.Value
- private final static class ParamsAsTupleMethod implements MethodFacade {
-
- private final ResolvedConstructor patConstructor;
- private final ResolvedMethod method;
+ private record ParamsAsTupleMethod(
+ ResolvedConstructor patConstructor,
+ ResolvedMethod method) implements MethodFacade {
@Override public Class<?>[] getParameterTypes() {
return patConstructor.paramTypes();
@@ -278,7 +274,7 @@ private final static class ParamsAsTupleMethod implements MethodFacade {
return patConstructor.constructor();
}
@Override @SneakyThrows
- public Object[] getArguments(final Object[] executionParameters, ParameterConverter converter) {
+ public Object[] getArguments(final Object[] executionParameters, final ParameterConverter converter) {
var convertedArgs = converter.convertAll(patConstructor.constructor(), executionParameters);
// converts input args into a single arg tuple type (PAT semantics)
return new Object[] {patConstructor.constructor().newInstance(convertedArgs)};
diff --git a/commons/src/main/java/org/apache/causeway/commons/io/HashUtils.java b/commons/src/main/java/org/apache/causeway/commons/io/HashUtils.java
index 5df95e39c00..5104d9a66f9 100644
--- a/commons/src/main/java/org/apache/causeway/commons/io/HashUtils.java
+++ b/commons/src/main/java/org/apache/causeway/commons/io/HashUtils.java
@@ -23,7 +23,9 @@
import java.security.DigestInputStream;
import java.security.MessageDigest;
+import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
+
import org.springframework.util.function.ThrowingSupplier;
import org.apache.causeway.commons.functional.Try;
@@ -32,10 +34,7 @@
import lombok.AccessLevel;
import lombok.Getter;
-import org.jspecify.annotations.NonNull;
import lombok.RequiredArgsConstructor;
-import lombok.Value;
-import lombok.experimental.Accessors;
import lombok.experimental.UtilityClass;
/**
@@ -49,21 +48,19 @@
@UtilityClass
public class HashUtils {
- //XXX record candidate
- @Value @Accessors(fluent=true)
- public static class Hash {
- private final String algorithmName;
- private final byte[] bytes;
+ public record Hash(
+ String algorithmName,
+ byte[] _bytes) {
public byte[] bytes() {
// defensive copy
- return bytes!=null
- ? bytes.clone()
+ return _bytes!=null
+ ? _bytes.clone()
: null;
}
public String asHexString() {
- return _Bytes.hexDump(bytes, "");
+ return _Bytes.hexDump(_bytes, "");
}
}
diff --git a/commons/src/main/java/org/apache/causeway/commons/io/ZipUtils.java b/commons/src/main/java/org/apache/causeway/commons/io/ZipUtils.java
index 7ec10bf0052..effbfac689c 100644
--- a/commons/src/main/java/org/apache/causeway/commons/io/ZipUtils.java
+++ b/commons/src/main/java/org/apache/causeway/commons/io/ZipUtils.java
@@ -38,6 +38,7 @@
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
+import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import org.apache.causeway.commons.functional.Try;
@@ -48,12 +49,7 @@
import org.apache.causeway.commons.internal.functions._Predicates;
import lombok.Builder;
-import lombok.Getter;
-import org.jspecify.annotations.NonNull;
-import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
-import lombok.Value;
-import lombok.experimental.Accessors;
import lombok.experimental.UtilityClass;
/**
@@ -64,32 +60,33 @@
@UtilityClass
public class ZipUtils {
- //XXX record candidate
- @Builder
- @Value @Accessors(fluent=true)
- public static class ZipOptions {
- @Builder.Default
- private final int bufferSize = 64*1024; // 64k
- /**
- * The {@link java.nio.charset.Charset charset} to be
- * used to decode the ZIP entry name (ignored if the
- * <a href="package-summary.html#lang_encoding"> language
- * encoding bit</a> of the ZIP entry's general purpose bit
- * flag is set).
- */
- @Builder.Default @NonNull
- private final Charset zipEntryCharset = StandardCharsets.UTF_8;
-
- @Builder.Default @NonNull
- private final Predicate<ZipEntry> zipEntryFilter = _Predicates.alwaysTrue();
+ @Builder()
+ public record ZipOptions(int bufferSize,
+ /**
+ * The {@link java.nio.charset.Charset charset} to be
+ * used to decode the ZIP entry name (ignored if the
+ * <a href="package-summary.html#lang_encoding"> language
+ * encoding bit</a> of the ZIP entry's general purpose bit
+ * flag is set).
+ */
+ @NonNull Charset zipEntryCharset,
+ @NonNull Predicate<ZipEntry> zipEntryFilter
+ ) {
+
+ // canonical constructor
+ public ZipOptions(
+ final int bufferSize,
+ final Charset zipEntryCharset,
+ final Predicate<ZipEntry> zipEntryFilter) {
+ this.bufferSize = bufferSize>0 ? bufferSize : 64*1024; // 64k
+ this.zipEntryCharset = zipEntryCharset!=null ? zipEntryCharset : StandardCharsets.UTF_8;
+ this.zipEntryFilter = zipEntryFilter!=null ? zipEntryFilter : _Predicates.alwaysTrue();
+ }
}
- //XXX record candidate
- @RequiredArgsConstructor
- public static class ZipEntryDataSource implements DataSource {
- @Getter @Accessors(fluent=true)
- private final ZipEntry zipEntry;
- private final byte[] bytes;
+ public record ZipEntryDataSource(
+ ZipEntry zipEntry,
+ byte[] bytes) implements DataSource {
@Override
public <T> Try<T> tryReadAll(final @NonNull Function<InputStream, Try<T>> consumingMapper) {
diff --git a/commons/src/test/java/org/apache/causeway/commons/collections/CanTest.java b/commons/src/test/java/org/apache/causeway/commons/collections/CanTest.java
index eb90f07068f..91feb875bba 100644
--- a/commons/src/test/java/org/apache/causeway/commons/collections/CanTest.java
+++ b/commons/src/test/java/org/apache/causeway/commons/collections/CanTest.java
@@ -29,6 +29,7 @@
import java.util.stream.IntStream;
import java.util.stream.Stream;
+import org.jspecify.annotations.Nullable;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
@@ -40,7 +41,6 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.jspecify.annotations.Nullable;
import org.springframework.util.StringUtils;
import org.apache.causeway.commons.internal.base._NullSafe;
@@ -48,7 +48,6 @@
import org.apache.causeway.commons.internal.testing._SerializationTester;
import lombok.RequiredArgsConstructor;
-import lombok.Value;
class CanTest {
@@ -406,9 +405,7 @@ void subCan_biArg_multiCan() {
// -- TO MAP
- @Value
- static class Customer {
- final String name;
+ static record Customer(String name) {
}
@RequiredArgsConstructor
@@ -424,7 +421,7 @@ int cardinality() {
return customers.size();
}
// simulates a zip-function with nullable result
- @Nullable static String format(Customer customer, int ordinal) {
+ @Nullable static String format(final Customer customer, final int ordinal) {
return StringUtils.hasLength(customer.name)
? String.format("%d->%s", ordinal, customer.name)
: null;
@@ -433,8 +430,8 @@ int cardinality() {
@RequiredArgsConstructor
enum MapScenario {
- HASH_MAP(customers->customers.toMap(Customer::getName)),
- TREE_MAP(customers->customers.toMap(Customer::getName, (a, b)->a, TreeMap::new));
+ HASH_MAP(customers->customers.toMap(Customer::name)),
+ TREE_MAP(customers->customers.toMap(Customer::name, (a, b)->a, TreeMap::new));
final Function<Can<Customer>, Map<String, Customer>> toMapConverterUnderTest;
void assertUnmodifiable(final Map<String, Customer> map) {
assertThrows(Exception.class, ()->{
@@ -548,7 +545,7 @@ void join_withImplicit_toString(final CustomerScenario scenario) {
scenario.customers
.join(", "));
}
-
+
/**
* Tests all {@link Cardinality}(s) on
* {@link Can#join(Function, String) join w/ explicit toString}
@@ -557,11 +554,11 @@ void join_withImplicit_toString(final CustomerScenario scenario) {
@EnumSource(CustomerScenario.class)
void join_withExplicit_toString(final CustomerScenario scenario) {
assertEquals(
- scenario.customers.map(Customer::getName)
+ scenario.customers.map(Customer::name)
.stream()
.collect(Collectors.joining(", ")),
scenario.customers
- .join(Customer::getName, ", "));
+ .join(Customer::name, ", "));
}
// -- HEPER
diff --git a/commons/src/test/java/org/apache/causeway/commons/graph/GraphUtilsTest.java b/commons/src/test/java/org/apache/causeway/commons/graph/GraphUtilsTest.java
index 07d32ec88b3..fa63e076896 100644
--- a/commons/src/test/java/org/apache/causeway/commons/graph/GraphUtilsTest.java
+++ b/commons/src/test/java/org/apache/causeway/commons/graph/GraphUtilsTest.java
@@ -35,13 +35,9 @@
import org.apache.causeway.commons.graph.GraphUtils.NodeFormatter;
import org.apache.causeway.commons.io.TextUtils;
-import lombok.Value;
-
class GraphUtilsTest {
- @Value
- static class Customer {
- String name;
+ record Customer(String name) {
}
@Test
@@ -57,7 +53,7 @@ void builderDirected() {
.addEdge(2, 0);
var graph = gBuilder.build();
- var textForm = graph.toString(Customer::getName);
+ var textForm = graph.toString(Customer::name);
//debug
//System.err.println(textForm);
@@ -80,7 +76,7 @@ void builderUndirected() {
.addEdge(2, 0);
var graph = gBuilder.build();
- var textForm = graph.toString(Customer::getName);
+ var textForm = graph.toString(Customer::name);
//debug
//System.err.println(textForm);
@@ -136,7 +132,7 @@ void builderWithEdgeAttributes() {
var graph = gBuilder.build();
var textForm = graph.toString(
- NodeFormatter.of(Customer::getName),
+ NodeFormatter.of(Customer::name),
edgeAttr->String.format("(weight=%.1f)", (double)edgeAttr));
//debug
//System.err.println(textForm);
@@ -162,9 +158,9 @@ void builderWithAdvancedEdgeAdding() {
var graph = gBuilder
.build()
- .sorted(Comparator.comparing(Customer::getName)); // test sorting
+ .sorted(Comparator.comparing(Customer::name)); // test sorting
var textForm = graph.toString(
- NodeFormatter.of(Customer::getName),
+ NodeFormatter.of(Customer::name),
edgeAttr->String.format("(weight=%.1f)", (double)edgeAttr));
//debug
//System.err.println(textForm);
@@ -215,9 +211,9 @@ void filterDirectedGraph() {
.addEdge(1, 2) // B -> C
.addEdge(2, 0, 0.7) // C -> A (weight=0.7)
.build()
- .filter(node->!node.getName().equals("C")); // now remove C
+ .filter(node->!node.name().equals("C")); // now remove C
- var textForm = graph.toString(Customer::getName);
+ var textForm = graph.toString(Customer::name);
//debug
//System.err.println(textForm);
@@ -240,11 +236,11 @@ void filterUndirectedGraph() {
.addEdge(c, b, 0.7) // B - C (weight=0.7)
.addNode(d)
.build()
- .filter(node->!node.getName().equals("C")) // now remove C
+ .filter(node->!node.name().equals("C")) // now remove C
;
var textForm = graph.toString(
- NodeFormatter.of(Customer::getName),
+ NodeFormatter.of(Customer::name),
edgeAttr->String.format("(weight=%.1f)", (double)edgeAttr));
//debug
//System.err.println(textForm);
diff --git a/commons/src/test/java/org/apache/causeway/commons/internal/reflection/_Expectations.java b/commons/src/test/java/org/apache/causeway/commons/internal/reflection/_Expectations.java
index 28e817e5008..5bdb87dd768 100644
--- a/commons/src/test/java/org/apache/causeway/commons/internal/reflection/_Expectations.java
+++ b/commons/src/test/java/org/apache/causeway/commons/internal/reflection/_Expectations.java
@@ -27,16 +27,15 @@
import lombok.Builder;
-@lombok.Value @Builder
-public class _Expectations {
-
- int methodCount;
- int syntheticCount;
- int bridgeCount;
- /**
- * short notation see {@link _MethodSummaryUtil}
- */
- String methodNameOrdinals;
+@Builder
+public record _Expectations(
+ int methodCount,
+ int syntheticCount,
+ int bridgeCount,
+ /**
+ * short notation see {@link _MethodSummaryUtil}
+ */
+ String methodNameOrdinals) {
_Expectations actual(final Can<ResolvedMethod> methods) {
return _Expectations.builder()
diff --git a/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java b/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java
index 5ddd1695251..92a88f3aae4 100644
--- a/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java
+++ b/core/config/src/main/java/org/apache/causeway/core/config/CausewayConfiguration.java
@@ -107,7 +107,6 @@
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
-import lombok.Value;
/**
* Configuration 'beans' with meta-data (IDE-support).
@@ -229,8 +228,8 @@ public static class Spring {
* Setting this option to {@literal true} allows {@code CsrfFilter}(s) to be
* configured. Yet EXPERIMENTAL.
*
- * @see <code>org.springframework.security.web.csrf.CsrfFilter</code>
- * @see "https://www.baeldung.com/spring-security-registered-filters"
+ * @see org.springframework.security.web.csrf.CsrfFilter
+ * @see <a href="https://www.baeldung.com/spring-security-registered-filters">baeldung</a>
*/
private boolean allowCsrfFilters = false;
@@ -4586,24 +4585,22 @@ private static List<String> listOf(final String ...values) {
return new ArrayList<>(Arrays.asList(values));
}
- @Value
- static class PatternToString {
- private final Pattern pattern;
- private final String string;
+ record PatternToString(
+ Pattern pattern,
+ String string) {
}
private static Map<Pattern, String> asMap(final String... mappings) {
return new LinkedHashMap<>(_NullSafe.stream(mappings).map(mapping -> {
final String[] parts = mapping.split(":");
- if (parts.length != 2) {
- return null;
- }
+ if (parts.length != 2) return null;
+
try {
return new PatternToString(Pattern.compile(parts[0], Pattern.CASE_INSENSITIVE), parts[1]);
} catch(Exception ex) {
return null;
}
}).filter(Objects::nonNull)
- .collect(Collectors.toMap(PatternToString::getPattern, PatternToString::getString)));
+ .collect(Collectors.toMap(PatternToString::pattern, PatternToString::string)));
}
@Target({ FIELD, METHOD, PARAMETER, ANNOTATION_TYPE })
diff --git a/core/config/src/main/java/org/apache/causeway/core/config/datasources/DataSourceIntrospectionService.java b/core/config/src/main/java/org/apache/causeway/core/config/datasources/DataSourceIntrospectionService.java
index b1be6e671ce..b4826b86d19 100644
--- a/core/config/src/main/java/org/apache/causeway/core/config/datasources/DataSourceIntrospectionService.java
+++ b/core/config/src/main/java/org/apache/causeway/core/config/datasources/DataSourceIntrospectionService.java
@@ -29,6 +29,8 @@
import jakarta.annotation.Priority;
import jakarta.inject.Named;
+import org.jspecify.annotations.NonNull;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
@@ -38,9 +40,7 @@
import org.apache.causeway.commons.internal.base._Lazy;
import org.apache.causeway.core.config.CausewayModuleCoreConfig;
-import org.jspecify.annotations.NonNull;
import lombok.SneakyThrows;
-import lombok.Value;
import lombok.extern.log4j.Log4j2;
/**
@@ -61,9 +61,7 @@ public class DataSourceIntrospectionService {
@Autowired(required = false)
private List<DataSource> dataSources;
- @Value
- public static class DataSourceInfo {
- private final String jdbcUrl;
+ public record DataSourceInfo(String jdbcUrl) {
@SneakyThrows
private static DataSourceInfo fromMetaData(final @NonNull DatabaseMetaData databaseMetaData) {
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/consent/Consent.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/consent/Consent.java
index 11f0947afe0..fbb95181e90 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/consent/Consent.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/consent/Consent.java
@@ -24,20 +24,19 @@
import java.util.Optional;
import java.util.stream.Collectors;
+import org.jspecify.annotations.NonNull;
+
import org.apache.causeway.commons.internal.assertions._Assert;
import org.apache.causeway.commons.internal.base._Strings;
import org.apache.causeway.commons.internal.primitives._Ints;
import org.apache.causeway.core.metamodel.facets.object.immutable.ImmutableFacet;
-import org.jspecify.annotations.NonNull;
-import lombok.experimental.Accessors;
-
public interface Consent {
- //XXX record candidate
- @lombok.Value @Accessors(fluent=true)
- public static class VetoReason implements Serializable {
- private static final long serialVersionUID = 1L;
+ public record VetoReason(
+ VetoOriging vetoOriging,
+ UiHint uiHint,
+ @NonNull String string) implements Serializable {
/**
* Introduced to help pick a winner when merging 2 {@link VetoReason}(s).
@@ -87,9 +86,7 @@ static UiHint reduceToMaxOrdinal(final UiHint a, final UiHint b) {
return b.ordinal()>a.ordinal() ? b : a;
}
}
- private final VetoOriging vetoOriging;
- private final UiHint uiHint;
- private final @NonNull String string;
+
private static VetoReason of(
final @NonNull VetoOriging vetoOriging,
final @NonNull UiHint uiHint,
@@ -107,7 +104,7 @@ private static VetoReason inferred(final String reason) {
return of(VetoOriging.PROGRAMMING_MODEL, UiHint.NO_ICON_UNLESS_PROTOTYPING, reason);
}
- VetoReason withAdvisorAsDiagnostic(Object advisor) {
+ VetoReason withAdvisorAsDiagnostic(final Object advisor) {
return new VetoReason(this.vetoOriging, this.uiHint, this.string + " {" + advisor.getClass().getSimpleName() + "} ");
}
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/value/ValueFacetAbstract.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/value/ValueFacetAbstract.java
index 1699e59a33e..c56f432454a 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/value/ValueFacetAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/object/value/ValueFacetAbstract.java
@@ -122,7 +122,7 @@ public ValueSemanticsProvider.Context createValueSemanticsContext(final @Nullabl
if(iaProvider==null) {
return null; // JUnit context
}
- return ValueSemanticsProvider.Context.of(
+ return new ValueSemanticsProvider.Context(
feature!=null
? feature.getFeatureIdentifier()
: null,
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/specloader/validator/ValidationFailure.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/specloader/validator/ValidationFailure.java
index b820157f6b8..7c85c55859a 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/specloader/validator/ValidationFailure.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/specloader/validator/ValidationFailure.java
@@ -29,18 +29,13 @@
import org.apache.causeway.core.metamodel.specloader.SpecificationLoader;
import org.jspecify.annotations.NonNull;
-import lombok.Value;
/**
- *
* @since 2.0
- *
*/
-@Value(staticConstructor = "of")
-public final class ValidationFailure implements Comparable<ValidationFailure> {
-
- @NonNull private Identifier origin;
- @NonNull private String message;
+public record ValidationFailure(
+ @NonNull Identifier origin,
+ @NonNull String message) implements Comparable<ValidationFailure> {
// -- FACTORIES
@@ -52,7 +47,7 @@ public static void raise(
final @NonNull Identifier deficiencyOrigin,
final @NonNull String deficiencyMessage) {
- specLoader.addValidationFailure(ValidationFailure.of(deficiencyOrigin, deficiencyMessage));
+ specLoader.addValidationFailure(new ValidationFailure(deficiencyOrigin, deficiencyMessage));
}
/**
@@ -76,9 +71,9 @@ public static void raiseFormatted(
}
private static final Comparator<ValidationFailure> comparator = Comparator
- .<ValidationFailure, String>comparing(failure->failure.getOrigin().className(), nullsFirst(naturalOrder()))
- .<String>thenComparing(failure->failure.getOrigin().memberLogicalName(), nullsFirst(naturalOrder()))
- .thenComparing(ValidationFailure::getMessage);
+ .<ValidationFailure, String>comparing(failure->failure.origin().className(), nullsFirst(naturalOrder()))
+ .<String>thenComparing(failure->failure.origin().memberLogicalName(), nullsFirst(naturalOrder()))
+ .thenComparing(ValidationFailure::message);
// -- CONTRACT
@@ -97,15 +92,8 @@ public int hashCode() {
@Override
public int compareTo(final ValidationFailure o) {
-
- if(equals(o)) {
- return 0; // for consistency with equals
- }
-
- if(o==null) {
- return -1; // null last policy
- }
-
+ if(equals(o)) return 0; // for consistency with equals
+ if(o==null) return -1; // null last policy
return comparator.compare(this, o);
}
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/specloader/validator/ValidationFailures.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/specloader/validator/ValidationFailures.java
index 2ccdf474104..65f6d5b2a42 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/specloader/validator/ValidationFailures.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/specloader/validator/ValidationFailures.java
@@ -36,7 +36,7 @@ public final class ValidationFailures implements Iterable<ValidationFailure> {
public void add(final Identifier origin, final String pattern, final Object... arguments) {
var message = String.format(pattern, arguments);
- failures.add(ValidationFailure.of(origin, message));
+ failures.add(new ValidationFailure(origin, message));
}
public void addAll(final Iterable<ValidationFailure> failures) {
@@ -59,7 +59,7 @@ public Set<ValidationFailure> getFailures() {
public ArrayList<String> getMessages() { // <-- ensure serializable result
var messages = failures.stream() // already sorted
- .map(ValidationFailure::getMessage)
+ .map(ValidationFailure::message)
.collect(Collectors.toCollection(ArrayList::new));
return messages;
}
@@ -70,7 +70,7 @@ public ArrayList<String> getMessages() { // <-- ensure serializable result
public ArrayList<String> getMessages(final String messageFormat) { // <-- ensure serializable result
var messages = _Lists.<String>newArrayList();
failures.stream() // already sorted
- .map(ValidationFailure::getMessage)
+ .map(ValidationFailure::message)
.map(msg->String.format(messageFormat, messages.size()+1, msg))
.forEach(messages::add);
return messages;
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/valuesemantics/BigDecimalValueSemantics.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/valuesemantics/BigDecimalValueSemantics.java
index 227b899c92f..6e9b17db5d7 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/valuesemantics/BigDecimalValueSemantics.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/valuesemantics/BigDecimalValueSemantics.java
@@ -136,7 +136,7 @@ public BigDecimal parseTextRepresentation(final ValueSemanticsProvider.Context c
.orElse(null);
}
- private boolean isUseGroupingSeparatorFrom(CausewayConfiguration.ValueTypes.BigDecimal bigDecimalConfig) {
+ private boolean isUseGroupingSeparatorFrom(final CausewayConfiguration.ValueTypes.BigDecimal bigDecimalConfig) {
return bigDecimalConfig.getEditing().isUseGroupingSeparator() || bigDecimalConfig.isUseGroupingSeparator();
}
@@ -156,15 +156,11 @@ protected void configureDecimalFormat(
: bigDecimalConfig.getDisplay().isUseGroupingSeparator()
);
- if(context==null) {
- return;
- }
+ if(context==null) return;
- var feature = specificationLoader.loadFeature(context.getFeatureIdentifier())
+ var feature = specificationLoader.loadFeature(context.featureIdentifier())
.orElse(null);
- if(feature==null) {
- return;
- }
+ if(feature==null) return;
// evaluate any facets that provide the MaximumFractionDigits
Facets.maxFractionalDigits(feature)
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/valuesemantics/LocaleValueSemantics.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/valuesemantics/LocaleValueSemantics.java
index e999d3f5c13..8f2b61e6ea3 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/valuesemantics/LocaleValueSemantics.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/valuesemantics/LocaleValueSemantics.java
@@ -80,17 +80,13 @@ public String htmlPresentation(final ValueSemanticsProvider.Context context, fin
}
private String localeToString(final ValueSemanticsProvider.Context context, final Locale value) {
- var userLanguageLocale = context.getInteractionContext().getLocale().languageLocale();
+ var userLanguageLocale = context.interactionContext().getLocale().languageLocale();
var language = value.getDisplayLanguage(userLanguageLocale);
- if(_Strings.isEmpty(language)) {
- return stringify(value);
- }
+ if(_Strings.isEmpty(language)) return stringify(value);
var country = value.getDisplayCountry(userLanguageLocale);
- if(_Strings.isEmpty(country)) {
- return language;
- }
+ if(_Strings.isEmpty(country)) return language;
return String.format("%s (%s)",
value.getDisplayLanguage(userLanguageLocale),
diff --git a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/valuesemantics/temporal/TemporalValueSemanticsProvider.java b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/valuesemantics/temporal/TemporalValueSemanticsProvider.java
index 4a6175317e5..2f2cc66383f 100644
--- a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/valuesemantics/temporal/TemporalValueSemanticsProvider.java
+++ b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/valuesemantics/temporal/TemporalValueSemanticsProvider.java
@@ -311,17 +311,17 @@ protected Function<T, String> getRenderingFormatter(
* In other words, this conversion preserves the time {@link Instant}.
*/
private Temporal translateToUserLocalTimeZone(final ValueSemanticsProvider.Context context, final Temporal t) {
- if(t instanceof ZonedDateTime) {
- return _Temporals.translateToTimeZone((ZonedDateTime) t,
- context.getInteractionContext().getTimeZone());
+ if(t instanceof ZonedDateTime zonedDateTime) {
+ return _Temporals.translateToTimeZone(zonedDateTime,
+ context.interactionContext().getTimeZone());
}
- if(t instanceof OffsetDateTime) {
- return _Temporals.translateToTimeZone((OffsetDateTime) t,
- context.getInteractionContext().getTimeZone());
+ if(t instanceof OffsetDateTime offsetDateTime) {
+ return _Temporals.translateToTimeZone(offsetDateTime,
+ context.interactionContext().getTimeZone());
}
- if(t instanceof OffsetTime) {
- return _Temporals.translateToTimeOffset((OffsetTime) t,
- context.getInteractionContext().getTimeZoneOffsetNow());
+ if(t instanceof OffsetTime offsetTime) {
+ return _Temporals.translateToTimeOffset(offsetTime,
+ context.interactionContext().getTimeZoneOffsetNow());
}
return t; // otherwise acts as identity operator
}
@@ -387,7 +387,7 @@ static DateAndTimeFormatStyle forContext(
.map(MetaModelContext::getSpecificationLoader)
.flatMap(specLoader->specLoader.loadFeature(
Optional.ofNullable(context)
- .map(ValueSemanticsProvider.Context::getFeatureIdentifier)
+ .map(ValueSemanticsProvider.Context::featureIdentifier)
.orElse(null)));
// DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofLocalizedPattern(mmc.getConfiguration().getValueTypes().getTemporal().getDisplay().getDatePattern());
diff --git a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/value/JavaTimeValueSemanticsProviderTest.java b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/value/JavaTimeValueSemanticsProviderTest.java
index ad28bd5bea6..0d01411a51a 100644
--- a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/value/JavaTimeValueSemanticsProviderTest.java
+++ b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/facets/value/JavaTimeValueSemanticsProviderTest.java
@@ -62,14 +62,14 @@ void invalidParse() {
@Test
void rendering() {
setSemantics(valueSemantics = createValueSemantics(TimePrecision.SECOND));
- var _context = Context.of(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
+ var _context = new Context(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
assertEquals("Mar 13, 2013, 5:59:03 PM", valueSemantics.titlePresentation(_context , date));
}
@Test // support omitted parts on input
void parseNoMinutes() {
setSemantics(valueSemantics = createValueSemantics(TimePrecision.SECOND));
- var _context = Context.of(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
+ var _context = new Context(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
var parsedDate = valueSemantics.parseTextRepresentation(_context, "2013-03-13 17");
assertEquals(date.getTime() - 3540_000L - 3000L, parsedDate.getTime());
}
@@ -77,7 +77,7 @@ void parseNoMinutes() {
@Test // support omitted parts on input
void parseNoSeconds() {
setSemantics(valueSemantics = createValueSemantics(TimePrecision.SECOND));
- var _context = Context.of(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
+ var _context = new Context(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
var parsedDate = valueSemantics.parseTextRepresentation(_context, "2013-03-13 17:59");
assertEquals(date.getTime() - 3000L, parsedDate.getTime());
}
@@ -85,7 +85,7 @@ void parseNoSeconds() {
@Test
void parseSeconds() {
setSemantics(valueSemantics = createValueSemantics(TimePrecision.SECOND));
- var _context = Context.of(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
+ var _context = new Context(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
var parsedDate = valueSemantics.parseTextRepresentation(_context, "2013-03-13 17:59:03");
assertEquals(date.getTime(), parsedDate.getTime());
}
@@ -93,7 +93,7 @@ void parseSeconds() {
@Test
void parseMillis() {
setSemantics(valueSemantics = createValueSemantics(TimePrecision.MILLI_SECOND));
- var _context = Context.of(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
+ var _context = new Context(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
var parsedDate = valueSemantics.parseTextRepresentation(_context, "2013-03-13 17:59:03.123");
assertEquals(date.getTime() + 123L, parsedDate.getTime());
}
@@ -101,7 +101,7 @@ void parseMillis() {
@Test
void parseMicros() {
setSemantics(valueSemantics = createValueSemantics(TimePrecision.MICRO_SECOND));
- var _context = Context.of(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
+ var _context = new Context(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
var parsedDate = valueSemantics.parseTextRepresentation(_context, "2013-03-13 17:59:03.123456");
assertEquals(date.getTime() + 123L, parsedDate.getTime());
}
@@ -109,7 +109,7 @@ void parseMicros() {
@Test
void parseNanos() {
setSemantics(valueSemantics = createValueSemantics(TimePrecision.NANO_SECOND));
- var _context = Context.of(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
+ var _context = new Context(null, InteractionContext.builder().locale(UserLocale.valueOf(Locale.ENGLISH)).build());
var parsedDate = valueSemantics.parseTextRepresentation(_context, "2013-03-13 17:59:03.123456789");
assertEquals(date.getTime() + 123L, parsedDate.getTime());
}
diff --git a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/valuesemantics/BigDecimalValueSemanticsProvider_configureDecimalFormat_Test.java b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/valuesemantics/BigDecimalValueSemanticsProvider_configureDecimalFormat_Test.java
index ebc09e47bc1..86a1b5d95db 100644
--- a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/valuesemantics/BigDecimalValueSemanticsProvider_configureDecimalFormat_Test.java
+++ b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/valuesemantics/BigDecimalValueSemanticsProvider_configureDecimalFormat_Test.java
@@ -55,7 +55,7 @@ class BigDecimalValueSemanticsProvider_configureDecimalFormat_Test {
@BeforeEach
void setUpObjects() throws Exception {
- context = ValueSemanticsProvider.Context.of(mockIdentifier, null);
+ context = new ValueSemanticsProvider.Context(mockIdentifier, null);
causewayConfiguration = CausewayConfiguration.builder().build();
causewayConfiguration.getValueTypes().getBigDecimal().setMinScale(null);
diff --git a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/valuesemantics/IdStringifierForSerializable_Test.java b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/valuesemantics/IdStringifierForSerializable_Test.java
index 1056a69ac77..1facb53f69a 100644
--- a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/valuesemantics/IdStringifierForSerializable_Test.java
+++ b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/valuesemantics/IdStringifierForSerializable_Test.java
@@ -31,19 +31,15 @@
import org.apache.causeway.applib.services.urlencoding.UrlEncodingService;
-import lombok.Value;
-
class IdStringifierForSerializable_Test {
private UrlEncodingService codec = UrlEncodingService.forTesting();
// -- SCENARIO
- @Value
- static class CustomerPK implements Serializable{
- private static final long serialVersionUID = 1L;
- final int lower;
- final int upper;
+ static record CustomerPK(
+ int lower,
+ int upper) implements Serializable{
}
// -- TEST
diff --git a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/executor/_Xray.java b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/executor/_Xray.java
index 113496924d2..2fd4893d65c 100644
--- a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/executor/_Xray.java
+++ b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/executor/_Xray.java
@@ -95,10 +95,10 @@ private static SequenceHandle enterInvocation(
sequenceData.alias("executor", "Member-\nExecutorService-\n(Default)");
- var callee1 = handle.getCallees().getFirstElseFail();
- var callee2 = handle.getCallees().getLastElseFail();
+ var callee1 = handle.callees().getFirstElseFail();
+ var callee2 = handle.callees().getLastElseFail();
- sequenceData.enter(handle.getCaller(), callee1);
+ sequenceData.enter(handle.caller(), callee1);
sequenceData.activate(callee1);
sequenceData.enter(callee1, callee2, enteringLabel);
@@ -118,13 +118,13 @@ static void exitInvocation(final @Nullable SequenceHandle handle) {
handle.submit(sequenceData->{
- var callee1 = handle.getCallees().getFirstElseFail();
- var callee2 = handle.getCallees().getLastElseFail();
+ var callee1 = handle.callees().getFirstElseFail();
+ var callee2 = handle.callees().getLastElseFail();
sequenceData.exit(callee2, callee1);
sequenceData.deactivate(callee2);
- sequenceData.exit(callee1, handle.getCaller());
+ sequenceData.exit(callee1, handle.caller());
sequenceData.deactivate(callee1);
});
diff --git a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/publish/_Xray.java b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/publish/_Xray.java
index 05a67aa4e13..4d50a0fdea1 100644
--- a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/publish/_Xray.java
+++ b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/publish/_Xray.java
@@ -74,7 +74,7 @@ static SequenceHandle enterCommandCompletedPublishing(
return enterCommandPublishing(iaTracker, command, enabledSubscribers, cannotPublishReasonSupplier, "completed");
}
- private static SequenceHandle enterCommandPublishing(InteractionLayerTracker iaTracker, Command command, Can<CommandSubscriber> enabledSubscribers, Supplier<String> cannotPublishReasonSupplier, String verb) {
+ private static SequenceHandle enterCommandPublishing(final InteractionLayerTracker iaTracker, final Command command, final Can<CommandSubscriber> enabledSubscribers, final Supplier<String> cannotPublishReasonSupplier, final String verb) {
if(!XrayUi.isXrayEnabled()) {
return null;
}
@@ -100,8 +100,8 @@ private static SequenceHandle enterCommandPublishing(InteractionLayerTracker iaT
sequenceData.setConnectionLabelColor(Color.GRAY);
}
- var callee = handle.getCallees().getFirstElseFail();
- sequenceData.enter(handle.getCaller(), callee, enteringLabel);
+ var callee = handle.callees().getFirstElseFail();
+ sequenceData.enter(handle.caller(), callee, enteringLabel);
sequenceData.activate(callee);
});
@@ -142,8 +142,8 @@ public static SequenceHandle enterExecutionPublishing(
sequenceData.setConnectionLabelColor(Color.GRAY);
}
- var callee = handle.getCallees().getFirstElseFail();
- sequenceData.enter(handle.getCaller(), callee, enteringLabel);
+ var callee = handle.callees().getFirstElseFail();
+ sequenceData.enter(handle.caller(), callee, enteringLabel);
sequenceData.activate(callee);
});
@@ -185,8 +185,8 @@ public static SequenceHandle enterEntityChangesPublishing(
sequenceData.setConnectionLabelColor(Color.GRAY);
}
- var callee = handle.getCallees().getFirstElseFail();
- sequenceData.enter(handle.getCaller(), callee, enteringLabel);
+ var callee = handle.callees().getFirstElseFail();
+ sequenceData.enter(handle.caller(), callee, enteringLabel);
sequenceData.activate(callee);
});
@@ -228,8 +228,8 @@ public static SequenceHandle enterEntityPropertyChangePublishing(
sequenceData.setConnectionLabelColor(Color.GRAY);
}
- var callee = handle.getCallees().getFirstElseFail();
- sequenceData.enter(handle.getCaller(), callee, enteringLabel);
+ var callee = handle.callees().getFirstElseFail();
+ sequenceData.enter(handle.caller(), callee, enteringLabel);
sequenceData.activate(callee);
});
@@ -248,8 +248,8 @@ public static void exitPublishing(final @Nullable SequenceHandle handle) {
}
handle.submit(sequenceData->{
- var callee = handle.getCallees().getFirstElseFail();
- sequenceData.exit(callee, handle.getCaller());
+ var callee = handle.callees().getFirstElseFail();
+ sequenceData.exit(callee, handle.caller());
sequenceData.deactivate(callee);
sequenceData.setConnectionArrowColor(null);
@@ -260,23 +260,23 @@ public static void exitPublishing(final @Nullable SequenceHandle handle) {
// -- HELPER
- static String toText(Command command) {
+ static String toText(final Command command) {
return _Text.breakLines(Can.of(command.toString()), 80)
.stream()
.collect(Collectors.joining("\n "));
}
- static String toText(Execution<?, ?> execution) {
+ static String toText(final Execution<?, ?> execution) {
//TODO
return execution.toString();
}
- static String toText(EntityChanges changes) {
+ static String toText(final EntityChanges changes) {
//TODO
return changes.toString();
}
- static String toText(Can<EntityPropertyChange> changes) {
+ static String toText(final Can<EntityPropertyChange> changes) {
//TODO
return changes.toString();
}
diff --git a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/session/InteractionServiceDefault.java b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/session/InteractionServiceDefault.java
index 2d3a9c2d2e0..a84be23af0d 100644
--- a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/session/InteractionServiceDefault.java
+++ b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/session/InteractionServiceDefault.java
@@ -154,7 +154,7 @@ public void init(final ContextRefreshedEvent event) {
} else {
log.error("### Validation FAILED, failure count: {}", validationResult.getNumberOfFailures());
validationResult.forEach(failure->{
- log.error("# " + failure.getMessage());
+ log.error("# " + failure.message());
});
//throw _Exceptions.unrecoverable("Validation FAILED");
}
diff --git a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/session/_Xray.java b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/session/_Xray.java
index 8e7547b3cfe..69998332b5f 100644
--- a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/session/_Xray.java
+++ b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/session/_Xray.java
@@ -65,7 +65,7 @@ static void newInteractionLayer(final Stack<InteractionLayer> afterEnter) {
new XrayDataModel.Sequence(sequenceId, iaLabel))
.getData();
- sequenceData.alias("thread", threadId.getMultilinelabel());
+ sequenceData.alias("thread", threadId.multilinelabel());
sequenceData.alias(uiInteractionId, iaLabelMultiline);
sequenceData.enter("thread", uiInteractionId, iaOpeningLabel);
diff --git a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/transaction/TransactionServiceSpring.java b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/transaction/TransactionServiceSpring.java
index 38da8ccd999..8be8858ce6b 100644
--- a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/transaction/TransactionServiceSpring.java
+++ b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/transaction/TransactionServiceSpring.java
@@ -28,6 +28,8 @@
import jakarta.inject.Named;
import jakarta.inject.Provider;
+import org.jspecify.annotations.NonNull;
+
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@@ -59,9 +61,7 @@
import org.apache.causeway.core.runtimeservices.CausewayModuleCoreRuntimeServices;
import org.apache.causeway.core.transaction.events.TransactionCompletionStatus;
-import org.jspecify.annotations.NonNull;
import lombok.RequiredArgsConstructor;
-import lombok.Value;
import lombok.extern.log4j.Log4j2;
/**
@@ -423,7 +423,6 @@ public void requestRollback(final @NonNull CausewayInteraction interaction) {
* @param interaction The {@link CausewayInteraction} object representing the current interaction.
*/
public void onClose(final @NonNull CausewayInteraction interaction) {
-
if (log.isDebugEnabled()) {
log.debug("closing on {}", _Probe.currentThreadId());
}
@@ -436,11 +435,10 @@ public void onClose(final @NonNull CausewayInteraction interaction) {
txCounter.remove(); //XXX not tested yet: can we be certain that no txCounter.get() is called afterwards?
}
- @Value
- private static class CloseTask {
- @NonNull TransactionStatus txStatus;
- @NonNull String onErrorInfo;
- @NonNull ThrowingRunnable runnable;
+ private record CloseTask(
+ @NonNull TransactionStatus txStatus,
+ @NonNull String onErrorInfo,
+ @NonNull ThrowingRunnable runnable) {
}
@RequiredArgsConstructor
@@ -455,13 +453,13 @@ void runOnCloseTasks() {
onCloseTasks.forEach(onCloseTask->{
try {
- onCloseTask.getRunnable().run();
+ onCloseTask.runnable().run();
} catch(final Throwable ex) {
// ignore
log.error(
"failed to close transactional boundary using transaction-manager {}; "
+ "continuing to avoid memory leakage",
- onCloseTask.getOnErrorInfo(),
+ onCloseTask.onErrorInfo(),
ex);
}
});
diff --git a/core/security/src/main/java/org/apache/causeway/core/security/util/XrayUtil.java b/core/security/src/main/java/org/apache/causeway/core/security/util/XrayUtil.java
index cbef4d25eab..d6a4f70c943 100644
--- a/core/security/src/main/java/org/apache/causeway/core/security/util/XrayUtil.java
+++ b/core/security/src/main/java/org/apache/causeway/core/security/util/XrayUtil.java
@@ -30,9 +30,8 @@
import lombok.Builder;
import org.jspecify.annotations.NonNull;
-import lombok.Value;
-public final class XrayUtil {
+public record XrayUtil() {
/**
* Returns the sequence diagram data model's id, that is bound to the current thread and interaction.
@@ -76,15 +75,15 @@ public static Optional<SequenceHandle> createSequenceHandle(
}
- @Value @Builder
- public static final class SequenceHandle {
- final @NonNull String sequenceId;
- final @NonNull String caller;
- final @NonNull Can<String> callees;
+ @Builder
+ public record SequenceHandle(
+ @NonNull String sequenceId,
+ @NonNull String caller,
+ @NonNull Can<String> callees) {
public void submit(final Consumer<SequenceDiagram> onSubmission) {
XrayUi.updateModel(model->{
- model.lookupSequence(getSequenceId())
+ model.lookupSequence(sequenceId())
.ifPresent(sequence->onSubmission.accept(sequence.getData()));
});
}
diff --git a/core/webapp/src/main/java/org/apache/causeway/core/webapp/confmenu/ConfigurationViewServiceDefault.java b/core/webapp/src/main/java/org/apache/causeway/core/webapp/confmenu/ConfigurationViewServiceDefault.java
index 28e0bbb0866..ec94c031d8d 100644
--- a/core/webapp/src/main/java/org/apache/causeway/core/webapp/confmenu/ConfigurationViewServiceDefault.java
+++ b/core/webapp/src/main/java/org/apache/causeway/core/webapp/confmenu/ConfigurationViewServiceDefault.java
@@ -200,7 +200,7 @@ private Map<String, ConfigurationProperty> loadPrimary(final List<String> primar
dsInfos.forEach(IndexedConsumer.offset(1, (index, dataSourceInfo)->{
add(String.format("Data Source (%d/%d)", index, dsInfos.size()),
- dataSourceInfo.getJdbcUrl(),
+ dataSourceInfo.jdbcUrl(),
map);
}));
diff --git a/core/webapp/src/main/java/org/apache/causeway/core/webapp/webappctx/CausewayWebAppContextInitializer.java b/core/webapp/src/main/java/org/apache/causeway/core/webapp/webappctx/CausewayWebAppContextInitializer.java
index a4955b97c1c..4ce30754917 100644
--- a/core/webapp/src/main/java/org/apache/causeway/core/webapp/webappctx/CausewayWebAppContextInitializer.java
+++ b/core/webapp/src/main/java/org/apache/causeway/core/webapp/webappctx/CausewayWebAppContextInitializer.java
@@ -37,8 +37,6 @@
import org.apache.causeway.core.webapp.modules.WebModule;
import org.apache.causeway.core.webapp.modules.WebModuleContext;
-import org.jspecify.annotations.NonNull;
-import lombok.Value;
import lombok.extern.log4j.Log4j2;
/**
@@ -97,7 +95,7 @@ public void onStartup(final ServletContext servletContext) throws ServletExcepti
log.info("=== PHASE 2 === Initializing the ServletContext");
webModuleContext.init();
- servletContext.addListener(new ShutdownHook(webModuleContext));
+ servletContext.addListener(new ShutdownHook(this, webModuleContext));
log.info("=== DONE === ServletContext initialized.");
@@ -114,13 +112,13 @@ public void contextDestroyed(final WebModuleContext webModuleContext, final Serv
// -- HELPER
- @Value
- private class ShutdownHook implements EventListener, ServletContextListener {
- @NonNull WebModuleContext webModuleContext;
+ private record ShutdownHook(
+ CausewayWebAppContextInitializer self,
+ WebModuleContext webModuleContext) implements EventListener, ServletContextListener {
@Override
public void contextDestroyed(final ServletContextEvent sce) {
- CausewayWebAppContextInitializer.this.contextDestroyed(webModuleContext, sce);
+ self.contextDestroyed(webModuleContext, sce);
}
}
diff --git a/extensions/vw/fullcalendar/applib/src/main/java/org/apache/causeway/extensions/fullcalendar/applib/value/CalendarEventSemantics.java b/extensions/vw/fullcalendar/applib/src/main/java/org/apache/causeway/extensions/fullcalendar/applib/value/CalendarEventSemantics.java
index d0283421627..40473ec794b 100644
--- a/extensions/vw/fullcalendar/applib/src/main/java/org/apache/causeway/extensions/fullcalendar/applib/value/CalendarEventSemantics.java
+++ b/extensions/vw/fullcalendar/applib/src/main/java/org/apache/causeway/extensions/fullcalendar/applib/value/CalendarEventSemantics.java
@@ -159,7 +159,7 @@ public String htmlPresentation(final Context context, final CalendarEvent value)
"calendar-name", v.getCalendarName(),
"timestamp", zonedDateTimeValueSemantics
.htmlPresentation(context,
- v.asDateTime(context.getInteractionContext().getTimeZone())),
+ v.asDateTime(context.interactionContext().getTimeZone())),
"notes", _Strings.nullToEmpty(v.getNotes()));
}
@@ -171,7 +171,7 @@ public String htmlPresentation(final Context context, final CalendarEvent value)
"calendar-name", _Strings.htmlEscape(v.getCalendarName()),
"timestamp", zonedDateTimeValueSemantics
.htmlPresentation(context,
- v.asDateTime(context.getInteractionContext().getTimeZone())),
+ v.asDateTime(context.interactionContext().getTimeZone())),
"notes", _Strings.htmlEscape(_Strings.nullToEmpty(v.getNotes())));
}
diff --git a/persistence/commons/src/main/java/org/apache/causeway/persistence/commons/integration/changetracking/_Xray.java b/persistence/commons/src/main/java/org/apache/causeway/persistence/commons/integration/changetracking/_Xray.java
index 46aa52a3b06..80b4fed10c1 100644
--- a/persistence/commons/src/main/java/org/apache/causeway/persistence/commons/integration/changetracking/_Xray.java
+++ b/persistence/commons/src/main/java/org/apache/causeway/persistence/commons/integration/changetracking/_Xray.java
@@ -57,8 +57,8 @@ public static void publish(
sequenceData.setConnectionLabelColor(Color.GRAY);
}
- var callee = handle.getCallees().getFirstElseFail();
- sequenceData.enter(handle.getCaller(), callee, enteringLabel);
+ var callee = handle.callees().getFirstElseFail();
+ sequenceData.enter(handle.caller(), callee, enteringLabel);
//sequenceData.activate(callee);
});
@@ -117,8 +117,8 @@ private static void addSequence(
sequenceData.alias("ec-tracker", "EntityChange-\nTracker-\n(Default)");
- var callee = handle.getCallees().getFirstElseFail();
- sequenceData.enter(handle.getCaller(), callee, enteringLabel);
+ var callee = handle.callees().getFirstElseFail();
+ sequenceData.enter(handle.caller(), callee, enteringLabel);
//sequenceData.activate(callee);
});
diff --git a/regressiontests/base/src/main/java/org/apache/causeway/testdomain/fixtures/EntityTestFixtures.java b/regressiontests/base/src/main/java/org/apache/causeway/testdomain/fixtures/EntityTestFixtures.java
index 44dccffbee2..4f86e229f3b 100644
--- a/regressiontests/base/src/main/java/org/apache/causeway/testdomain/fixtures/EntityTestFixtures.java
+++ b/regressiontests/base/src/main/java/org/apache/causeway/testdomain/fixtures/EntityTestFixtures.java
@@ -29,6 +29,8 @@
import jakarta.inject.Inject;
+import org.jspecify.annotations.NonNull;
+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -53,7 +55,6 @@
import org.apache.causeway.testdomain.util.dto.IBook;
import org.apache.causeway.testdomain.util.kv.KVStoreForTesting;
-import org.jspecify.annotations.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
@@ -161,7 +162,7 @@ public final void assertInventoryHasBooks(
public final void assertHasPersistenceId(final Object entity) {
var bookmark = bookmarkService.bookmarkForElseFail(entity);
- final int id = Integer.parseInt(bookmark.getIdentifier());
+ final int id = Integer.parseInt(bookmark.identifier());
assertTrue(id>=-1, ()->String.format("expected valid id; got %d", id));
}
@@ -201,7 +202,7 @@ public void release() {
@SneakyThrows
public final synchronized Lock aquireLock() {
- var dsUrl = dataSourceIntrospectionService.getDataSourceInfos().getFirstElseFail().getJdbcUrl();
+ var dsUrl = dataSourceIntrospectionService.getDataSourceInfos().getFirstElseFail().jdbcUrl();
this.lockQueue = lockQueueByDatasource.computeIfAbsent(dsUrl, __->new LinkedBlockingQueue<>(1));
log.info("waiting for lock {}", dsUrl);
Lock lock;
diff --git a/regressiontests/domainmodel/src/test/java/org/apache/causeway/testdomain/domainmodel/DomainModelTest_usingGoodDomain.java b/regressiontests/domainmodel/src/test/java/org/apache/causeway/testdomain/domainmodel/DomainModelTest_usingGoodDomain.java
index 38412df7a20..a9dedd0f864 100644
--- a/regressiontests/domainmodel/src/test/java/org/apache/causeway/testdomain/domainmodel/DomainModelTest_usingGoodDomain.java
+++ b/regressiontests/domainmodel/src/test/java/org/apache/causeway/testdomain/domainmodel/DomainModelTest_usingGoodDomain.java
@@ -172,7 +172,7 @@ void goodDomain_shouldPassValidation() {
// guard against left overs from shared context
var validationFailures = validateDomainModel.getFailures().stream()
- .filter(f->!f.getOrigin().className().contains("bad"))
+ .filter(f->!f.origin().className().contains("bad"))
.collect(Collectors.toSet());
if(!validationFailures.isEmpty()) {
@@ -180,7 +180,7 @@ void goodDomain_shouldPassValidation() {
fail(String.format("%d problems found:\n%s",
validationFailures.size(),
validationFailures.stream()
- .map(validationFailure->validationFailure.getMessage())
+ .map(validationFailure->validationFailure.message())
.collect(Collectors.joining("\n"))));
}
}
diff --git a/regressiontests/persistence-jdo/src/test/java/org/apache/causeway/testdomain/domainmodel/jdo/DomainModelTest.java b/regressiontests/persistence-jdo/src/test/java/org/apache/causeway/testdomain/domainmodel/jdo/DomainModelTest.java
index e0f3e96cd8d..8e6420abe1d 100644
--- a/regressiontests/persistence-jdo/src/test/java/org/apache/causeway/testdomain/domainmodel/jdo/DomainModelTest.java
+++ b/regressiontests/persistence-jdo/src/test/java/org/apache/causeway/testdomain/domainmodel/jdo/DomainModelTest.java
@@ -69,29 +69,25 @@ class DomainModelTest {
@Test
void goodDomain_shouldPassValidation() {
- //debug();
assertFalse(specificationLoader.snapshotSpecifications().isEmpty());
var validateDomainModel = new DomainModelValidator(serviceRegistry);
- validateDomainModel.getFailures().forEach(f->System.err.printf("%s:%s%n", f.getOrigin(), f.getMessage()));
+ validateDomainModel.getFailures().forEach(f->System.err.printf("%s:%s%n", f.origin(), f.message()));
validateDomainModel.throwIfInvalid(); // should not throw
}
@Test
void pluginProvidedMixins_shouldBePickedUp() {
-
var entitySpec = specificationLoader.loadSpecification(JdoProduct.class);
var mx_datanucleusVersionLong = entitySpec.getAssociationElseFail("datanucleusVersionLong"); // plugged in mixin
assertNotNull(mx_datanucleusVersionLong);
-
}
@Test
void metaAnnotatedEntities_shouldBeRecognized() {
-
var entitySpec = specificationLoader.loadSpecification(JdoEntityMetaAnnotated.class);
assertEquals(BeanSort.ENTITY, entitySpec.getBeanSort());
diff --git a/regressiontests/persistence-jdo/src/test/java/org/apache/causeway/testdomain/injecting/jdo/JdoEntityInjectingTest.java b/regressiontests/persistence-jdo/src/test/java/org/apache/causeway/testdomain/injecting/jdo/JdoEntityInjectingTest.java
index cee87d52bc1..289ab49e11d 100644
--- a/regressiontests/persistence-jdo/src/test/java/org/apache/causeway/testdomain/injecting/jdo/JdoEntityInjectingTest.java
+++ b/regressiontests/persistence-jdo/src/test/java/org/apache/causeway/testdomain/injecting/jdo/JdoEntityInjectingTest.java
@@ -144,7 +144,7 @@ private JdoBook getSampleBook() {
private void assertInjectCountRange(final long lower, final long upper) {
_Assert.assertRangeContains(
- Range.of(Bound.inclusive(lower), Bound.inclusive(upper)),
+ new Range(Bound.inclusive(lower), Bound.inclusive(upper)),
getInjectCount(), "injection count");
}
diff --git a/regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/injecting/jpa/JpaEntityInjectingTest.java b/regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/injecting/jpa/JpaEntityInjectingTest.java
index ec18fa0ea97..522f3a238be 100644
--- a/regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/injecting/jpa/JpaEntityInjectingTest.java
+++ b/regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/injecting/jpa/JpaEntityInjectingTest.java
@@ -147,7 +147,7 @@ private JpaBook getSampleBook() {
private void assertInjectCountRange(final long lower, final long upper) {
_Assert.assertRangeContains(
- Range.of(Bound.inclusive(lower), Bound.inclusive(upper)),
+ new Range(Bound.inclusive(lower), Bound.inclusive(upper)),
getInjectCount(), "injection count");
}
diff --git a/regressiontests/value/src/test/java/org/apache/causeway/testdomain/value/ActionInteractionProbeImpl.java b/regressiontests/value/src/test/java/org/apache/causeway/testdomain/value/ActionInteractionProbeImpl.java
index d71e570309e..f7408bcead7 100644
--- a/regressiontests/value/src/test/java/org/apache/causeway/testdomain/value/ActionInteractionProbeImpl.java
+++ b/regressiontests/value/src/test/java/org/apache/causeway/testdomain/value/ActionInteractionProbeImpl.java
@@ -37,35 +37,35 @@
@RequiredArgsConstructor
class ActionInteractionProbeImpl<T> implements ActionInteractionProbe<T> {
-
+
final @NonNull String name;
final @NonNull Class<T> valueType;
final @NonNull ValueTypeExample<T> example;
final @NonNull ValueSemanticsTester<T> tester;
-
+
@Inject private SchemaValueMarshaller valueMarshaller;
-
+
@Override
public void testCommandWithNonEmptyArg(
final ValueSemanticsProvider.Context context,
final Command command) {
assertNotNull(command.getCommandDto());
-
+
//debug
//System.err.printf("CommandDto %s %s%n", name,
// CommandDtoUtils.dtoMapper().toString(command.getCommandDto()));
-
+
var actionDto = (ActionDto)command.getCommandDto().getMember();
-
+
assertNotNull(actionDto.getParameters());
assertNotNull(actionDto.getParameters().getParameter());
- assertEquals(1, actionDto.getParameters().getParameter().size()); // we are testing a single arg action
-
+ assertEquals(1, actionDto.getParameters().getParameter().size()); // we are testing a single arg action
+
var parameterRecordedDto = actionDto.getParameters().getParameter().get(0);
assertNotNull(parameterRecordedDto);
-
- final Identifier paramId = context.getFeatureIdentifier();
+
+ final Identifier paramId = context.featureIdentifier();
var parameterRecorded = valueMarshaller.recoverParameterFrom(paramId, parameterRecordedDto);
assertNotNull(parameterRecorded);
@@ -76,28 +76,28 @@ public void testCommandWithNonEmptyArg(
tester.assertValueEquals(example.getUpdateValue(), parameterRecorded.getPojo(), "command failed");
}
-
+
@Override
public void testCommandWithEmptyArg(
final ValueSemanticsProvider.Context context,
final Command command) {
assertNotNull(command.getCommandDto());
-
+
//debug
// System.err.printf("CommandDto %s %s%n", name,
// CommandDtoUtils.dtoMapper().toString(command.getCommandDto()));
-
+
var actionDto = (ActionDto)command.getCommandDto().getMember();
-
+
assertNotNull(actionDto.getParameters());
assertNotNull(actionDto.getParameters().getParameter());
- assertEquals(1, actionDto.getParameters().getParameter().size()); // we are testing a single arg action
-
+ assertEquals(1, actionDto.getParameters().getParameter().size()); // we are testing a single arg action
+
var parameterRecordedDto = actionDto.getParameters().getParameter().get(0);
assertNotNull(parameterRecordedDto);
-
- final Identifier paramId = context.getFeatureIdentifier();
+
+ final Identifier paramId = context.featureIdentifier();
var parameterRecorded = valueMarshaller.recoverParameterFrom(paramId, parameterRecordedDto);
assertNotNull(parameterRecorded);
@@ -107,5 +107,5 @@ public void testCommandWithEmptyArg(
assertNull(parameterRecorded.getPojo());
}
-
+
}
diff --git a/regressiontests/value/src/test/java/org/apache/causeway/testdomain/value/ValueSemanticsTester.java b/regressiontests/value/src/test/java/org/apache/causeway/testdomain/value/ValueSemanticsTester.java
index 5e0095776dd..d147b260139 100644
--- a/regressiontests/value/src/test/java/org/apache/causeway/testdomain/value/ValueSemanticsTester.java
+++ b/regressiontests/value/src/test/java/org/apache/causeway/testdomain/value/ValueSemanticsTester.java
@@ -180,7 +180,7 @@ public void propertyInteraction(
assertTrue(semanticsIfAny.isPresent(), ()->
"value semantics must be available for "
- + context.getFeatureIdentifier());
+ + context.featureIdentifier());
probe.testComposer(context, semanticsIfAny.get());
diff --git a/testing/h2console/ui/src/main/java/org/apache/causeway/testing/h2console/ui/webmodule/WebModuleH2Console.java b/testing/h2console/ui/src/main/java/org/apache/causeway/testing/h2console/ui/webmodule/WebModuleH2Console.java
index 073d6d2a439..6d61cba9efa 100644
--- a/testing/h2console/ui/src/main/java/org/apache/causeway/testing/h2console/ui/webmodule/WebModuleH2Console.java
+++ b/testing/h2console/ui/src/main/java/org/apache/causeway/testing/h2console/ui/webmodule/WebModuleH2Console.java
@@ -175,7 +175,7 @@ private boolean isH2MemConnectionUsed(final DataSourceIntrospectionService datas
return datasourceIntrospector.getDataSourceInfos()
.stream()
- .map(DataSourceInfo::getJdbcUrl)
+ .map(DataSourceInfo::jdbcUrl)
.anyMatch(jdbcUrl->{
if(jdbcUrl.contains(":h2:mem:")) {
log.info("found h2 in-memory data-source: {}", jdbcUrl);
diff --git a/testing/hsqldbmgr/ui/src/main/java/org/apache/causeway/extensions/hsqldbmgr/dom/services/HsqlDbManagerMenu.java b/testing/hsqldbmgr/ui/src/main/java/org/apache/causeway/extensions/hsqldbmgr/dom/services/HsqlDbManagerMenu.java
index 23089b8a7d2..949f7db5f18 100644
--- a/testing/hsqldbmgr/ui/src/main/java/org/apache/causeway/extensions/hsqldbmgr/dom/services/HsqlDbManagerMenu.java
+++ b/testing/hsqldbmgr/ui/src/main/java/org/apache/causeway/extensions/hsqldbmgr/dom/services/HsqlDbManagerMenu.java
@@ -58,7 +58,7 @@ public class HsqlDbManagerMenu {
public HsqlDbManagerMenu(final DataSourceIntrospectionService datasourceIntrospector) {
this.url = datasourceIntrospector.getDataSourceInfos()
.stream()
- .map(DataSourceInfo::getJdbcUrl)
+ .map(DataSourceInfo::jdbcUrl)
.filter(jdbcUrl->{
if(jdbcUrl.contains("hsqldb:mem")) {
log.info("found hsqldb in-memory data-source: {}", jdbcUrl);
diff --git a/testing/integtestsupport/applib/src/main/java/org/apache/causeway/testing/integtestsupport/applib/validate/DomainModelValidator.java b/testing/integtestsupport/applib/src/main/java/org/apache/causeway/testing/integtestsupport/applib/validate/DomainModelValidator.java
index 09f767591fc..c2d66912675 100644
--- a/testing/integtestsupport/applib/src/main/java/org/apache/causeway/testing/integtestsupport/applib/validate/DomainModelValidator.java
+++ b/testing/integtestsupport/applib/src/main/java/org/apache/causeway/testing/integtestsupport/applib/validate/DomainModelValidator.java
@@ -118,21 +118,17 @@ public void throwIfInvalid() {
}
public Set<ValidationFailure> getFailures() {
- if (validationFailures == null) {
- return Collections.emptySet();
- }
+ if (validationFailures == null) return Collections.emptySet();
+
return validationFailures.getFailures(); // already wrapped unmodifiable
}
public Stream<ValidationFailure> streamFailures(final @Nullable Predicate<Identifier> filter) {
- if(validationFailures==null) {
- return Stream.empty();
- }
- if(filter==null) {
- return validationFailures.getFailures().stream();
- }
+ if(validationFailures==null) return Stream.empty();
+ if(filter==null) return validationFailures.getFailures().stream();
+
return validationFailures.getFailures().stream()
- .filter(failure->filter.test(failure.getOrigin()));
+ .filter(failure->filter.test(failure.origin()));
}
public Stream<ValidationFailure> streamFailuresMatchingOriginatingIdentifier(
@@ -151,13 +147,13 @@ public void assertAnyFailuresContaining(
boolean matchFound = streamFailuresMatchingOriginatingIdentifier(identifier)
.anyMatch(failure->
- failure.getMessage().contains(messageSnippet));
+ failure.message().contains(messageSnippet));
if(!matchFound) {
var msg = String.format("validation snipped '%s' not found within messages:\n%s",
messageSnippet,
streamFailuresMatchingOriginatingIdentifier(identifier)
- .map(ValidationFailure::getMessage)
+ .map(ValidationFailure::message)
.collect(Collectors.joining("\n")));
throw new AssertionFailedError(msg);
}
@@ -176,13 +172,13 @@ public void assertAnyFailuresContaining(
boolean matchFound = streamFailures(filterByLogicalType)
.anyMatch(failure->
- failure.getMessage().contains(messageSnippet));
+ failure.message().contains(messageSnippet));
if(!matchFound) {
var msg = String.format("validation snipped '%s' not found within messages:\n%s",
messageSnippet,
streamFailures(filterByLogicalType)
- .map(ValidationFailure::getMessage)
+ .map(ValidationFailure::message)
.collect(Collectors.joining("\n")));
throw new AssertionFailedError(msg);
}
@@ -196,18 +192,18 @@ public void assertAnyOfContainingAnyFailures(
final String messageSnippet) {
boolean matchFound = classIdentifiers
- .stream()
- .anyMatch(identifier->
- streamFailuresMatchingOriginatingIdentifier(identifier)
- .anyMatch(failure->
- failure.getMessage().contains(messageSnippet)));
+ .stream()
+ .anyMatch(identifier->
+ streamFailuresMatchingOriginatingIdentifier(identifier)
+ .anyMatch(failure->
+ failure.message().contains(messageSnippet)));
if(!matchFound) {
var msg = String.format("validation snipped '%s' not found within messages:\n%s",
messageSnippet,
classIdentifiers.stream()
.flatMap(identifier->streamFailuresMatchingOriginatingIdentifier(identifier))
- .map(ValidationFailure::getMessage)
+ .map(ValidationFailure::message)
.collect(Collectors.joining("\n")));
throw new AssertionFailedError(msg);
}