Repository: jakartaee/data (java)

Issue:
separate package for restrictions
On the topic of further API updates for restrictions, I noticed that 9 of the 13 classes in the `jakarta.data` package, (or 8 if we consider `Operator` to be general purpose) are all for restrictions.  This tells me restrictions ought to have its own package, maybe `jakarta.data.restrict`?  I'm not opening a PR for this yet because it would collide with the rename in #915 and it would be better to do these serially to avoid merge conflicts.  In the mean time, this is a good opportunity to collect feedback from others, if anyone wants a different package name, has thoughts on whether `Operator` should go with it or stay, and so forth.

Pull request:
Use separate package for Restrictions
Fixes #931
This moves the 9 classes that we have for restrictions into their own package so that they don't overwhelm the main `jakarta.data` package.

Patch:
diff --git a/api/src/main/java/jakarta/data/metamodel/Attribute.java b/api/src/main/java/jakarta/data/metamodel/Attribute.java
index 147b73ba..0d3b91bd 100644
--- a/api/src/main/java/jakarta/data/metamodel/Attribute.java
+++ b/api/src/main/java/jakarta/data/metamodel/Attribute.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023,2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2023,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,8 +19,8 @@ package jakarta.data.metamodel;
 
 import java.util.Set;
 
-import jakarta.data.Restrict;
-import jakarta.data.Restriction;
+import jakarta.data.metamodel.restrict.Restrict;
+import jakarta.data.metamodel.restrict.Restriction;
 
 /**
  * Represents an entity attribute in the {@link StaticMetamodel}.
diff --git a/api/src/main/java/jakarta/data/metamodel/SortableAttribute.java b/api/src/main/java/jakarta/data/metamodel/SortableAttribute.java
index 650164de..47cee815 100644
--- a/api/src/main/java/jakarta/data/metamodel/SortableAttribute.java
+++ b/api/src/main/java/jakarta/data/metamodel/SortableAttribute.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023,2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2023,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,9 @@
  */
 package jakarta.data.metamodel;
 
-import jakarta.data.Restrict;
-import jakarta.data.Restriction;
 import jakarta.data.Sort;
+import jakarta.data.metamodel.restrict.Restrict;
+import jakarta.data.metamodel.restrict.Restriction;
 
 /**
  * Represents a sortable entity attribute in the {@link StaticMetamodel}.
diff --git a/api/src/main/java/jakarta/data/metamodel/TextAttribute.java b/api/src/main/java/jakarta/data/metamodel/TextAttribute.java
index 9b026025..3beb362e 100644
--- a/api/src/main/java/jakarta/data/metamodel/TextAttribute.java
+++ b/api/src/main/java/jakarta/data/metamodel/TextAttribute.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023,2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2023,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,9 @@
  */
 package jakarta.data.metamodel;
 
-import jakarta.data.Restrict;
 import jakarta.data.Sort;
-import jakarta.data.TextRestriction;
+import jakarta.data.metamodel.restrict.Restrict;
+import jakarta.data.metamodel.restrict.TextRestriction;
 
 /**
  * Represents an textual entity attribute in the {@link StaticMetamodel}.
diff --git a/api/src/main/java/jakarta/data/BasicRestriction.java b/api/src/main/java/jakarta/data/metamodel/restrict/BasicRestriction.java
similarity index 88%
rename from api/src/main/java/jakarta/data/BasicRestriction.java
rename to api/src/main/java/jakarta/data/metamodel/restrict/BasicRestriction.java
index d044da66..27171a46 100644
--- a/api/src/main/java/jakarta/data/BasicRestriction.java
+++ b/api/src/main/java/jakarta/data/metamodel/restrict/BasicRestriction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  *
  * SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 public interface BasicRestriction<T> extends Restriction<T> {
     String attribute();
diff --git a/api/src/main/java/jakarta/data/BasicRestrictionRecord.java b/api/src/main/java/jakarta/data/metamodel/restrict/BasicRestrictionRecord.java
similarity index 91%
rename from api/src/main/java/jakarta/data/BasicRestrictionRecord.java
rename to api/src/main/java/jakarta/data/metamodel/restrict/BasicRestrictionRecord.java
index 4667f9ce..c065c6a5 100644
--- a/api/src/main/java/jakarta/data/BasicRestrictionRecord.java
+++ b/api/src/main/java/jakarta/data/metamodel/restrict/BasicRestrictionRecord.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  *
  *  SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 // Internal implementation class.
 // The proper way for users to obtain instances is via
diff --git a/api/src/main/java/jakarta/data/CompositeRestriction.java b/api/src/main/java/jakarta/data/metamodel/restrict/CompositeRestriction.java
similarity index 89%
rename from api/src/main/java/jakarta/data/CompositeRestriction.java
rename to api/src/main/java/jakarta/data/metamodel/restrict/CompositeRestriction.java
index 5c5a8ab6..df9f5abb 100644
--- a/api/src/main/java/jakarta/data/CompositeRestriction.java
+++ b/api/src/main/java/jakarta/data/metamodel/restrict/CompositeRestriction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  *
  * SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 import java.util.List;
 
diff --git a/api/src/main/java/jakarta/data/CompositeRestrictionRecord.java b/api/src/main/java/jakarta/data/metamodel/restrict/CompositeRestrictionRecord.java
similarity index 93%
rename from api/src/main/java/jakarta/data/CompositeRestrictionRecord.java
rename to api/src/main/java/jakarta/data/metamodel/restrict/CompositeRestrictionRecord.java
index 40b8d612..0350c6af 100644
--- a/api/src/main/java/jakarta/data/CompositeRestrictionRecord.java
+++ b/api/src/main/java/jakarta/data/metamodel/restrict/CompositeRestrictionRecord.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  *
  *  SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 import java.util.List;
 
diff --git a/api/src/main/java/jakarta/data/Operator.java b/api/src/main/java/jakarta/data/metamodel/restrict/Operator.java
similarity index 92%
rename from api/src/main/java/jakarta/data/Operator.java
rename to api/src/main/java/jakarta/data/metamodel/restrict/Operator.java
index 003357ef..8662bd56 100644
--- a/api/src/main/java/jakarta/data/Operator.java
+++ b/api/src/main/java/jakarta/data/metamodel/restrict/Operator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  *
  * SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 public enum Operator {
     EQUAL,
diff --git a/api/src/main/java/jakarta/data/Restrict.java b/api/src/main/java/jakarta/data/metamodel/restrict/Restrict.java
similarity index 98%
rename from api/src/main/java/jakarta/data/Restrict.java
rename to api/src/main/java/jakarta/data/metamodel/restrict/Restrict.java
index 9ba7dc49..ccdb89f9 100644
--- a/api/src/main/java/jakarta/data/Restrict.java
+++ b/api/src/main/java/jakarta/data/metamodel/restrict/Restrict.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  *
  * SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 import java.util.List;
 import java.util.Objects;
diff --git a/api/src/main/java/jakarta/data/Restriction.java b/api/src/main/java/jakarta/data/metamodel/restrict/Restriction.java
similarity index 86%
rename from api/src/main/java/jakarta/data/Restriction.java
rename to api/src/main/java/jakarta/data/metamodel/restrict/Restriction.java
index 91504c71..1988da01 100644
--- a/api/src/main/java/jakarta/data/Restriction.java
+++ b/api/src/main/java/jakarta/data/metamodel/restrict/Restriction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  *
  * SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 public interface Restriction<T> {
     Restriction<T> negate();
diff --git a/api/src/main/java/jakarta/data/TextRestriction.java b/api/src/main/java/jakarta/data/metamodel/restrict/TextRestriction.java
similarity index 90%
rename from api/src/main/java/jakarta/data/TextRestriction.java
rename to api/src/main/java/jakarta/data/metamodel/restrict/TextRestriction.java
index d1a44fa8..e9fd0103 100644
--- a/api/src/main/java/jakarta/data/TextRestriction.java
+++ b/api/src/main/java/jakarta/data/metamodel/restrict/TextRestriction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  *
  * SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 public interface TextRestriction<T> extends BasicRestriction<T> {
     TextRestriction<T> ignoreCase();
diff --git a/api/src/main/java/jakarta/data/TextRestrictionRecord.java b/api/src/main/java/jakarta/data/metamodel/restrict/TextRestrictionRecord.java
similarity index 97%
rename from api/src/main/java/jakarta/data/TextRestrictionRecord.java
rename to api/src/main/java/jakarta/data/metamodel/restrict/TextRestrictionRecord.java
index 9cc88bf2..ec593a17 100644
--- a/api/src/main/java/jakarta/data/TextRestrictionRecord.java
+++ b/api/src/main/java/jakarta/data/metamodel/restrict/TextRestrictionRecord.java
@@ -15,7 +15,7 @@
  *
  *  SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 // Internal implementation class.
 // The proper way for users to obtain instances is via
diff --git a/api/src/main/java/module-info.java b/api/src/main/java/module-info.java
index ebd710b5..51015d0c 100644
--- a/api/src/main/java/module-info.java
+++ b/api/src/main/java/module-info.java
@@ -1069,6 +1069,7 @@ module jakarta.data {
     exports jakarta.data;
     exports jakarta.data.metamodel;
     exports jakarta.data.metamodel.impl;
+    exports jakarta.data.metamodel.restrict;
     exports jakarta.data.page;
     exports jakarta.data.page.impl;
     exports jakarta.data.repository;


Test patch:
diff --git a/api/src/test/java/jakarta/data/metamodel/AttributeTest.java b/api/src/test/java/jakarta/data/metamodel/AttributeTest.java
index a109e1a9..2073dc64 100644
--- a/api/src/test/java/jakarta/data/metamodel/AttributeTest.java
+++ b/api/src/test/java/jakarta/data/metamodel/AttributeTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,12 +17,13 @@
  */
 package jakarta.data.metamodel;
 
-import jakarta.data.BasicRestriction;
-import jakarta.data.Operator;
-import jakarta.data.Restriction;
 import org.assertj.core.api.SoftAssertions;
 import org.junit.jupiter.api.Test;
 
+import jakarta.data.metamodel.restrict.BasicRestriction;
+import jakarta.data.metamodel.restrict.Operator;
+import jakarta.data.metamodel.restrict.Restriction;
+
 import java.util.Set;
 
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
diff --git a/api/src/test/java/jakarta/data/metamodel/SortableAttributeTest.java b/api/src/test/java/jakarta/data/metamodel/SortableAttributeTest.java
index a28f4c2b..5b484ea7 100644
--- a/api/src/test/java/jakarta/data/metamodel/SortableAttributeTest.java
+++ b/api/src/test/java/jakarta/data/metamodel/SortableAttributeTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,11 +17,12 @@
  */
 package jakarta.data.metamodel;
 
-import jakarta.data.BasicRestriction;
-import jakarta.data.CompositeRestriction;
-import jakarta.data.Operator;
-import jakarta.data.Restriction;
 import jakarta.data.Sort;
+import jakarta.data.metamodel.restrict.BasicRestriction;
+import jakarta.data.metamodel.restrict.CompositeRestriction;
+import jakarta.data.metamodel.restrict.Operator;
+import jakarta.data.metamodel.restrict.Restriction;
+
 import org.assertj.core.api.SoftAssertions;
 import org.junit.jupiter.api.Test;
 
diff --git a/api/src/test/java/jakarta/data/metamodel/TextAttributeTest.java b/api/src/test/java/jakarta/data/metamodel/TextAttributeTest.java
index 1c9b24ab..c552002d 100644
--- a/api/src/test/java/jakarta/data/metamodel/TextAttributeTest.java
+++ b/api/src/test/java/jakarta/data/metamodel/TextAttributeTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,10 @@
  */
 package jakarta.data.metamodel;
 
-import jakarta.data.Operator;
 import jakarta.data.Sort;
-import jakarta.data.TextRestriction;
+import jakarta.data.metamodel.restrict.Operator;
+import jakarta.data.metamodel.restrict.TextRestriction;
+
 import org.assertj.core.api.SoftAssertions;
 import org.junit.jupiter.api.Test;
 
diff --git a/api/src/test/java/jakarta/data/BasicRestrictionRecordTest.java b/api/src/test/java/jakarta/data/metamodel/restrict/BasicRestrictionRecordTest.java
similarity index 98%
rename from api/src/test/java/jakarta/data/BasicRestrictionRecordTest.java
rename to api/src/test/java/jakarta/data/metamodel/restrict/BasicRestrictionRecordTest.java
index bd2e88be..a2454c57 100644
--- a/api/src/test/java/jakarta/data/BasicRestrictionRecordTest.java
+++ b/api/src/test/java/jakarta/data/metamodel/restrict/BasicRestrictionRecordTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  *
  *  SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 import org.assertj.core.api.SoftAssertions;
 import org.junit.jupiter.api.Test;
diff --git a/api/src/test/java/jakarta/data/CompositeRestrictionRecordTest.java b/api/src/test/java/jakarta/data/metamodel/restrict/CompositeRestrictionRecordTest.java
similarity index 98%
rename from api/src/test/java/jakarta/data/CompositeRestrictionRecordTest.java
rename to api/src/test/java/jakarta/data/metamodel/restrict/CompositeRestrictionRecordTest.java
index 67e3f9df..5ee98503 100644
--- a/api/src/test/java/jakarta/data/CompositeRestrictionRecordTest.java
+++ b/api/src/test/java/jakarta/data/metamodel/restrict/CompositeRestrictionRecordTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  *
  *  SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 
 import org.assertj.core.api.SoftAssertions;
diff --git a/api/src/test/java/jakarta/data/RestrictTest.java b/api/src/test/java/jakarta/data/metamodel/restrict/RestrictTest.java
similarity index 98%
rename from api/src/test/java/jakarta/data/RestrictTest.java
rename to api/src/test/java/jakarta/data/metamodel/restrict/RestrictTest.java
index 8d458fc0..0a1c244d 100644
--- a/api/src/test/java/jakarta/data/RestrictTest.java
+++ b/api/src/test/java/jakarta/data/metamodel/restrict/RestrictTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  *
  * SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 import org.assertj.core.api.SoftAssertions;
 import org.junit.jupiter.api.Test;
diff --git a/api/src/test/java/jakarta/data/TextRestrictionRecordTest.java b/api/src/test/java/jakarta/data/metamodel/restrict/TextRestrictionRecordTest.java
similarity index 97%
rename from api/src/test/java/jakarta/data/TextRestrictionRecordTest.java
rename to api/src/test/java/jakarta/data/metamodel/restrict/TextRestrictionRecordTest.java
index a0d799af..990391ee 100644
--- a/api/src/test/java/jakarta/data/TextRestrictionRecordTest.java
+++ b/api/src/test/java/jakarta/data/metamodel/restrict/TextRestrictionRecordTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Contributors to the Eclipse Foundation
+ * Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,12 +15,12 @@
  *
  *  SPDX-License-Identifier: Apache-2.0
  */
-package jakarta.data;
+package jakarta.data.metamodel.restrict;
 
 import org.assertj.core.api.SoftAssertions;
 import org.junit.jupiter.api.Test;
 
-import jakarta.data.BasicRestrictionRecordTest.Book;
+import jakarta.data.metamodel.restrict.BasicRestrictionRecordTest.Book;
 
 import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;