This is an automated email from the ASF dual-hosted git repository.

apkhmv pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 35712c6cee IGNITE-23835 Simplify ProblemBuilder (#4824)
35712c6cee is described below

commit 35712c6ceef7e06171358ef6907080bc705f6a61
Author: Vadim Pakhnushev <[email protected]>
AuthorDate: Tue Dec 3 19:47:52 2024 +0300

    IGNITE-23835 Simplify ProblemBuilder (#4824)
---
 .../apache/ignite/internal/rest/api/Problem.java   | 64 +++++++++++-----------
 .../ignite/internal/rest/problem/Builder.java      | 28 ----------
 .../handler/IgniteExceptionHandlerTest.java        |  2 +-
 3 files changed, 32 insertions(+), 62 deletions(-)

diff --git 
a/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/Problem.java
 
b/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/Problem.java
index 0db38b32cf..48c6fb5207 100644
--- 
a/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/Problem.java
+++ 
b/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/Problem.java
@@ -25,7 +25,6 @@ import java.util.Collection;
 import java.util.Objects;
 import java.util.UUID;
 import org.apache.ignite.internal.rest.constants.HttpCode;
-import org.apache.ignite.internal.rest.problem.Builder;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -87,13 +86,13 @@ public class Problem {
     }
 
     /** Returns {@link ProblemBuilder}. */
-    public static <T extends Problem, B extends ProblemBuilder<T, B>> 
ProblemBuilder<T, B> builder() {
-        return new ProblemBuilder<>();
+    public static ProblemBuilder builder() {
+        return new ProblemBuilder();
     }
 
     /** Returns {@link ProblemBuilder} with http status and title. */
-    public static <T extends Problem, B extends ProblemBuilder<T, B>> 
ProblemBuilder<T, B> fromHttpCode(HttpCode httpCode) {
-        ProblemBuilder<T, B> builder = new ProblemBuilder<>();
+    public static ProblemBuilder fromHttpCode(HttpCode httpCode) {
+        ProblemBuilder builder = new ProblemBuilder();
         builder.status(httpCode.code());
         builder.title(httpCode.message());
 
@@ -174,66 +173,65 @@ public class Problem {
     }
 
     /** Builder for {@link Problem}. */
-    public static class ProblemBuilder<T extends Problem, B extends 
ProblemBuilder<T, B>> implements Builder<T, B> {
-        protected String title;
+    public static class ProblemBuilder {
+        private String title;
 
-        protected int status;
+        private int status;
 
-        protected String code;
+        private String code;
 
-        protected String type;
+        private String type;
 
-        protected String detail;
+        private String detail;
 
-        protected String node;
+        private String node;
 
-        protected UUID traceId;
+        private UUID traceId;
 
-        protected Collection<InvalidParam> invalidParams;
+        private Collection<InvalidParam> invalidParams;
 
-        public B title(String title) {
+        public ProblemBuilder title(String title) {
             this.title = title;
-            return (B) this;
+            return this;
         }
 
-        public B status(int status) {
+        public ProblemBuilder status(int status) {
             this.status = status;
-            return (B) this;
+            return this;
         }
 
-        public B code(String code) {
+        public ProblemBuilder code(String code) {
             this.code = code;
-            return (B) this;
+            return this;
         }
 
-        public B type(String type) {
+        public ProblemBuilder type(String type) {
             this.type = type;
-            return (B) this;
+            return this;
         }
 
-        public B detail(String detail) {
+        public ProblemBuilder detail(String detail) {
             this.detail = detail;
-            return (B) this;
+            return this;
         }
 
-        public B node(String node) {
+        public ProblemBuilder node(String node) {
             this.node = node;
-            return (B) this;
+            return this;
         }
 
-        public B traceId(UUID traceId) {
+        public ProblemBuilder traceId(UUID traceId) {
             this.traceId = traceId;
-            return (B) this;
+            return this;
         }
 
-        public B invalidParams(Collection<InvalidParam> invalidParams) {
+        public ProblemBuilder invalidParams(Collection<InvalidParam> 
invalidParams) {
             this.invalidParams = invalidParams;
-            return (B) this;
+            return this;
         }
 
-        @Override
-        public T build() {
-            return (T) new Problem(title, status, code, type, detail, node, 
traceId, invalidParams);
+        public Problem build() {
+            return new Problem(title, status, code, type, detail, node, 
traceId, invalidParams);
         }
     }
 }
diff --git 
a/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/problem/Builder.java
 
b/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/problem/Builder.java
deleted file mode 100644
index 3b00486e2a..0000000000
--- 
a/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/problem/Builder.java
+++ /dev/null
@@ -1,28 +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.ignite.internal.rest.problem;
-
-/**
- * Generic interface for builders.
- *
- * @param <T> built type.
- * @param <B> builder type.
- */
-public interface Builder<T, B extends Builder<T, B>> {
-    T build();
-}
diff --git 
a/modules/rest-api/src/test/java/org/apache/ignite/internal/rest/exception/handler/IgniteExceptionHandlerTest.java
 
b/modules/rest-api/src/test/java/org/apache/ignite/internal/rest/exception/handler/IgniteExceptionHandlerTest.java
index 22e9483bd5..bc031d8e20 100644
--- 
a/modules/rest-api/src/test/java/org/apache/ignite/internal/rest/exception/handler/IgniteExceptionHandlerTest.java
+++ 
b/modules/rest-api/src/test/java/org/apache/ignite/internal/rest/exception/handler/IgniteExceptionHandlerTest.java
@@ -113,7 +113,7 @@ class IgniteExceptionHandlerTest extends 
BaseIgniteAbstractTest {
 
     @ParameterizedTest
     @MethodSource("igniteExceptions")
-    void shouldHandleIgniteException(IgniteException givenIgniteException, 
ProblemBuilder<? extends Problem, ?> expectedProblem) {
+    void shouldHandleIgniteException(IgniteException givenIgniteException, 
ProblemBuilder expectedProblem) {
         HttpResponse<? extends Problem> response = 
exceptionHandler.handle(request, givenIgniteException);
 
         Problem problem = response.body();

Reply via email to