You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2021/11/24 16:10:34 UTC
[isis] branch master updated: ISIS-2877: just using some better names
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new 5d4f2de ISIS-2877: just using some better names
5d4f2de is described below
commit 5d4f2de8d2adbc4f8deb8ce34e01e42109e2be1f
Author: Andi Huber <ah...@apache.org>
AuthorDate: Wed Nov 24 16:59:36 2021 +0100
ISIS-2877: just using some better names
---
.../applib/value/semantics/EncoderDecoder.java | 7 ++--
.../isis/applib/value/semantics/ValueComposer.java | 40 ++++++++++++++++++++++
.../valuesemantics/OidDtoValueSemantics.java | 6 ++--
.../isis/testdomain/value/ValueSemanticsTest.java | 14 ++++----
4 files changed, 52 insertions(+), 15 deletions(-)
diff --git a/api/applib/src/main/java/org/apache/isis/applib/value/semantics/EncoderDecoder.java b/api/applib/src/main/java/org/apache/isis/applib/value/semantics/EncoderDecoder.java
index 68a6814..13950bb 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/value/semantics/EncoderDecoder.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/value/semantics/EncoderDecoder.java
@@ -43,7 +43,8 @@ package org.apache.isis.applib.value.semantics;
*
* @since 1.x {@index}
*/
-public interface EncoderDecoder<T> {
+public interface EncoderDecoder<T>
+extends ValueComposer<T> {
/**
* Returns the provided object as an encoded string.
@@ -66,8 +67,4 @@ public interface EncoderDecoder<T> {
*/
T fromEncodedString(String encodedString);
- default Object getConstructorExtractor(final T value) {
- return null;
- }
-
}
diff --git a/api/applib/src/main/java/org/apache/isis/applib/value/semantics/ValueComposer.java b/api/applib/src/main/java/org/apache/isis/applib/value/semantics/ValueComposer.java
new file mode 100644
index 0000000..8053d83
--- /dev/null
+++ b/api/applib/src/main/java/org/apache/isis/applib/value/semantics/ValueComposer.java
@@ -0,0 +1,40 @@
+/*
+ * 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.isis.applib.value.semantics;
+
+/**
+ * Provides construction and extraction for a given value-type
+ * from and into its constituent parts.
+ *
+ * @param <T> - value-type
+ *
+ * @see DefaultsProvider
+ * @see Parser
+ * @see OrderRelation
+ * @see ValueSemanticsProvider
+ *
+ * @since 2.x {@index}
+ */
+public interface ValueComposer<T> {
+
+ default Object getValueMixin(final T value) {
+ return null;
+ }
+
+}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/valuesemantics/OidDtoValueSemantics.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/valuesemantics/OidDtoValueSemantics.java
index a87c949..906da73 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/valuesemantics/OidDtoValueSemantics.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/valuesemantics/OidDtoValueSemantics.java
@@ -87,7 +87,7 @@ implements
@Action
@RequiredArgsConstructor
- public static class ConstructorExtractor {
+ public static class ValueMixin {
final OidDto value;
@@ -104,8 +104,8 @@ implements
}
@Override
- public ConstructorExtractor getConstructorExtractor(final OidDto object) {
- return new ConstructorExtractor(object);
+ public ValueMixin getValueMixin(final OidDto object) {
+ return new ValueMixin(object);
}
// -- ENCODER DECODER
diff --git a/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java b/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java
index eccf0cd..ffc3fd7 100644
--- a/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java
+++ b/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java
@@ -86,14 +86,14 @@ class ValueSemanticsTest {
tester.propertyInteraction("value",
interactionContext(),
managedProp->example.getUpdateValue(),
- (context, codec)->{
+ (context, composer)->{
- val constructorExtractor = codec.getConstructorExtractor(example.getValue());
- if(constructorExtractor!=null) {
+ val valueMixin = composer.getValueMixin(example.getValue());
+ if(valueMixin!=null) {
- val spec = specLoader.specForTypeElseFail(constructorExtractor.getClass());
+ val spec = specLoader.specForTypeElseFail(valueMixin.getClass());
val interaction = ActionInteraction
- .start(ManagedObject.of(spec, constructorExtractor), "act", Where.ANYWHERE);
+ .start(ManagedObject.of(spec, valueMixin), "act", Where.ANYWHERE);
val pendingParams = interaction
.startParameterNegotiation()
@@ -116,11 +116,11 @@ class ValueSemanticsTest {
}
// CoderDecoder round-trip test
- val serialized = codec.toEncodedString(example.getValue());
+ val serialized = composer.toEncodedString(example.getValue());
tester.assertValueEquals(
example.getValue(),
- codec.fromEncodedString(serialized),
+ composer.fromEncodedString(serialized),
"serialization roundtrip failed");
},