congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
GsonBuilder.addSerializationExclusionStrategy
Code IndexAdd Tabnine to your IDE (free)

How to use
addSerializationExclusionStrategy
method
in
com.google.gson.GsonBuilder

Best Java code snippets using com.google.gson.GsonBuilder.addSerializationExclusionStrategy (Showing top 20 results out of 315)

origin: zstackio/zstack

public GsonUtil setSerializationExclusionStrategy(ExclusionStrategy excludeStratege) {
  _gsonBuilder.addSerializationExclusionStrategy(excludeStratege);
  return this;
}

origin: tabulapdf/tabula-java

private static Gson gson() {
  return new GsonBuilder()
      .addSerializationExclusionStrategy(ALLCLASSES_SKIPNONPUBLIC)
      .registerTypeAdapter(Table.class, TableSerializer.INSTANCE)
      .registerTypeAdapter(RectangularTextContainer.class, RectangularTextContainerSerializer.INSTANCE)
      .registerTypeAdapter(Cell.class, RectangularTextContainerSerializer.INSTANCE)
      .registerTypeAdapter(TextChunk.class, RectangularTextContainerSerializer.INSTANCE)
      .create();
}
origin: stackoverflow.com

 public class GsonFactory {

  public static Gson build(final List<String> fieldExclusions, final List<Class<?>> classExclusions) {
    GsonBuilder b = new GsonBuilder();
    b.addSerializationExclusionStrategy(new ExclusionStrategy() {
      @Override
      public boolean shouldSkipField(FieldAttributes f) {
        return fieldExclusions == null ? false : fieldExclusions.contains(f.getName());
      }

      @Override
      public boolean shouldSkipClass(Class<?> clazz) {
        return classExclusions == null ? false : classExclusions.contains(clazz);
      }
    });
    return b.create();

  }
}
origin: org.apache.fulcrum/fulcrum-json-gson

@Override
public <T> String serializeAllExceptFilter(Object src,
    Class<T> filterClass, String... filterAttr) throws Exception {
  return gson
      .addSerializationExclusionStrategy(
          exclude(filterClass, filterAttr)).create().toJson(src);
}
 
origin: org.apache.fulcrum/fulcrum-json-gson

@Override
public <T> String serializeAllExceptFilter(Object src, Boolean notused,
    String... filterAttr) throws Exception {
  return gson
      .addSerializationExclusionStrategy(
          exclude(null, filterAttr)).create().toJson(src);
}
 
origin: dayatang/dddlib

public GsonSerializerBuilder addSerializationExclusionStrategy(ExclusionStrategy strategy) {
  return new GsonSerializerBuilder(builder
      .addSerializationExclusionStrategy(strategy));
}
origin: org.apache.fulcrum/fulcrum-json-gson

@Override
public <T> String serializeOnlyFilter(Object src, Boolean notused,
    String... filterAttr) throws Exception {
  return  gson
      .addSerializationExclusionStrategy(
          include(null,filterAttr)).create().toJson(src);
}
origin: org.apache.fulcrum/fulcrum-json-gson

@Override
public <T> String serializeOnlyFilter(Object src, String... filterAttr)
    throws Exception {
  return  gson
      .addSerializationExclusionStrategy(
          include(null,filterAttr)).create().toJson(src);
}
origin: org.apache.fulcrum/fulcrum-json-gson

@Override
public <T> String serializeOnlyFilter(Object src, Class<T> filterClass,
    String... filterAttr) throws Exception {
  return  gson
  .addSerializationExclusionStrategy(
      include(filterClass, filterAttr)).create().toJson(src);
}
 
origin: org.apache.fulcrum/fulcrum-json-gson

@Override
public <T> String serializeAllExceptFilter(Object src, String... filterAttr)
    throws Exception {
  return gson
      .addSerializationExclusionStrategy(
          exclude(null, filterAttr)).create().toJson(src);
}
origin: Adobe-Consulting-Services/acs-aem-commons

Gson getGson() {
  GsonBuilder gsonBuilder = new GsonBuilder();
  gsonBuilder.addSerializationExclusionStrategy(new ExclusionStrategy() {
    @Override
    public boolean shouldSkipField(FieldAttributes fa) {
      return (fa.hasModifier(Modifier.TRANSIENT) || fa.hasModifier(Modifier.VOLATILE));
    }
    @Override
    public boolean shouldSkipClass(Class<?> type) {
      return IGNORED_CLASSES.contains(type)
          || (type.getPackage() != null
          && IGNORED_PACKAGES.contains(type.getPackage().getName()));
    }
  });
  gsonBuilder.disableInnerClassSerialization();
  Gson gson = gsonBuilder.create();
  return gson;
}
origin: caelum/vraptor

public Gson create() {
  for (JsonSerializer<?> adapter : serializers) {
    builder.registerTypeHierarchyAdapter(getAdapterType(adapter), adapter);
  }
  for (ExclusionStrategy exclusion : exclusions) {
    builder.addSerializationExclusionStrategy(exclusion);
  }
  return builder.create();
}
origin: KleeGroup/vertigo

private static Gson createGson() {
  return new GsonBuilder()
      .setPrettyPrinting()
      .registerTypeAdapter(DefinitionReference.class, new DefinitionReferenceJsonSerializer())
      .registerTypeAdapter(Optional.class, new OptionJsonSerializer())
      .addSerializationExclusionStrategy(new JsonExclusionStrategy())
      .create();
}
origin: KleeGroup/vertigo

private static Gson createGson() {
  return new GsonBuilder()
      .setPrettyPrinting()
      .registerTypeAdapter(DefinitionReference.class, new DefinitionReferenceJsonSerializer())
      .registerTypeAdapter(Optional.class, new OptionJsonSerializer())
      .addSerializationExclusionStrategy(new JsonExclusionStrategy())
      .create();
}
origin: vmware/xenon

public static GsonBuilder createDefaultGsonBuilder(EnumSet<JsonOptions> options) {
  GsonBuilder bldr = new GsonBuilder();
  registerCommonGsonTypeAdapters(bldr);
  if (!options.contains(JsonOptions.COMPACT)) {
    bldr.setPrettyPrinting();
  }
  bldr.disableHtmlEscaping();
  if (options.contains(JsonOptions.EXCLUDE_SENSITIVE)) {
    bldr.addSerializationExclusionStrategy(new SensitiveAnnotationExclusionStrategy());
  }
  if (options.contains(JsonOptions.EXCLUDE_BUILTIN)) {
    bldr.addSerializationExclusionStrategy(new BuiltInServiceDocumentFieldsExclusionStrategy());
  }
  return bldr;
}
origin: com.haulmont.addon.dashboard/dashboard-web

public JsonConverter() {
  GsonBuilder builder = new GsonBuilder();
  builder.addSerializationExclusionStrategy(new ExclusionStrategy() {
    @Override
    public boolean shouldSkipField(FieldAttributes f) {
      return f.getAnnotations().contains(Transient.class) || f.hasModifier(Modifier.TRANSIENT);
    }
    @Override
    public boolean shouldSkipClass(Class<?> clazz) {
      return false;
    }
  });
  builder.addSerializationExclusionStrategy(new AnnotationExclusionStrategy());
  builder.serializeNulls();
  builder.setPrettyPrinting();
  builder.registerTypeAdapter(ParameterValue.class, new InheritanceAdapter());
  builder.registerTypeAdapter(DashboardLayout.class, new InheritanceAdapter());
  gson = builder.create();
}
origin: devicehive/devicehive-java-server

public static Gson createGson(Policy policy) {
  Gson gson = cache.get(policy);
  if (gson != null) {
    return gson;
  }
  gson = createGsonBuilder()
      .addDeserializationExclusionStrategy(new AnnotatedStrategy(policy))
      .addSerializationExclusionStrategy(new AnnotatedStrategy(policy))
      .create();
  cache.put(policy, gson);
  return gson;
}
origin: dayatang/dddlib

public GsonSerializerBuilder excludeFieldsNamed(String... fieldNames) {
  return new GsonSerializerBuilder(builder
      .addSerializationExclusionStrategy(new FieldNameExclusionStrategy(fieldNames)));
}
origin: caelum/vraptor4

@Override
public Gson create() {
  for (JsonSerializer<?> adapter : jsonSerializers) {
    registerAdapter(getAdapterType(adapter), adapter);
  }
  for (JsonDeserializer<?> adapter : jsonDeserializers) {
    registerAdapter(getAdapterType(adapter), adapter);
  }
  
  for (ExclusionStrategy exclusion : exclusions) {
    getGsonBuilder().addSerializationExclusionStrategy(exclusion);
  }
  
  return getGsonBuilder().create();
}

origin: cbilgili/zemberek-nlp-server

  public static void main(String[] args) throws IOException {
    // JSON converter
    Gson jsonConverter = new GsonBuilder()
        .addSerializationExclusionStrategy(new ZemberekExclusionStrategy())
        .disableInnerClassSerialization()
        .create();
    // Turkish default morphology
    TurkishMorphology morphology = TurkishMorphology.createWithDefaults();

    new FindPOSController(jsonConverter, morphology);
    new SentenceBoundaryDetectionController(jsonConverter);
    new TurkishTokenizationController(jsonConverter);
    new SpellingController(jsonConverter, morphology);
    new StemmingAndLemmatizationController(jsonConverter, morphology);
    new AnalyzeWordController(jsonConverter, morphology);
    new AnalyzeSentenceController(jsonConverter, morphology);
    new GenerateWordsController(jsonConverter);
  }
}
com.google.gsonGsonBuilderaddSerializationExclusionStrategy

Javadoc

Configures Gson to apply the passed in exclusion strategy during serialization. If this method is invoked numerous times with different exclusion strategy objects then the exclusion strategies that were added will be applied as a disjunction rule. This means that if one of the added exclusion strategies suggests that a field (or class) should be skipped then that field (or object) is skipped during its serialization.

Popular methods of GsonBuilder

  • create
    Creates a Gson instance based on the current configuration. This method is free of side-effects to t
  • <init>
    Constructs a GsonBuilder instance from a Gson instance. The newly constructed GsonBuilder has the sa
  • registerTypeAdapter
  • setPrettyPrinting
    Configures Gson to output Json that fits in a page for pretty printing. This option only affects Jso
  • serializeNulls
    Configure Gson to serialize null fields. By default, Gson omits all fields that are null during seri
  • disableHtmlEscaping
    By default, Gson escapes HTML characters such as < > etc. Use this option to configure Gson to pass-
  • setDateFormat
    Configures Gson to serialize Date objects according to the pattern provided. You can call this metho
  • registerTypeAdapterFactory
    Register a factory for type adapters. Registering a factory is useful when the type adapter needs to
  • setFieldNamingPolicy
    Configures Gson to apply a specific naming policy to an object's field during serialization and dese
  • registerTypeHierarchyAdapter
  • excludeFieldsWithoutExposeAnnotation
    Configures Gson to exclude all fields from consideration for serialization or deserialization that d
  • setExclusionStrategies
    Configures Gson to apply a set of exclusion strategies during both serialization and deserialization
  • excludeFieldsWithoutExposeAnnotation,
  • setExclusionStrategies,
  • enableComplexMapKeySerialization,
  • setLenient,
  • excludeFieldsWithModifiers,
  • serializeSpecialFloatingPointValues,
  • setVersion,
  • setFieldNamingStrategy,
  • addTypeAdaptersForDate

Popular in Java

  • Making http requests using okhttp
  • onCreateOptionsMenu (Activity)
  • getSystemService (Context)
  • getContentResolver (Context)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • AtomicInteger (java.util.concurrent.atomic)
    An int value that may be updated atomically. See the java.util.concurrent.atomic package specificati
  • JFrame (javax.swing)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now