Skip to content

Commit d09f372

Browse files
committed
Simplified factory classes.
1 parent 4144d78 commit d09f372

24 files changed

+224
-498
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<!-- testing only -->
3131
<version.junit-jupiter-params>5.10.0</version.junit-jupiter-params>
3232
<version.assertj-core>3.24.2</version.assertj-core>
33-
<version.java-util>2.19.0</version.java-util>
33+
<version.java-util>3.0.0</version.java-util>
3434
<version.gson>2.11.0</version.gson>
3535
<version.jackson-core>2.18.0</version.jackson-core>
3636

src/main/java/com/cedarsoftware/io/factory/EmptyEnumerationFactory.java

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.cedarsoftware.io.factory;
2+
3+
import java.util.Collection;
4+
import java.util.Collections;
5+
import java.util.Enumeration;
6+
import java.util.Iterator;
7+
import java.util.List;
8+
import java.util.ListIterator;
9+
import java.util.Map;
10+
import java.util.NavigableMap;
11+
import java.util.NavigableSet;
12+
import java.util.Set;
13+
import java.util.SortedMap;
14+
import java.util.SortedSet;
15+
16+
import com.cedarsoftware.io.JsonIoException;
17+
import com.cedarsoftware.io.JsonObject;
18+
import com.cedarsoftware.io.JsonReader;
19+
import com.cedarsoftware.io.Resolver;
20+
21+
/**
22+
* @author John DeRegnaucourt ([email protected])
23+
* <br>
24+
* Copyright (c) Cedar Software LLC
25+
* <br><br>
26+
* Licensed under the Apache License, Version 2.0 (the "License");
27+
* you may not use this file except in compliance with the License.
28+
* You may obtain a copy of the License at
29+
* <br><br>
30+
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a>
31+
* <br><br>
32+
* Unless required by applicable law or agreed to in writing, software
33+
* distributed under the License is distributed on an "AS IS" BASIS,
34+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35+
* See the License for the specific language governing permissions and
36+
* limitations under the License.
37+
*/
38+
public class EmptyFactory implements JsonReader.ClassFactory {
39+
public Object newInstance(Class<?> c, JsonObject jObj, Resolver resolver) {
40+
if (NavigableSet.class.isAssignableFrom(c) || SortedSet.class.isAssignableFrom(c)) {
41+
return Collections.emptyNavigableSet();
42+
} else if (Set.class.isAssignableFrom(c)) {
43+
return Collections.emptySet();
44+
} else if (List.class.isAssignableFrom(c) || Collection.class.isAssignableFrom(c)) {
45+
return Collections.emptyList();
46+
} else if (NavigableMap.class.isAssignableFrom(c) || SortedMap.class.isAssignableFrom(c)) {
47+
return Collections.emptyNavigableMap();
48+
} else if (Map.class.isAssignableFrom(c)) {
49+
return Collections.emptyMap();
50+
} else if (ListIterator.class.isAssignableFrom(c)) {
51+
return Collections.emptyListIterator();
52+
} else if (Iterator.class.isAssignableFrom(c)) {
53+
return Collections.emptyIterator();
54+
} else if (Enumeration.class.isAssignableFrom(c)) {
55+
return Collections.emptyEnumeration();
56+
}
57+
throw new JsonIoException("EmptyFactory handed Class for which it was not expecting: " + c.getName());
58+
}
59+
}
60+

src/main/java/com/cedarsoftware/io/factory/EmptyIteratorFactory.java

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

src/main/java/com/cedarsoftware/io/factory/EmptyListFactory.java

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

src/main/java/com/cedarsoftware/io/factory/EmptyListIteratorFactory.java

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

src/main/java/com/cedarsoftware/io/factory/EmptyMapFactory.java

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

src/main/java/com/cedarsoftware/io/factory/EmptyNavigableMapFactory.java

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

src/main/java/com/cedarsoftware/io/factory/EmptyNavigableSetFactory.java

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

src/main/java/com/cedarsoftware/io/factory/EmptySetFactory.java

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

0 commit comments

Comments
 (0)