IntelliJ Inspect various improvements

This commit is contained in:
Rob Bygrave committed 2022-08-27 22:37:48 +12:00
1 parent 81ef967d9f
commit 0c2ab729bc
5 files changed
+5 -20

No files matched your search

@@ -780,6 +780,7 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
} }
} }
@SuppressWarnings("unchecked")
@Override @Override
public void jsonRead(SpiJsonReader readJson, EntityBean bean) throws IOException { public void jsonRead(SpiJsonReader readJson, EntityBean bean) throws IOException {
if (jsonDeserialize && targetDescriptor != null) { if (jsonDeserialize && targetDescriptor != null) {
@@ -106,10 +106,7 @@ final class ReadAnnotationConfig {
if (javaxValidation != null && javaxValidation.isValidationNotNull(property)) { if (javaxValidation != null && javaxValidation.isValidationNotNull(property)) {
return true; return true;
} }
if (jakartaValidation != null && jakartaValidation.isValidationNotNull(property)) { return jakartaValidation != null && jakartaValidation.isValidationNotNull(property);
return true;
}
return false;
} }
/** /**
@@ -122,7 +122,6 @@ public final class DJsonContext implements SpiJsonContext {
@Override @Override
public <T> T toBean(Class<T> cls, JsonParser parser, JsonReadOptions options) throws JsonIOException { public <T> T toBean(Class<T> cls, JsonParser parser, JsonReadOptions options) throws JsonIOException {
BeanDescriptor<T> desc = getDescriptor(cls); BeanDescriptor<T> desc = getDescriptor(cls);
try { try {
return desc.jsonRead(new ReadJson(desc, parser, options, determineObjectMapper(options), false), null, null); return desc.jsonRead(new ReadJson(desc, parser, options, determineObjectMapper(options), false), null, null);
@@ -156,9 +155,9 @@ public final class DJsonContext implements SpiJsonContext {
toBean(target, parser, null); toBean(target, parser, null);
} }
@SuppressWarnings("unchecked")
@Override @Override
public <T> void toBean(T target, JsonParser parser, JsonReadOptions options) throws JsonIOException { public <T> void toBean(T target, JsonParser parser, JsonReadOptions options) throws JsonIOException {
BeanDescriptor<T> desc = (BeanDescriptor<T>) getDescriptor(target.getClass()); BeanDescriptor<T> desc = (BeanDescriptor<T>) getDescriptor(target.getClass());
try { try {
desc.jsonRead(new ReadJson(desc, parser, options, determineObjectMapper(options), target != null), null, target); desc.jsonRead(new ReadJson(desc, parser, options, determineObjectMapper(options), target != null), null, target);
@@ -169,14 +168,12 @@ public final class DJsonContext implements SpiJsonContext {
@Override @Override
public <T> DJsonBeanReader<T> createBeanReader(Class<T> cls, JsonParser parser, JsonReadOptions options) throws JsonIOException { public <T> DJsonBeanReader<T> createBeanReader(Class<T> cls, JsonParser parser, JsonReadOptions options) throws JsonIOException {
BeanDescriptor<T> desc = getDescriptor(cls); BeanDescriptor<T> desc = getDescriptor(cls);
return new DJsonBeanReader<>(desc, new ReadJson(desc, parser, options, determineObjectMapper(options), false)); return new DJsonBeanReader<>(desc, new ReadJson(desc, parser, options, determineObjectMapper(options), false));
} }
@Override @Override
public <T> DJsonBeanReader<T> createBeanReader(BeanType<T> beanType, JsonParser parser, JsonReadOptions options) throws JsonIOException { public <T> DJsonBeanReader<T> createBeanReader(BeanType<T> beanType, JsonParser parser, JsonReadOptions options) throws JsonIOException {
BeanDescriptor<T> desc = (BeanDescriptor<T>) beanType; BeanDescriptor<T> desc = (BeanDescriptor<T>) beanType;
SpiJsonReader readJson = new ReadJson(desc, parser, options, determineObjectMapper(options), false); SpiJsonReader readJson = new ReadJson(desc, parser, options, determineObjectMapper(options), false);
return new DJsonBeanReader<>(desc, readJson); return new DJsonBeanReader<>(desc, readJson);
@@ -209,7 +206,6 @@ public final class DJsonContext implements SpiJsonContext {
@Override @Override
public <T> List<T> toList(Class<T> cls, JsonParser src, JsonReadOptions options) throws JsonIOException { public <T> List<T> toList(Class<T> cls, JsonParser src, JsonReadOptions options) throws JsonIOException {
BeanDescriptor<T> desc = getDescriptor(cls); BeanDescriptor<T> desc = getDescriptor(cls);
SpiJsonReader readJson = new ReadJson(desc, src, options, determineObjectMapper(options), false); SpiJsonReader readJson = new ReadJson(desc, src, options, determineObjectMapper(options), false);
try { try {
@@ -241,19 +237,16 @@ public final class DJsonContext implements SpiJsonContext {
@Override @Override
public Object toObject(Type genericType, String json) throws JsonIOException { public Object toObject(Type genericType, String json) throws JsonIOException {
return toObject(genericType, createParser(new StringReader(json))); return toObject(genericType, createParser(new StringReader(json)));
} }
@Override @Override
public Object toObject(Type genericType, Reader json) throws JsonIOException { public Object toObject(Type genericType, Reader json) throws JsonIOException {
return toObject(genericType, createParser(json)); return toObject(genericType, createParser(json));
} }
@Override @Override
public Object toObject(Type genericType, JsonParser jsonParser) throws JsonIOException { public Object toObject(Type genericType, JsonParser jsonParser) throws JsonIOException {
TypeInfo info = ParamTypeHelper.getTypeInfo(genericType); TypeInfo info = ParamTypeHelper.getTypeInfo(genericType);
ManyType manyType = info.getManyType(); ManyType manyType = info.getManyType();
switch (manyType) { switch (manyType) {
@@ -362,7 +355,6 @@ public final class DJsonContext implements SpiJsonContext {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private void toJsonInternal(Object value, JsonGenerator gen, JsonWriteOptions options) throws IOException { private void toJsonInternal(Object value, JsonGenerator gen, JsonWriteOptions options) throws IOException {
if (value == null) { if (value == null) {
gen.writeNull(); gen.writeNull();
} else if (value instanceof Number) { } else if (value instanceof Number) {
@@ -392,7 +384,6 @@ public final class DJsonContext implements SpiJsonContext {
@Override @Override
public SpiJsonReader createJsonRead(BeanType<?> beanType, String json) { public SpiJsonReader createJsonRead(BeanType<?> beanType, String json) {
BeanDescriptor<?> desc = (BeanDescriptor<?>) beanType; BeanDescriptor<?> desc = (BeanDescriptor<?>) beanType;
JsonParser parser = createParser(new StringReader(json)); JsonParser parser = createParser(new StringReader(json));
return new ReadJson(desc, parser, null, defaultObjectMapper, false); return new ReadJson(desc, parser, null, defaultObjectMapper, false);
@@ -415,7 +406,6 @@ public final class DJsonContext implements SpiJsonContext {
} }
private <T> void toJsonFromCollection(Collection<T> collection, String key, JsonGenerator gen, JsonWriteOptions options) throws IOException { private <T> void toJsonFromCollection(Collection<T> collection, String key, JsonGenerator gen, JsonWriteOptions options) throws IOException {
if (key != null) { if (key != null) {
gen.writeFieldName(key); gen.writeFieldName(key);
} }
@@ -429,7 +419,6 @@ public final class DJsonContext implements SpiJsonContext {
} }
private void toJsonFromMap(Map<Object, Object> map, JsonGenerator gen, JsonWriteOptions options) throws IOException { private void toJsonFromMap(Map<Object, Object> map, JsonGenerator gen, JsonWriteOptions options) throws IOException {
Set<Entry<Object, Object>> entrySet = map.entrySet(); Set<Entry<Object, Object>> entrySet = map.entrySet();
Iterator<Entry<Object, Object>> it = entrySet.iterator(); Iterator<Entry<Object, Object>> it = entrySet.iterator();
@@ -480,10 +480,8 @@ public final class OrmQueryDetail implements Serializable {
if (create && props == null) { if (create && props == null) {
props = new OrmQueryProperties(path); props = new OrmQueryProperties(path);
fetch(props); fetch(props);
return props;
} else {
return props;
} }
return props;
} }
/** /**
@@ -161,7 +161,7 @@ class ScalarTypeArrayList extends ScalarTypeArrayBase<List> implements ScalarTyp
/** /**
* Convert from the json types to the proper scalar types (uuid, enum, double etc) * Convert from the json types to the proper scalar types (uuid, enum, double etc)
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings({"rawtypes", "unchecked"})
private List convert(List<Object> rawList) { private List convert(List<Object> rawList) {
List list = new ArrayList(rawList.size()); List list = new ArrayList(rawList.size());
for (Object rawVal : rawList) { for (Object rawVal : rawList) {