本文整理汇总了Java中com.google.gson.annotations.Expose.serialize方法的典型用法代码示例。如果您正苦于以下问题:Java Expose.serialize方法的具体用法?Java Expose.serialize怎么用?Java Expose.serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gson.annotations.Expose
的用法示例。
在下文中一共展示了Expose.serialize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toMap
import com.google.gson.annotations.Expose; //导入方法依赖的package包/类
public Map<String, Object> toMap(Object requestObject) {
Map<String, Object> valuesToWrite = new HashMap<>();
for (Field field : requestObject.getClass().getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers())) {
continue;
}
if (Modifier.isPrivate(field.getModifiers())) {
continue;
}
Expose expose = field.getAnnotation(Expose.class);
if (expose != null && !expose.serialize()) {
continue;
}
Object value = ReflectionUtils.getValue(field, requestObject);
if (value == null) {
continue;
}
SerializedName serializedName = field.getAnnotation(SerializedName.class);
String nameToUse = serializedName != null ? serializedName.value() : field.getName();
Object valueToUse = determineCorrectValue(value);
if (valueToUse != null) {
valuesToWrite.put(nameToUse, valueToUse);
}
}
return valuesToWrite;
}
示例2: excludeField
import com.google.gson.annotations.Expose; //导入方法依赖的package包/类
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;
}
示例3: excludeField
import com.google.gson.annotations.Expose; //导入方法依赖的package包/类
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;
}
示例4: shouldSkipField
import com.google.gson.annotations.Expose; //导入方法依赖的package包/类
public boolean shouldSkipField(FieldAttributes f) {
Expose annotation = f.getAnnotation(Expose.class);
if (annotation == null) {
return true;
}
return !annotation.serialize();
}
开发者ID:IAmPhoenix,项目名称:Minecraft-API-Protocol,代码行数:8,代码来源:ExposeAnnotationSerializationExclusionStrategy.java
示例5: shouldSkipField
import com.google.gson.annotations.Expose; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(final FieldAttributes fieldAttributes) {
Expose exposeAnnotation = fieldAttributes.getAnnotation(Expose.class);
if (exposeAnnotation == null) {
return false;
}
if (useForSerialization) {
return !exposeAnnotation.serialize();
}
return !exposeAnnotation.deserialize();
}
示例6: isExcluded
import com.google.gson.annotations.Expose; //导入方法依赖的package包/类
private boolean isExcluded(Field f) {
int modifiers = f.getModifiers();
if (Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers)) {
return true;
}
Expose expose = f.getAnnotation(Expose.class);
if (expose != null && !expose.deserialize() && !expose.serialize()) {
return true;
}
return false;
}
示例7: excludeField
import com.google.gson.annotations.Expose; //导入方法依赖的package包/类
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;
}
示例8: shouldSkipField
import com.google.gson.annotations.Expose; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
final Expose expose = fieldAttributes.getAnnotation(Expose.class);
return expose != null && !expose.serialize();
}
示例9: excludeField
import com.google.gson.annotations.Expose; //导入方法依赖的package包/类
private boolean excludeField(Field paramField, boolean paramBoolean)
{
if (!this.excluder.excludeClass(paramField.getType(), paramBoolean))
{
Excluder localExcluder = this.excluder;
int i;
if ((localExcluder.modifiers & paramField.getModifiers()) != 0) {
i = 1;
}
while (i == 0)
{
return true;
if ((localExcluder.version != -1.0D) && (!localExcluder.isValidVersion((Since)paramField.getAnnotation(Since.class), (Until)paramField.getAnnotation(Until.class)))) {
i = 1;
} else {
label140:
label270:
if (paramField.isSynthetic())
{
i = 1;
}
else
{
if (localExcluder.requireExpose)
{
Expose localExpose = (Expose)paramField.getAnnotation(Expose.class);
if (localExpose != null)
{
if (!paramBoolean) {
break label140;
}
if (localExpose.serialize()) {
break label150;
}
}
while (!localExpose.deserialize())
{
i = 1;
break;
}
}
label150:
if ((!localExcluder.serializeInnerClasses) && (Excluder.isInnerClass(paramField.getType())))
{
i = 1;
}
else if (Excluder.isAnonymousOrLocal(paramField.getType()))
{
i = 1;
}
else
{
if (paramBoolean) {}
for (List localList = localExcluder.serializationStrategies;; localList = localExcluder.deserializationStrategies)
{
if (localList.isEmpty()) {
break label270;
}
new FieldAttributes(paramField);
Iterator localIterator = localList.iterator();
do
{
if (!localIterator.hasNext()) {
break;
}
} while (!((ExclusionStrategy)localIterator.next()).shouldSkipField$6e8224bb());
i = 1;
break;
}
i = 0;
}
}
}
}
}
return false;
}
示例10: shouldSkipField
import com.google.gson.annotations.Expose; //导入方法依赖的package包/类
@Override
public boolean shouldSkipField(FieldAttributes f) {
final Expose expose = f.getAnnotation(Expose.class);
return expose != null && !expose.serialize();
}