Package com.google.gson

Examples of com.google.gson.FieldNamingStrategy


         MapTypeAdapterFactory map, MultimapTypeAdapterFactory multimap, IterableTypeAdapterFactory iterable,
         CollectionTypeAdapterFactory collection, ListTypeAdapterFactory list,
         ImmutableListTypeAdapterFactory immutableList, FluentIterableTypeAdapterFactory fluentIterable,
         DefaultExclusionStrategy exclusionStrategy) {

      FieldNamingStrategy serializationPolicy = new AnnotationOrNameFieldNamingStrategy(ImmutableSet.of(
            new ExtractSerializedName(), new ExtractNamed()));

      GsonBuilder builder = new GsonBuilder().setFieldNamingStrategy(serializationPolicy)
                                             .setExclusionStrategies(exclusionStrategy);
View Full Code Here


   Gson gson = new Gson();

   DeserializationConstructorAndReflectiveTypeAdapterFactory parameterizedCtorFactory = parameterizedCtorFactory();

   static DeserializationConstructorAndReflectiveTypeAdapterFactory parameterizedCtorFactory() {
      FieldNamingStrategy serializationPolicy = new AnnotationOrNameFieldNamingStrategy(ImmutableSet.of(
            new ExtractSerializedName(), new ExtractNamed()));
      NamingStrategies.AnnotationConstructorNamingStrategy deserializationPolicy = new NamingStrategies.AnnotationConstructorNamingStrategy(
            ImmutableSet.of(ConstructorProperties.class, Inject.class), ImmutableSet.of(new ExtractNamed()));

      return new DeserializationConstructorAndReflectiveTypeAdapterFactory(new ConstructorConstructor(),
View Full Code Here

         MapTypeAdapterFactory map, MultimapTypeAdapterFactory multimap, IterableTypeAdapterFactory iterable,
         CollectionTypeAdapterFactory collection, ListTypeAdapterFactory list,
         ImmutableListTypeAdapterFactory immutableList, FluentIterableTypeAdapterFactory fluentIterable,
         DefaultExclusionStrategy exclusionStrategy) {

      FieldNamingStrategy serializationPolicy = new AnnotationOrNameFieldNamingStrategy(ImmutableSet.of(
            new ExtractSerializedName(), new ExtractNamed()));

      GsonBuilder builder = new GsonBuilder().setFieldNamingStrategy(serializationPolicy)
                                             .setExclusionStrategies(exclusionStrategy);
View Full Code Here

   Gson gson = new Gson();

   DeserializationConstructorAndReflectiveTypeAdapterFactory parameterizedCtorFactory = parameterizedCtorFactory();

   static DeserializationConstructorAndReflectiveTypeAdapterFactory parameterizedCtorFactory() {
      FieldNamingStrategy serializationPolicy = new AnnotationOrNameFieldNamingStrategy(ImmutableSet.of(
            new ExtractSerializedName(), new ExtractNamed()));
      NamingStrategies.AnnotationConstructorNamingStrategy deserializationPolicy = new NamingStrategies.AnnotationConstructorNamingStrategy(
            ImmutableSet.of(ConstructorProperties.class, Inject.class), ImmutableSet.of(new ExtractNamed()));

      return new DeserializationConstructorAndReflectiveTypeAdapterFactory(new ConstructorConstructor(ImmutableMap.<Type, InstanceCreator<?>>of()),
View Full Code Here

public final class GsonMessageBodyReaderWriter implements MessageBodyWriter<Object>, MessageBodyReader<Object> {
    private Gson gson;

    private Gson getGson() {
        if (gson == null) {
            FieldNamingStrategy fieldNamingStrategy = new GsonFieldNamingStrategy();

            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.setFieldNamingStrategy(fieldNamingStrategy);

            gsonBuilder.registerTypeAdapter(Date.class, new DateTypeAdapter());
View Full Code Here

         MapTypeAdapterFactory map, MultimapTypeAdapterFactory multimap, IterableTypeAdapterFactory iterable,
         CollectionTypeAdapterFactory collection, ListTypeAdapterFactory list,
         ImmutableListTypeAdapterFactory immutableList, FluentIterableTypeAdapterFactory fluentIterable,
         DefaultExclusionStrategy exclusionStrategy) {

      FieldNamingStrategy serializationPolicy = new AnnotationOrNameFieldNamingStrategy(ImmutableSet.of(
            new ExtractSerializedName(), new ExtractNamed()));

      GsonBuilder builder = new GsonBuilder().setFieldNamingStrategy(serializationPolicy)
                                             .setExclusionStrategies(exclusionStrategy);
View Full Code Here

   Gson gson = new Gson();

   DeserializationConstructorAndReflectiveTypeAdapterFactory parameterizedCtorFactory = parameterizedCtorFactory();

   static DeserializationConstructorAndReflectiveTypeAdapterFactory parameterizedCtorFactory() {
      FieldNamingStrategy serializationPolicy = new AnnotationOrNameFieldNamingStrategy(ImmutableSet.of(
            new ExtractSerializedName(), new ExtractNamed()));
      NamingStrategies.AnnotationConstructorNamingStrategy deserializationPolicy = new NamingStrategies.AnnotationConstructorNamingStrategy(
            ImmutableSet.of(ConstructorProperties.class, Inject.class), ImmutableSet.of(new ExtractNamed()));

      return new DeserializationConstructorAndReflectiveTypeAdapterFactory(new ConstructorConstructor(ImmutableMap.<Type, InstanceCreator<?>>of()),
View Full Code Here

      assertEquals(extractor.extractName(SimpleTest.class.getDeclaredField("d").getAnnotation(Named.class)),
            "dog");
   }
  
   public void testAnnotationFieldNamingStrategy() throws Exception {
      FieldNamingStrategy strategy = new AnnotationFieldNamingStrategy(ImmutableSet.of(new ExtractNamed()));

      assertNull(strategy.translateName(SimpleTest.class.getDeclaredField("a")));
      assertNull(strategy.translateName(SimpleTest.class.getDeclaredField("b")));
      assertEquals(strategy.translateName(SimpleTest.class.getDeclaredField("c")), "cat");
      assertEquals(strategy.translateName(SimpleTest.class.getDeclaredField("d")), "dog");
   }
View Full Code Here

      assertEquals(strategy.translateName(SimpleTest.class.getDeclaredField("c")), "cat");
      assertEquals(strategy.translateName(SimpleTest.class.getDeclaredField("d")), "dog");
   }

   public void testAnnotationOrNameFieldNamingStrategy() throws Exception {
      FieldNamingStrategy strategy = new AnnotationOrNameFieldNamingStrategy(ImmutableSet.of(new ExtractNamed()));

      assertEquals(strategy.translateName(SimpleTest.class.getDeclaredField("a")), "a");
      assertEquals(strategy.translateName(SimpleTest.class.getDeclaredField("b")), "b");
      assertEquals(strategy.translateName(SimpleTest.class.getDeclaredField("c")), "cat");
      assertEquals(strategy.translateName(SimpleTest.class.getDeclaredField("d")), "dog");
   }
View Full Code Here

   Gson gson = new Gson();

   DeserializationConstructorAndReflectiveTypeAdapterFactory parameterizedCtorFactory = parameterizedCtorFactory();

   static DeserializationConstructorAndReflectiveTypeAdapterFactory parameterizedCtorFactory() {
      FieldNamingStrategy serializationPolicy = new AnnotationOrNameFieldNamingStrategy(ImmutableSet.of(
            new ExtractSerializedName(), new ExtractNamed()));
      NamingStrategies.AnnotationConstructorNamingStrategy deserializationPolicy = new NamingStrategies.AnnotationConstructorNamingStrategy(
            ImmutableSet.of(ConstructorProperties.class, Inject.class), ImmutableSet.of(new ExtractNamed()));

      return new DeserializationConstructorAndReflectiveTypeAdapterFactory(new ConstructorConstructor(ImmutableMap.<Type, InstanceCreator<?>>of()),
View Full Code Here

TOP

Related Classes of com.google.gson.FieldNamingStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.