• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

burningwave / json / #7

25 Oct 2023 06:36AM UTC coverage: 45.756% (-3.2%) from 48.947%
#7

push

Roberto-Gentili
Releasing new version

372 of 813 relevant lines covered (45.76%)

0.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.56
/src/main/java/org/burningwave/json/Facade.java
1
/*
2
 * This file is part of Burningwave JSON.
3
 *
4
 * Author: Roberto Gentili
5
 *
6
 * Hosted at: https://github.com/burningwave/json
7
 *
8
 * --
9
 *
10
 * The MIT License (MIT)
11
 *
12
 * Copyright (c) 2023 Roberto Gentili
13
 *
14
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
15
 * documentation files (the "Software"), to deal in the Software without restriction, including without
16
 * limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
17
 * the Software, and to permit persons to whom the Software is furnished to do so, subject to the following
18
 * conditions:
19
 *
20
 * The above copyright notice and this permission notice shall be included in all copies or substantial
21
 * portions of the Software.
22
 *
23
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24
 * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
25
 * EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
27
 * OR OTHER DEALINGS IN THE SOFTWARE.
28
 */
29
package org.burningwave.json;
30

31
import java.io.File;
32
import java.io.InputStream;
33
import java.io.Reader;
34
import java.net.URL;
35

36
import org.burningwave.Executor;
37

38
import com.fasterxml.jackson.databind.ObjectMapper;
39

40
public class Facade {
41

42
        private ObjectMapper objectMapper;
43
        private Validator validator;
44
        private SchemaHolder schemaHolder;
45

46
        private Facade() {
47
                this(new ObjectMapper());
1✔
48
        }
1✔
49

50
        private Facade(ObjectMapper objectMapper) {
1✔
51
                this.objectMapper = objectMapper;
1✔
52
                this.schemaHolder = new SchemaHolder(objectMapper);
1✔
53
                this.validator = new Validator(
1✔
54
                        this.schemaHolder
55
                );
56
        }
1✔
57

58
        public static Facade create() {
59
                return new Facade();
1✔
60
        }
61

62
        public static Facade create(ObjectMapper objectMapper) {
63
                return new Facade(objectMapper);
×
64
        }
65

66
        public ObjectMapper objectMapper() {
67
                return objectMapper;
×
68
        }
69

70
        public ObjectHandler newObjectHandler(Object jsonObject) {
71
                return ObjectHandler.create(objectMapper, jsonObject);
×
72
        }
73

74
        public <T> ObjectHandler newObjectHandler(byte[] src, Class<T> type) {
75
                return Executor.get(() -> ObjectHandler.create(objectMapper, objectMapper.readValue(src, type)));
×
76
        }
77

78
        public <T> ObjectHandler newObjectHandler(File src, Class<T> type) {
79
                return Executor.get(() -> ObjectHandler.create(objectMapper, objectMapper.readValue(src, type)));
×
80
        }
81

82
        public <T> ObjectHandler newObjectHandler(InputStream src, Class<T> type) {
83
                return Executor.get(() -> ObjectHandler.create(objectMapper, objectMapper.readValue(src, type)));
1✔
84
        }
85

86
        public <T> ObjectHandler newObjectHandler(Reader src, Class<T> type) {
87
                return Executor.get(() -> ObjectHandler.create(objectMapper, objectMapper.readValue(src, type)));
×
88
        }
89

90
        public <T> ObjectHandler newObjectHandler(String src, Class<T> type) {
91
                return Executor.get(() -> ObjectHandler.create(objectMapper, objectMapper.readValue(src, type)));
×
92
        }
93

94
        public <T> ObjectHandler newObjectHandler(URL src, Class<T> type) {
95
                return Executor.get(() -> ObjectHandler.create(objectMapper, objectMapper.readValue(src, type)));
×
96
        }
97

98
        public Validator validator() {
99
                return this.validator;
1✔
100
        }
101

102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc