Java 类com.alibaba.fastjson.serializer.PropertyFilter 实例源码

项目:GitHub    文件:PropertyFilter_bool_field.java   
public void test_0() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{}", text);
}
项目:GitHub    文件:PropertyFilter_bool_field.java   
public void test_1() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("id".equals(name)) {
                Assert.assertTrue(value instanceof Boolean);
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"id\":false}", text);
}
项目:GitHub    文件:PropertyFilter_bool_field.java   
public void test_2() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    a.name = "chennp2008";
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_bool_field.java   
public void test_3() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_bool_field.java   
public void test_4() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return false;
            }
            return true;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 3);
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"id\":3}", text);
}
项目:GitHub    文件:PropertyFilter_short.java   
public void test_0() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{}", text);
}
项目:GitHub    文件:PropertyFilter_short.java   
public void test_1() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("id".equals(name)) {
                Assert.assertTrue(value instanceof Short);
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"id\":0}", text);
}
项目:GitHub    文件:PropertyFilter_short.java   
public void test_2() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    a.setName("chennp2008");
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_short.java   
public void test_3() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_short.java   
public void test_4() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return false;
            }
            return true;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 3);
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"id\":3}", text);
}
项目:GitHub    文件:PropertyFilter_char.java   
public void test_0() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{}", text);
}
项目:GitHub    文件:PropertyFilter_char.java   
public void test_1() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("id".equals(name)) {
                Assert.assertTrue(value instanceof Character);
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"id\":\"0\"}", text);
}
项目:GitHub    文件:PropertyFilter_char.java   
public void test_2() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    a.setName("chennp2008");
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_char.java   
public void test_3() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_char.java   
public void test_4() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return false;
            }
            return true;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", (char) '3');
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"id\":\"3\"}", text);
}
项目:GitHub    文件:PropertyFilter_long_field.java   
public void test_0() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{}", text);
}
项目:GitHub    文件:PropertyFilter_long_field.java   
public void test_1() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("id".equals(name)) {
                Assert.assertTrue(value instanceof Long);
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"id\":0}", text);
}
项目:GitHub    文件:PropertyFilter_long_field.java   
public void test_2() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    a.name = "chennp2008";
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_long_field.java   
public void test_3() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_long_field.java   
public void test_4() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return false;
            }
            return true;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 3);
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"id\":3}", text);
}
项目:GitHub    文件:PropertyFilter_byte.java   
public void test_0() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{}", text);
}
项目:GitHub    文件:PropertyFilter_byte.java   
public void test_1() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("id".equals(name)) {
                Assert.assertTrue(value instanceof Byte);
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"id\":0}", text);
}
项目:GitHub    文件:PropertyFilter_byte.java   
public void test_2() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    a.setName("chennp2008");
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_byte.java   
public void test_3() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_byte.java   
public void test_4() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return false;
            }
            return true;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 3);
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"id\":3}", text);
}
项目:GitHub    文件:PropertyFilter_long.java   
public void test_0() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{}", text);
}
项目:GitHub    文件:PropertyFilter_long.java   
public void test_1() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("id".equals(name)) {
                Assert.assertTrue(value instanceof Long);
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"id\":0}", text);
}
项目:GitHub    文件:PropertyFilter_long.java   
public void test_2() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    a.setName("chennp2008");
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_long.java   
public void test_3() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_long.java   
public void test_4() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return false;
            }
            return true;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 3);
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"id\":3}", text);
}
项目:GitHub    文件:PropertyFilter_double.java   
public void test_0() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{}", text);
}
项目:GitHub    文件:PropertyFilter_double.java   
public void test_1() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("id".equals(name)) {
                Assert.assertTrue(value instanceof Double);
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"id\":0.0}", text);
}
项目:GitHub    文件:PropertyFilter_double.java   
public void test_2() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    a.setName("chennp2008");
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_double.java   
public void test_3() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilter_double.java   
public void test_4() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return false;
            }
            return true;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 3);
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"id\":3}", text);
}
项目:GitHub    文件:PropertyFilterTest.java   
public void test_0() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{}", text);
}
项目:GitHub    文件:PropertyFilterTest.java   
public void test_1() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("id".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"id\":0}", text);
}
项目:GitHub    文件:PropertyFilterTest.java   
public void test_2() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    A a = new A();
    a.setName("chennp2008");
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilterTest.java   
public void test_3() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return true;
            }
            return false;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
}
项目:GitHub    文件:PropertyFilterTest.java   
public void test_4() throws Exception {
    PropertyFilter filter = new PropertyFilter() {

        public boolean apply(Object source, String name, Object value) {
            if ("name".equals(name)) {
                return false;
            }
            return true;
        }
    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getPropertyFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 3);
    map.put("name", "chennp2008");
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"id\":3}", text);
}