Skip to content

Commit 1ea74a6

Browse files
committed
Showcase stereotyping.
1 parent fbd6ccf commit 1ea74a6

File tree

8 files changed

+397
-5
lines changed

8 files changed

+397
-5
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2025 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package de.odrotbohm.restbucks;
17+
18+
import org.jmolecules.stereotype.Stereotype;
19+
20+
/**
21+
* @author Oliver Drotbohm
22+
*/
23+
@Stereotype(groups = "restbucks")
24+
public interface DTO {}

server/src/main/java/de/odrotbohm/restbucks/order/OrderProjection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
/**
2525
* Projection interface to render {@link Order} summaries.
26-
*
26+
*
2727
* @author Oliver Gierke
2828
*/
2929
@Projection(name = "summary", types = Order.class)

server/src/main/java/de/odrotbohm/restbucks/payment/Payment.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ public Receipt getReceipt() {
8080
*
8181
* @author Oliver Gierke
8282
*/
83+
// TODO: Cannot be a ValueObject as Spring Data REST filters association objects and we'd end up with only one
84+
// property to serialize, which would cause unwrapping into the EntityModel.
8385
@Value
8486
public static class Receipt {
8587

server/src/main/java/de/odrotbohm/restbucks/payment/PaymentService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@
2020

2121
import java.util.Optional;
2222

23+
import org.jmolecules.ddd.annotation.Service;
24+
2325
/**
2426
* Interface to collect payment services.
2527
*
2628
* @author Oliver Gierke
2729
*/
30+
@Service
2831
public interface PaymentService {
2932

3033
/**
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
@org.jspecify.annotations.NullMarked
22
package de.odrotbohm.restbucks.payment;
3+

server/src/main/java/de/odrotbohm/restbucks/payment/web/PaymentController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717

1818
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
1919

20+
import de.odrotbohm.restbucks.DTO;
2021
import de.odrotbohm.restbucks.order.Order;
2122
import de.odrotbohm.restbucks.order.Orders;
2223
import de.odrotbohm.restbucks.payment.CreditCardNumber;
2324
import de.odrotbohm.restbucks.payment.Payment;
24-
import de.odrotbohm.restbucks.payment.PaymentService;
2525
import de.odrotbohm.restbucks.payment.Payment.Receipt;
26+
import de.odrotbohm.restbucks.payment.PaymentService;
2627
import lombok.Data;
2728
import lombok.EqualsAndHashCode;
2829
import lombok.NonNull;
@@ -156,7 +157,7 @@ static class PaymentModel extends RepresentationModel<PaymentModel> {
156157

157158
@Value
158159
@RequiredArgsConstructor(onConstructor = @__(@JsonCreator))
159-
static class PaymentForm {
160+
static class PaymentForm implements DTO {
160161
CreditCardNumber number;
161162
}
162163
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"groups" : {
3+
"restbucks" : {
4+
"displayName" : "Restbucks",
5+
"type" : "design"
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)