当前位置: 首页>>代码示例>>Java>>正文


Java PropertyFilter类代码示例

本文整理汇总了Java中com.alibaba.fastjson.serializer.PropertyFilter的典型用法代码示例。如果您正苦于以下问题:Java PropertyFilter类的具体用法?Java PropertyFilter怎么用?Java PropertyFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PropertyFilter类属于com.alibaba.fastjson.serializer包,在下文中一共展示了PropertyFilter类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_0

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:PropertyFilter_bool_field.java

示例2: test_1

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PropertyFilter_bool_field.java

示例3: test_2

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PropertyFilter_bool_field.java

示例4: test_3

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PropertyFilter_bool_field.java

示例5: test_4

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:PropertyFilter_bool_field.java

示例6: test_1

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PropertyFilter_short.java

示例7: test_2

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PropertyFilter_short.java

示例8: test_1

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PropertyFilter_char.java

示例9: test_4

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:PropertyFilter_char.java

示例10: test_1

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PropertyFilter_long_field.java

示例11: test_1

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PropertyFilter_byte.java

示例12: test_1

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:PropertyFilter_double.java

示例13: test_1

import com.alibaba.fastjson.serializer.PropertyFilter; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:PropertyFilterTest.java


注:本文中的com.alibaba.fastjson.serializer.PropertyFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。