Package com.google.gson

Examples of com.google.gson.ExclusionStrategy


  /* (non-Javadoc)
   * @see org.mitre.openid.connect.view.AbstractClientEntityView#getExclusionStrategy()
   */
  @Override
  protected ExclusionStrategy getExclusionStrategy() {
    return new ExclusionStrategy() {

      @Override
      public boolean shouldSkipField(FieldAttributes f) {
        // whitelist the handful of fields that are good
        if (whitelistedFields.contains(f.getName())) {
View Full Code Here


  /**
   * @return
   */
  @Override
  protected ExclusionStrategy getExclusionStrategy() {
    return new ExclusionStrategy() {

      @Override
      public boolean shouldSkipField(FieldAttributes f) {
        if (blacklistedFields.contains(f.getName())) {
          return true;
View Full Code Here

 
  @Inject
  public GsonBuilderWrapper(@Any Instance<JsonSerializer<?>> jsonSerializers, @Any Instance<JsonDeserializer<?>> jsonDeserializers) {
    this.jsonSerializers = jsonSerializers;
    this.jsonDeserializers = jsonDeserializers;
    ExclusionStrategy exclusion = new Exclusions(serializee);
    exclusions = singletonList(exclusion);
  }
View Full Code Here

  private Collection<ExclusionStrategy> exclusions;

  public VRaptorGsonBuilder(JsonSerializers serializers, Serializee serializee) {
    this.serializers = serializers.getSerializers();
    ExclusionStrategy exclusion = new Exclusions(serializee);
    this.exclusions = Arrays.asList(exclusion);

  }
View Full Code Here

    this.response = response;
    this.extractor = extractor;
    this.initializer = initializer;

    this.serializee = new Serializee();
    ExclusionStrategy exclusion = new Exclusions(serializee);
    this.builder = new VraptorGsonBuilder(serializers.getSerializers(), Arrays.asList(exclusion));
  }
View Full Code Here

     * @param prettyPrint
     * @return
     */
    public String toJsonAndSkipCertainFields(Object obj, final List<String> excludedFields,
            boolean prettyPrint) {
        ExclusionStrategy strategy = new ExclusionStrategy() {
            public boolean shouldSkipField(FieldAttributes f) {
                if (excludedFields.contains(f.getName())) {
                    return true;
                }

View Full Code Here

     * @param filterAttrs
     *            The fieldnames to be filtered as string
     * @return the strategy applied by GSON
     */
    private ExclusionStrategy exclude(Class clazz, String... filterAttrs) {
        return new ExclusionStrategy() {

            public Class<?> excludedThisClass;
            public HashSet<String> excludedAttributes;

            private ExclusionStrategy init(Class<?> excludedThisClass,
View Full Code Here

            }
        }.init(clazz, filterAttrs);
    }
   
    private ExclusionStrategy include(Class clazz, String... filterAttrs) {
        return new ExclusionStrategy() {

            private Class<?> includeThisClass;
            private HashSet<String> includedAttributes;

            private ExclusionStrategy init(Class<?> includeThisClass,
View Full Code Here

     * @param prettyPrint
     * @return
     */
    public String toJsonAndSkipCertainFields(Object obj, final List<String> excludedFields,
            boolean prettyPrint) {
        ExclusionStrategy strategy = new ExclusionStrategy() {
            public boolean shouldSkipField(FieldAttributes f) {
                if (excludedFields.contains(f.getName())) {
                    return true;
                }

View Full Code Here

  /**
   *
   */
  private void initializeGson() {
    gson = new GsonBuilder().setExclusionStrategies(new ExclusionStrategy() {
      public boolean shouldSkipField(FieldAttributes fieldAttributes) {
        if (fieldAttributes.getName().equalsIgnoreCase("serialVersionUUID")) {
          return true;
        }
        return false;
View Full Code Here

TOP

Related Classes of com.google.gson.ExclusionStrategy

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.