Skip to content

Commit 22478c4

Browse files
removing oop NULL like the colossal mistake it was...
1 parent 11351a3 commit 22478c4

File tree

6 files changed

+10
-18
lines changed

6 files changed

+10
-18
lines changed

SerialX-core/src/main/java/org/ugp/serialx/GenericScope.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import java.util.function.Function;
1717
import java.util.function.Predicate;
1818

19-
import org.ugp.serialx.Utils.NULL;
2019
import org.ugp.serialx.converters.DataParser;
2120
import org.ugp.serialx.protocols.SerializationProtocol;
2221
import org.ugp.serialx.protocols.SerializationProtocol.ProtocolRegistry;
@@ -277,7 +276,7 @@ public <V extends ValT> V get(KeyT variableKey, V defaultValue)
277276
V obj = (V) variables().get(variableKey);
278277
if (obj == null)
279278
return defaultValue;
280-
return obj instanceof NULL ? null : obj;
279+
return obj;
281280
}
282281

283282
/**
@@ -388,8 +387,7 @@ public boolean containsIndependentValue(ValT value)
388387
@SuppressWarnings("unchecked")
389388
public <V extends ValT> V get(int valueIndex)
390389
{
391-
V obj = (V) values().get(valueIndex < 0 ? valuesCount() + valueIndex : valueIndex);
392-
return obj instanceof NULL ? null : obj;
390+
return (V) values().get(valueIndex < 0 ? valuesCount() + valueIndex : valueIndex);
393391
}
394392

395393
/**
@@ -600,7 +598,6 @@ public <V> GenericScope<KeyT, V> transform(Function<ValT, V> trans, boolean incl
600598
try
601599
{
602600
Object obj = ent.getValue();
603-
obj = obj instanceof NULL ? null : obj;
604601
if (obj instanceof GenericScope && includeSubScopes)
605602
{
606603
GenericScope<?, V> sc = ((GenericScope<?, ValT>) obj).transform(trans, includeSubScopes);
@@ -655,8 +652,7 @@ public <V> List<V> map(Function<ValT, V> trans, boolean includeSubScopes)
655652
List<V> fltVals = new ArrayList<>();
656653
for (Object obj : this)
657654
try
658-
{
659-
obj = obj instanceof NULL ? null : obj;
655+
{
660656
if (obj instanceof GenericScope && includeSubScopes)
661657
{
662658
GenericScope<?, V> sc = ((GenericScope<?, ValT>) obj).transform(trans, includeSubScopes);

SerialX-core/src/main/java/org/ugp/serialx/Serializer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ else if (multLineCom <= -1 && ch == '"')
653653
if (semicolon > index)
654654
{
655655
lineReader.close();
656-
return (T) NULL.toOopNull(DataParser.parseObj(DataParser.REGISTRY, sb.toString(), this));
656+
return (T) DataParser.parseObj(DataParser.REGISTRY, sb.toString(), this);
657657
}
658658
659659
if (multLineCom > -1 || com > -1) //Is comment
@@ -722,7 +722,7 @@ else if (ch == '}' || ch == ']')
722722
else if (quote % 2 != 0)
723723
throw new IllegalArgumentException("Unclosed or missing quotes!");
724724
else if (!(line = sb.toString()).isEmpty())
725-
return (T) NULL.toOopNull(DataParser.parseObj(DataParser.REGISTRY, line, this));
725+
return (T) DataParser.parseObj(DataParser.REGISTRY, line, this);
726726
LogProvider.instance.logErr("Value with index " + index + " is out of bounds!");
727727
return null;
728728
}
@@ -808,7 +808,7 @@ else if (multLineCom <= -1 && ch == '"')
808808
int start = sb.indexOf("=", findIndex-fromIndexOrig);
809809
if (start <= -1)
810810
start = sb.indexOf(":", findIndex-fromIndexOrig);
811-
return (T) NULL.toOopNull(DataParser.parseObj(DataParser.REGISTRY, sb.substring(start+1), this));
811+
return (T) DataParser.parseObj(DataParser.REGISTRY, sb.substring(start+1), this);
812812
}
813813
814814
if (multLineCom > -1 || com > -1) //Is comment

SerialX-core/src/main/java/org/ugp/serialx/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ else if (obj.getClass() == String.class)
261261
{
262262
ParserRegistry parsers = parsersToUse instanceof ParserRegistry ? (ParserRegistry) parsersToUse : new ParserRegistry(parsersToUse);
263263

264-
Object cln = NULL.toOopNull(parsers.parse(parsers.toString(obj, converterArgs).toString(), parserArgs));
264+
Object cln = parsers.parse(parsers.toString(obj, converterArgs).toString(), parserArgs);
265265
if (cln != null && cln != VOID)
266266
return (T) cln;
267267

SerialX-core/src/main/java/org/ugp/serialx/converters/NullConverter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.ugp.serialx.converters;
22

3-
import org.ugp.serialx.Utils.NULL;
4-
53
/**
64
* This converter is capable of converting "nothing" otherwise known as null and {@link DataParser#VOID}.
75
* Its case insensitive!
@@ -48,7 +46,7 @@ public Object parse(ParserRegistry registry, String str, Object... args)
4846
@Override
4947
public CharSequence toString(ParserRegistry myHomeRegistry, Object obj, Object... args)
5048
{
51-
if (obj == null || obj instanceof NULL)
49+
if (obj == null)
5250
return "null";
5351
return CONTINUE;
5452
}

SerialX-juss/src/main/java/org/ugp/serialx/juss/JussSerializer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.ugp.serialx.Registry;
3030
import org.ugp.serialx.Scope;
3131
import org.ugp.serialx.Serializer;
32-
import org.ugp.serialx.Utils.NULL;
3332
import org.ugp.serialx.converters.BooleanConverter;
3433
import org.ugp.serialx.converters.CharacterConverter;
3534
import org.ugp.serialx.converters.DataConverter;
@@ -676,7 +675,7 @@ else if (brackets > 0)
676675
*/
677676
protected Object parseObject(ParserRegistry registry, String str, Object... parserArgs)
678677
{
679-
return NULL.toOopNull(registry.parse(str, parserArgs));
678+
return registry.parse(str, parserArgs);
680679
}
681680

682681
/**

SerialX-operators/src/main/java/org/ugp/serialx/converters/operators/ConditionalAssignmentOperators.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import static org.ugp.serialx.Utils.indexOfNotInObj;
44

55
import org.ugp.serialx.LogProvider;
6-
import org.ugp.serialx.Utils.NULL;
76
import org.ugp.serialx.converters.DataParser;
87

98
/**
@@ -45,7 +44,7 @@ public Object parse(ParserRegistry myHomeRegistry, String str, Object... args)
4544
if ((index = str.indexOf("??")) > -1)
4645
{
4746
Object obj = myHomeRegistry.parse(str.substring(0, index).trim(), args);
48-
if (obj != null && !(obj instanceof NULL))
47+
if (obj != null)
4948
return obj;
5049

5150
String next = str.substring(index+2);

0 commit comments

Comments
 (0)