Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Apr 18, 2016
1 parent f2f830e commit 34342be
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 140 deletions.
22 changes: 4 additions & 18 deletions src/main/java/com/alibaba/fastjson/serializer/JSONSerializer.java
Expand Up @@ -151,14 +151,6 @@ public final boolean isWriteClassName(Type fieldType, Object obj) {
|| context.parent != null);
}

public SerialContext getSerialContext(Object object) {
if (references == null) {
return null;
}

return references.get(object);
}

public boolean containsReference(Object value) {
return references != null && references.containsKey(value);
}
Expand Down Expand Up @@ -191,17 +183,11 @@ public void writeReference(Object object) {

if (object == rootContext.object) {
out.write("{\"$ref\":\"$\"}");
return;
} else {
out.write("{\"$ref\":\"");
out.write(references.get(object).toString());
out.write("\"}");
}

SerialContext refContext = this.getSerialContext(object);

String path = refContext.toString();

out.write("{\"$ref\":\"");
out.write(path);
out.write("\"}");
return;
}

public List<ValueFilter> getValueFilters() {
Expand Down

This file was deleted.

15 changes: 3 additions & 12 deletions src/main/java/com/alibaba/fastjson/serializer/Labels.java
Expand Up @@ -42,20 +42,11 @@ public DefaultLabelFilter(String[] includes, String[] excludes){

public boolean apply(String label) {
if (excludes != null) {
if (Arrays.binarySearch(excludes, label) >= 0) {
return false;
}
return Arrays.binarySearch(excludes, label) == -1;

This comment has been minimized.

Copy link
@SongXueZhi

SongXueZhi Nov 8, 2021

inducing regression

}

if (includes != null) {
if (Arrays.binarySearch(includes, label) >= 0) {
return true;
}

return false;
}

return true;
return includes != null //
&& Arrays.binarySearch(includes, label) >= 0;
}
}

Expand Down
11 changes: 0 additions & 11 deletions src/main/java/com/alibaba/fastjson/serializer/SerialContext.java
Expand Up @@ -6,14 +6,12 @@ public class SerialContext {
public final Object object;
public final Object fieldName;
public final int features;
private int fieldFeatures;

public SerialContext(SerialContext parent, Object object, Object fieldName, int features, int fieldFeatures){
this.parent = parent;
this.object = object;
this.fieldName = fieldName;
this.features = features;
this.fieldFeatures = fieldFeatures;
}

public String toString() {
Expand All @@ -28,13 +26,4 @@ public String toString() {

}
}

public int getFeatures() {
return features;
}

public boolean isEnabled(SerializerFeature feature) {
int mask = feature.mask;
return (features & mask) != 0 || (fieldFeatures & mask) != 0;
}
}

This file was deleted.

2 changes: 0 additions & 2 deletions src/test/java/com/alibaba/json/bvt/serializer/RefTest.java
Expand Up @@ -12,8 +12,6 @@ public class RefTest extends TestCase {

public void test_ref() throws Exception {
JSONSerializer ser = new JSONSerializer();
Assert.assertNull(ser.getSerialContext(null));

Assert.assertFalse(ser.containsReference(null));
}

Expand Down

0 comments on commit 34342be

Please sign in to comment.