com.google.gson.annotations.Expose Java Examples

The following examples show how to use com.google.gson.annotations.Expose. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Model.java    From tencentcloud-sdk-java with Apache License 2.0 6 votes vote down vote up
/**
 * Internal implementation, normal users should not use it.
 */
public void toMap(HashMap<String, String> map, String prefix) {
    this.setParamSimple(map, prefix + "Name", this.Name);
    this.setParamSimple(map, prefix + "Description", this.Description);
    this.setParamSimple(map, prefix + "Cluster", this.Cluster);
    this.setParamSimple(map, prefix + "Model", this.Model);
    this.setParamSimple(map, prefix + "RuntimeVersion", this.RuntimeVersion);
    this.setParamSimple(map, prefix + "CreateTime", this.CreateTime);
    this.setParamSimple(map, prefix + "State", this.State);
    this.setParamSimple(map, prefix + "ServingUrl", this.ServingUrl);
    this.setParamSimple(map, prefix + "Message", this.Message);
    this.setParamSimple(map, prefix + "AppId", this.AppId);
    this.setParamSimple(map, prefix + "ServType", this.ServType);
    this.setParamSimple(map, prefix + "Expose", this.Expose);
    this.setParamSimple(map, prefix + "Replicas", this.Replicas);
    this.setParamSimple(map, prefix + "Id", this.Id);
    this.setParamSimple(map, prefix + "Uin", this.Uin);
    this.setParamSimple(map, prefix + "DelTime", this.DelTime);

}
 
Example #2
Source File: CubaJavaScriptComponent.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected static GsonBuilder createSharedGsonBuilder() {
    GsonBuilder builder = new GsonBuilder();
    builder.setExclusionStrategies(new ExclusionStrategy() {
        @Override
        public boolean shouldSkipField(FieldAttributes f) {
            Expose expose = f.getAnnotation(Expose.class);
            return expose != null && !expose.serialize();
        }

        @Override
        public boolean shouldSkipClass(Class<?> clazz) {
            return false;
        }
    });

    setDefaultProperties(builder);
    return builder;
}
 
Example #3
Source File: CreateModelRequest.java    From tencentcloud-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 * Internal implementation, normal users should not use it.
 */
public void toMap(HashMap<String, String> map, String prefix) {
    this.setParamSimple(map, prefix + "Name", this.Name);
    this.setParamSimple(map, prefix + "Model", this.Model);
    this.setParamSimple(map, prefix + "Description", this.Description);
    this.setParamSimple(map, prefix + "Cluster", this.Cluster);
    this.setParamSimple(map, prefix + "RuntimeVersion", this.RuntimeVersion);
    this.setParamSimple(map, prefix + "Replicas", this.Replicas);
    this.setParamSimple(map, prefix + "Expose", this.Expose);
    this.setParamSimple(map, prefix + "ServType", this.ServType);
    this.setParamArraySimple(map, prefix + "RuntimeConf.", this.RuntimeConf);

}
 
Example #4
Source File: GsonObjectExtension.java    From raml-java-tools with Apache License 2.0 5 votes vote down vote up
@Override
public FieldSpec.Builder fieldBuilt(ObjectPluginContext objectPluginContext, TypeDeclaration declaration, FieldSpec.Builder incoming, EventType eventType) {
    return incoming
            .addAnnotation(
                    AnnotationSpec.builder(SerializedName.class)
                            .addMember("value", "$S", objectPluginContext.creationResult().getJavaName(EventType.IMPLEMENTATION)).build())
            .addAnnotation(AnnotationSpec.builder(Expose.class).build());
}
 
Example #5
Source File: Excluder.java    From letv with Apache License 2.0 5 votes vote down vote up
public boolean excludeField(Field field, boolean serialize) {
    if ((this.modifiers & field.getModifiers()) != 0) {
        return true;
    }
    if (this.version != IGNORE_VERSIONS && !isValidVersion((Since) field.getAnnotation(Since.class), (Until) field.getAnnotation(Until.class))) {
        return true;
    }
    if (field.isSynthetic()) {
        return true;
    }
    if (this.requireExpose) {
        Expose annotation = (Expose) field.getAnnotation(Expose.class);
        if (annotation == null || (serialize ? !annotation.serialize() : !annotation.deserialize())) {
            return true;
        }
    }
    if (!this.serializeInnerClasses && isInnerClass(field.getType())) {
        return true;
    }
    if (isAnonymousOrLocal(field.getType())) {
        return true;
    }
    List<ExclusionStrategy> list = serialize ? this.serializationStrategies : this.deserializationStrategies;
    if (!list.isEmpty()) {
        FieldAttributes fieldAttributes = new FieldAttributes(field);
        for (ExclusionStrategy exclusionStrategy : list) {
            if (exclusionStrategy.shouldSkipField(fieldAttributes)) {
                return true;
            }
        }
    }
    return false;
}
 
Example #6
Source File: ExposeServiceResponse.java    From tencentcloud-sdk-java with Apache License 2.0 4 votes vote down vote up
/**
 * Internal implementation, normal users should not use it.
 */
public void toMap(HashMap<String, String> map, String prefix) {
    this.setParamObj(map, prefix + "Expose.", this.Expose);
    this.setParamSimple(map, prefix + "RequestId", this.RequestId);

}
 
Example #7
Source File: GsonCompatibilityMode.java    From java with MIT License 4 votes vote down vote up
@Override
protected JsonIgnore getJsonIgnore(Annotation[] annotations) {

    JsonIgnore jsoniterObj = super.getJsonIgnore(annotations);
    if (jsoniterObj != null) {
        return jsoniterObj;
    }
    if (builder().excludeFieldsWithoutExposeAnnotation) {
        final Expose gsonObj = getAnnotation(
                annotations, Expose.class);
        if (gsonObj != null) {
            return new JsonIgnore() {
                @Override
                public boolean ignoreDecoding() {
                    return !gsonObj.deserialize();
                }

                @Override
                public boolean ignoreEncoding() {
                    return !gsonObj.serialize();
                }

                @Override
                public Class<? extends Annotation> annotationType() {
                    return JsonIgnore.class;
                }
            };
        }
        return new JsonIgnore() {
            @Override
            public boolean ignoreDecoding() {
                return true;
            }

            @Override
            public boolean ignoreEncoding() {
                return true;
            }

            @Override
            public Class<? extends Annotation> annotationType() {
                return JsonIgnore.class;
            }
        };
    }
    return null;
}
 
Example #8
Source File: JsonExclusionStrategy.java    From RoomBookerMVP with MIT License 4 votes vote down vote up
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
    final Expose expose = fieldAttributes.getAnnotation(Expose.class);
    return expose != null && !expose.serialize();
}
 
Example #9
Source File: Excluder.java    From gson with Apache License 2.0 4 votes vote down vote up
public boolean excludeField(Field field, boolean serialize) {
  if ((modifiers & field.getModifiers()) != 0) {
    return true;
  }

  if (version != Excluder.IGNORE_VERSIONS
      && !isValidVersion(field.getAnnotation(Since.class), field.getAnnotation(Until.class))) {
    return true;
  }

  if (field.isSynthetic()) {
    return true;
  }

  if (requireExpose) {
    Expose annotation = field.getAnnotation(Expose.class);
    if (annotation == null || (serialize ? !annotation.serialize() : !annotation.deserialize())) {
      return true;
    }
  }

  if (!serializeInnerClasses && isInnerClass(field.getType())) {
    return true;
  }

  if (isAnonymousOrLocal(field.getType())) {
    return true;
  }

  List<ExclusionStrategy> list = serialize ? serializationStrategies : deserializationStrategies;
  if (!list.isEmpty()) {
    FieldAttributes fieldAttributes = new FieldAttributes(field);
    for (ExclusionStrategy exclusionStrategy : list) {
      if (exclusionStrategy.shouldSkipField(fieldAttributes)) {
        return true;
      }
    }
  }

  return false;
}
 
Example #10
Source File: Excluder.java    From framework with GNU Affero General Public License v3.0 4 votes vote down vote up
public boolean excludeField(Field field, boolean serialize) {
  if ((modifiers & field.getModifiers()) != 0) {
    return true;
  }

  if (version != Excluder.IGNORE_VERSIONS
      && !isValidVersion(field.getAnnotation(Since.class), field.getAnnotation(Until.class))) {
    return true;
  }

  if (field.isSynthetic()) {
    return true;
  }

  if (requireExpose) {
    Expose annotation = field.getAnnotation(Expose.class);
    if (annotation == null || (serialize ? !annotation.serialize() : !annotation.deserialize())) {
      return true;
    }
  }

  if (!serializeInnerClasses && isInnerClass(field.getType())) {
    return true;
  }

  if (isAnonymousOrLocal(field.getType())) {
    return true;
  }

  List<ExclusionStrategy> list = serialize ? serializationStrategies : deserializationStrategies;
  if (!list.isEmpty()) {
    FieldAttributes fieldAttributes = new FieldAttributes(field);
    for (ExclusionStrategy exclusionStrategy : list) {
      if (exclusionStrategy.shouldSkipField(fieldAttributes)) {
        return true;
      }
    }
  }

  return false;
}
 
Example #11
Source File: ExposeServiceResponse.java    From tencentcloud-sdk-java with Apache License 2.0 2 votes vote down vote up
/**
 * Get 暴露方式 
 * @return Expose 暴露方式
 */
public ExposeInfo getExpose() {
    return this.Expose;
}
 
Example #12
Source File: ExposeServiceResponse.java    From tencentcloud-sdk-java with Apache License 2.0 2 votes vote down vote up
/**
 * Set 暴露方式
 * @param Expose 暴露方式
 */
public void setExpose(ExposeInfo Expose) {
    this.Expose = Expose;
}
 
Example #13
Source File: Model.java    From tencentcloud-sdk-java with Apache License 2.0 2 votes vote down vote up
/**
 * Get 模型暴露方式 
 * @return Expose 模型暴露方式
 */
public String getExpose() {
    return this.Expose;
}
 
Example #14
Source File: Model.java    From tencentcloud-sdk-java with Apache License 2.0 2 votes vote down vote up
/**
 * Set 模型暴露方式
 * @param Expose 模型暴露方式
 */
public void setExpose(String Expose) {
    this.Expose = Expose;
}
 
Example #15
Source File: CreateModelRequest.java    From tencentcloud-sdk-java with Apache License 2.0 2 votes vote down vote up
/**
 * Get 暴露外网或内网,默认暴露外网,`集群模式` 选填 
 * @return Expose 暴露外网或内网,默认暴露外网,`集群模式` 选填
 */
public String getExpose() {
    return this.Expose;
}
 
Example #16
Source File: CreateModelRequest.java    From tencentcloud-sdk-java with Apache License 2.0 2 votes vote down vote up
/**
 * Set 暴露外网或内网,默认暴露外网,`集群模式` 选填
 * @param Expose 暴露外网或内网,默认暴露外网,`集群模式` 选填
 */
public void setExpose(String Expose) {
    this.Expose = Expose;
}