1 package org.imageconverter.infra.exception;
2
3 import java.text.NumberFormat;
4
5 public class ElementWithIdNotFoundException extends ElementNotFoundException {
6
7 private static final long serialVersionUID = 1L;
8
9 public <T> ElementWithIdNotFoundException(final Class<T> cls, final Object id) {
10 super("{exception.elementIdNotFound}", new Object[] { cls.getSimpleName(), formatNumber(id) });
11 }
12
13 public static Object formatNumber(final Object id) {
14
15 if (id instanceof Number number) {
16
17 final var format = NumberFormat.getInstance();
18 format.setGroupingUsed(false);
19
20 return format.format(number);
21 }
22
23 return id;
24 }
25 }