Skip to content

Commit e293f85

Browse files
committed
value api: remove Value/BeanConverter
- both are replaced by Converter
1 parent 0be56e5 commit e293f85

12 files changed

Lines changed: 5 additions & 375 deletions

File tree

jooby/src/main/java/io/jooby/BeanConverter.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

jooby/src/main/java/io/jooby/Value.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ default boolean isObject() {
367367
*/
368368
@NonNull default <T> Optional<T> toOptional(@NonNull Class<T> type) {
369369
try {
370-
return Optional.ofNullable(to(type));
370+
return Optional.ofNullable(toNullable(type));
371371
} catch (MissingValueException x) {
372372
return Optional.empty();
373373
}

jooby/src/main/java/io/jooby/ValueConverter.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

jooby/src/main/java/io/jooby/internal/RouterImpl.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ public Stack executor(Executor executor) {
157157

158158
private Cookie flashCookie = new Cookie("jooby.flash").setHttpOnly(true);
159159

160-
private LinkedList<ValueConverter> converters;
161-
162-
private List<BeanConverter> beanConverters;
163-
164160
private ContextInitializer preDispatchInitializer;
165161

166162
private ContextInitializer postDispatchInitializer;
@@ -179,9 +175,6 @@ public Stack executor(Executor executor) {
179175

180176
public RouterImpl() {
181177
stack.addLast(new Stack(chi, null));
182-
183-
converters = new LinkedList<>();
184-
beanConverters = new ArrayList<>(3);
185178
}
186179

187180
@NonNull @Override

jooby/src/main/java/io/jooby/internal/SingleValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public <T> Set<T> toSet(@NonNull Class<T> type) {
7878

7979
@NonNull @Override
8080
public <T> Optional<T> toOptional(@NonNull Class<T> type) {
81-
return Optional.of(to(type));
81+
return Optional.ofNullable(toNullable(type));
8282
}
8383

8484
@NonNull @Override

jooby/src/main/java/io/jooby/internal/converter/BuiltinConverter.java

Lines changed: 1 addition & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,16 @@
2929
import io.jooby.SneakyThrows;
3030
import io.jooby.StatusCode;
3131
import io.jooby.Value;
32-
import io.jooby.ValueConverter;
3332
import io.jooby.value.Converter;
3433
import io.jooby.value.ValueFactory;
3534

36-
public enum BuiltinConverter implements ValueConverter<Value>, Converter {
35+
public enum BuiltinConverter implements Converter {
3736
BigDecimal {
3837
@Override
3938
protected void add(ValueFactory factory) {
4039
factory.put(BigDecimal.class, this);
4140
}
4241

43-
@Override
44-
public boolean supports(@NonNull Class<?> type) {
45-
return type == BigDecimal.class;
46-
}
47-
48-
@Override
49-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
50-
return convert(type, value);
51-
}
52-
5342
@Override
5443
public Object convert(@NonNull Type type, @NonNull Value value) {
5544
return new BigDecimal(value.value());
@@ -61,16 +50,6 @@ protected void add(ValueFactory factory) {
6150
factory.put(BigInteger.class, this);
6251
}
6352

64-
@Override
65-
public boolean supports(@NonNull Class<?> type) {
66-
return type == BigInteger.class;
67-
}
68-
69-
@Override
70-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
71-
return convert(type, value);
72-
}
73-
7453
@Override
7554
public Object convert(@NonNull Type type, @NonNull Value value) {
7655
return new BigInteger(value.value());
@@ -82,16 +61,6 @@ protected void add(ValueFactory factory) {
8261
factory.put(Charset.class, this);
8362
}
8463

85-
@Override
86-
public boolean supports(@NonNull Class<?> type) {
87-
return type == Charset.class;
88-
}
89-
90-
@Override
91-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
92-
return convert(type, value);
93-
}
94-
9564
@Override
9665
public Object convert(@NonNull Type type, @NonNull Value value) {
9766
String charset = value.value();
@@ -112,16 +81,6 @@ protected void add(ValueFactory factory) {
11281
factory.put(Date.class, this);
11382
}
11483

115-
@Override
116-
public boolean supports(@NonNull Class<?> type) {
117-
return type == Date.class;
118-
}
119-
120-
@Override
121-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
122-
return convert(type, value);
123-
}
124-
12584
@Override
12685
public Object convert(@NonNull Type type, @NonNull Value value) {
12786
try {
@@ -140,16 +99,6 @@ protected void add(ValueFactory factory) {
14099
factory.put(Duration.class, this);
141100
}
142101

143-
@Override
144-
public boolean supports(@NonNull Class<?> type) {
145-
return type == Duration.class;
146-
}
147-
148-
@Override
149-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
150-
return convert(type, value);
151-
}
152-
153102
@Override
154103
public Object convert(@NonNull Type type, @NonNull Value value) {
155104
try {
@@ -216,16 +165,6 @@ protected void add(ValueFactory factory) {
216165
factory.put(Period.class, this);
217166
}
218167

219-
@Override
220-
public boolean supports(@NonNull Class<?> type) {
221-
return type == Period.class;
222-
}
223-
224-
@Override
225-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
226-
return convert(type, value);
227-
}
228-
229168
@Override
230169
public Object convert(@NonNull Type type, @NonNull Value value) {
231170
try {
@@ -293,16 +232,6 @@ protected void add(ValueFactory factory) {
293232
factory.put(Instant.class, this);
294233
}
295234

296-
@Override
297-
public boolean supports(@NonNull Class<?> type) {
298-
return type == Instant.class;
299-
}
300-
301-
@Override
302-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
303-
return convert(type, value);
304-
}
305-
306235
@Override
307236
public Object convert(@NonNull Type type, @NonNull Value value) {
308237
try {
@@ -318,16 +247,6 @@ protected void add(ValueFactory factory) {
318247
factory.put(LocalDate.class, this);
319248
}
320249

321-
@Override
322-
public boolean supports(@NonNull Class<?> type) {
323-
return type == LocalDate.class;
324-
}
325-
326-
@Override
327-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
328-
return convert(type, value);
329-
}
330-
331250
@Override
332251
public Object convert(@NonNull Type type, @NonNull Value value) {
333252
try {
@@ -346,16 +265,6 @@ protected void add(ValueFactory factory) {
346265
factory.put(LocalDateTime.class, this);
347266
}
348267

349-
@Override
350-
public boolean supports(@NonNull Class<?> type) {
351-
return type == LocalDateTime.class;
352-
}
353-
354-
@Override
355-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
356-
return convert(type, value);
357-
}
358-
359268
@Override
360269
public Object convert(@NonNull Type type, @NonNull Value value) {
361270
try {
@@ -374,16 +283,6 @@ protected void add(ValueFactory factory) {
374283
factory.put(StatusCode.class, this);
375284
}
376285

377-
@Override
378-
public boolean supports(@NonNull Class<?> type) {
379-
return type == StatusCode.class;
380-
}
381-
382-
@Override
383-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
384-
return convert(type, value);
385-
}
386-
387286
@Override
388287
public Object convert(@NonNull Type type, @NonNull Value value) {
389288
return io.jooby.StatusCode.valueOf(value.intValue());
@@ -395,16 +294,6 @@ protected void add(ValueFactory factory) {
395294
factory.put(TimeZone.class, this);
396295
}
397296

398-
@Override
399-
public boolean supports(@NonNull Class<?> type) {
400-
return type == TimeZone.class;
401-
}
402-
403-
@Override
404-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
405-
return convert(type, value);
406-
}
407-
408297
@Override
409298
public Object convert(@NonNull Type type, @NonNull Value value) {
410299
return java.util.TimeZone.getTimeZone(value.value());
@@ -416,16 +305,6 @@ protected void add(ValueFactory factory) {
416305
factory.put(URI.class, this);
417306
}
418307

419-
@Override
420-
public boolean supports(@NonNull Class<?> type) {
421-
return type == URI.class || type == URL.class;
422-
}
423-
424-
@Override
425-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
426-
return convert(type, value);
427-
}
428-
429308
@Override
430309
public Object convert(@NonNull Type type, @NonNull Value value) {
431310
try {
@@ -445,16 +324,6 @@ protected void add(ValueFactory factory) {
445324
factory.put(UUID.class, this);
446325
}
447326

448-
@Override
449-
public boolean supports(@NonNull Class<?> type) {
450-
return type == UUID.class;
451-
}
452-
453-
@Override
454-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
455-
return convert(type, value);
456-
}
457-
458327
@Override
459328
public Object convert(@NonNull Type type, @NonNull Value value) {
460329
return java.util.UUID.fromString(value.value());
@@ -466,16 +335,6 @@ protected void add(ValueFactory factory) {
466335
factory.put(ZoneId.class, this);
467336
}
468337

469-
@Override
470-
public boolean supports(@NonNull Class<?> type) {
471-
return type == ZoneId.class;
472-
}
473-
474-
@Override
475-
public @NonNull Object convert(@NonNull Value value, @NonNull Class<?> type) {
476-
return convert(type, value);
477-
}
478-
479338
@Override
480339
public Object convert(@NonNull Type type, @NonNull Value value) {
481340
var zoneId = value.value();

0 commit comments

Comments
 (0)