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 2020/12/18 10:22:04 UTC

[isis] branch master updated: ISIS-2033: applib query: more cleaning up

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 d578bd3  ISIS-2033: applib query: more cleaning up
d578bd3 is described below

commit d578bd345169587cbf4f7c5d8d0faebaa3abf120
Author: Andi Huber <ah...@apache.org>
AuthorDate: Fri Dec 18 11:21:31 2020 +0100

    ISIS-2033: applib query: more cleaning up
---
 .../java/org/apache/isis/applib/query/Query.java   |  4 -
 .../apache/isis/applib/query/QueryAbstract.java    | 88 ----------------------
 .../applib/query/_AllInstancesQueryDefault.java    |  9 +--
 .../isis/applib/query/_NamedQueryDefault.java      |  2 +-
 .../apache/isis/applib/query/_QueryAbstract.java   | 42 +++++++++++
 .../choices/ChoicesFacetFromBoundedAbstract.java   |  2 +-
 6 files changed, 46 insertions(+), 101 deletions(-)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/query/Query.java b/api/applib/src/main/java/org/apache/isis/applib/query/Query.java
index b02f794..3587056 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/query/Query.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/query/Query.java
@@ -66,15 +66,11 @@ public interface Query<T> extends Serializable {
 
     /**
      * The start index into the set table
-     *
-     * @return
      */
     long getStart();
 
     /**
      * The number of items to return, starting at {@link #getStart()}
-     *
-     * @return
      */
     long getCount();
     
diff --git a/api/applib/src/main/java/org/apache/isis/applib/query/QueryAbstract.java b/api/applib/src/main/java/org/apache/isis/applib/query/QueryAbstract.java
deleted file mode 100644
index 04e5cbf..0000000
--- a/api/applib/src/main/java/org/apache/isis/applib/query/QueryAbstract.java
+++ /dev/null
@@ -1,88 +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.isis.applib.query;
-
-import org.apache.isis.commons.internal.context._Context;
-
-import lombok.Getter;
-
-/**
- * Convenience adapter class for {@link Query}.
- * <p>
- * Handles implementation of {@link #getResultType()}
- */
-public abstract class QueryAbstract<T> implements Query<T> {
-
-    private static final long serialVersionUID = 1L;
-
-    /**
-     * The start index within the retrieved result set.
-     */
-    @Getter private final long start;
-
-    /**
-     * The number of items to return
-     */
-    @Getter private final long count;
-
-    @Getter private final String resultTypeName;
-
-    /**
-     * Derived from {@link #getResultTypeName()}, with respect to the
-     * {@link Thread#getContextClassLoader() current thread's class loader}.
-     */
-    private transient Class<T> resultType;
-
-    /**
-     * Base query based on Class type.
-     *
-     * @param type
-     */
-    protected QueryAbstract(final Class<T> type, final long start, final long count) {
-        this.resultTypeName = type.getName();
-        this.start = start;
-        this.count = count;
-    }
-
-    protected QueryAbstract(final String typeName, final long start, final long count) {
-        this.resultTypeName = typeName;
-        this.start = start;
-        this.count = count;
-    }
-
-    /**
-     * @throws IllegalStateException
-     *             (wrapping a {@link ClassNotFoundException}) if the class
-     *             could not be determined.
-     */
-    @Override
-    @SuppressWarnings("unchecked")
-    public Class<T> getResultType() {
-        if (resultType == null) {
-            try {
-                resultType = (Class<T>) _Context.loadClass(resultTypeName);
-            } catch (final ClassNotFoundException e) {
-                throw new IllegalStateException(e);
-            }
-        }
-        return resultType;
-    }
-    
-}
diff --git a/api/applib/src/main/java/org/apache/isis/applib/query/_AllInstancesQueryDefault.java b/api/applib/src/main/java/org/apache/isis/applib/query/_AllInstancesQueryDefault.java
index 0c74068..7b041e9 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/query/_AllInstancesQueryDefault.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/query/_AllInstancesQueryDefault.java
@@ -24,7 +24,7 @@ import org.apache.isis.commons.internal.exceptions._Exceptions;
 import lombok.NonNull;
 
 final class _AllInstancesQueryDefault<T> 
-extends QueryAbstract<T> 
+extends _QueryAbstract<T> 
 implements AllInstancesQuery<T> {
 
     private static final long serialVersionUID = 1L;
@@ -36,14 +36,9 @@ implements AllInstancesQuery<T> {
         super(type, start, count);
     }
 
-    @Deprecated
-    protected _AllInstancesQueryDefault(final String typeName, final long start, final long count) {
-        super(typeName, start, count);
-    }
-
     @Override
     public String getDescription() {
-        return getResultTypeName() + " (all instances)";
+        return getResultType().getName() + " (all instances)";
     }
 
     // -- WITHERS
diff --git a/api/applib/src/main/java/org/apache/isis/applib/query/_NamedQueryDefault.java b/api/applib/src/main/java/org/apache/isis/applib/query/_NamedQueryDefault.java
index c90a3ce..2d1d398 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/query/_NamedQueryDefault.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/query/_NamedQueryDefault.java
@@ -31,7 +31,7 @@ import lombok.NonNull;
 import lombok.val;
 
 final class _NamedQueryDefault<T> 
-extends QueryAbstract<T>
+extends _QueryAbstract<T>
 implements NamedQuery<T> {
 
     private static final long serialVersionUID = 1L;
diff --git a/api/applib/src/main/java/org/apache/isis/applib/query/_QueryAbstract.java b/api/applib/src/main/java/org/apache/isis/applib/query/_QueryAbstract.java
new file mode 100644
index 0000000..b71d970
--- /dev/null
+++ b/api/applib/src/main/java/org/apache/isis/applib/query/_QueryAbstract.java
@@ -0,0 +1,42 @@
+/*
+ *  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.query;
+
+import lombok.Getter;
+import lombok.NonNull;
+
+abstract class _QueryAbstract<T> implements Query<T> {
+
+    private static final long serialVersionUID = 1L;
+
+    @Getter(onMethod_ = {@Override}) private final long start;
+    @Getter(onMethod_ = {@Override}) private final long count;
+    @Getter(onMethod_ = {@Override}) private final Class<T> resultType;
+
+    protected _QueryAbstract(
+            final @NonNull Class<T> resultType, 
+            final long start, 
+            final long count) {
+        this.resultType = resultType;
+        this.start = start;
+        this.count = count;
+    }
+    
+}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/ChoicesFacetFromBoundedAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/ChoicesFacetFromBoundedAbstract.java
index c65353f..842e7c8 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/ChoicesFacetFromBoundedAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/object/choices/ChoicesFacetFromBoundedAbstract.java
@@ -106,7 +106,7 @@ implements ChoicesFacet, DisablingInteractionAdvisor, ValidatingInteractionAdvis
     @SneakyThrows
     @Override
     public Can<ManagedObject> getChoices(
-            ManagedObject adapter,
+            final ManagedObject adapter,
             final InteractionInitiatedBy interactionInitiatedBy) {
 
         //TODO[2033] if assert is always true just use type = getObjectSpecification().getCorrespondingClass()