Java 类org.bson.codecs.configuration.CodecProvider 实例源码

项目:bsoncodec-apt    文件:ProviderCodeGenerator.java   
public void generate(Appendable appendable) throws IOException {
    int pos = this.fullyQualifiedName.lastIndexOf(".");
    String className;
    String packageName;
    if (pos > 0) {
        packageName = this.fullyQualifiedName.substring(0, pos);
        className = this.fullyQualifiedName.substring(pos + 1);
    }
    else {
        packageName = "";
        className = this.fullyQualifiedName;
    }
    Builder classBuilder = TypeSpec.classBuilder(className);
    classBuilder.addModifiers(Modifier.PUBLIC, Modifier.FINAL);
    classBuilder.addSuperinterface(CodecProvider.class);

    addInstanceFields(classBuilder);
    addConstructor(classBuilder);
    addGetMethod(classBuilder);

    JavaFile javaFile = JavaFile.builder(packageName, classBuilder.build()).build();
    javaFile.writeTo(appendable);
}
项目:mongo-mapper    文件:MongoMapperTest.java   
@Test
public void testMongoMapper() throws Exception {
    List<CodecProvider> providers = MongoMapper.getProviders();
    Assert.assertFalse(providers.isEmpty());

    int size = providers.size();
    // Check for unmodifiable list.
    providers.add(new CustomFieldCodecProvider());

    MongoMapper.addProvider(new CustomFieldCodecProvider());
    providers = MongoMapper.getProviders();
    Assert.assertEquals(size + 1, providers.size());
}
项目:mongo-mapper    文件:MongoMapper.java   
public static List<CodecProvider> getProviders() {
    return (ArrayList) providers.clone();
}
项目:mongo-mapper    文件:MongoMapper.java   
public static void addProvider(CodecProvider provider) {
    providers.add(provider);
}