Top Description Fields Constructors Methods
com.google.gson.internal

public final Class Excluder

extends Object
implements TypeAdapterFactory, Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable, com.google.gson.TypeAdapterFactory
Imports
com.google.gson.ExclusionStrategy, .FieldAttributes, .Gson, .TypeAdapter, .TypeAdapterFactory, com.google.gson.annotations.Expose, .Since, .Until, com.google.gson.internal.reflect.ReflectionHelper, com.google.gson.reflect.TypeToken, com.google.gson.stream.JsonReader, .JsonWriter, java.io.IOException, java.lang.reflect.Field, .Modifier, java.util.ArrayList, .Collections, .List

This class selects which fields and types to omit. It is configurable, supporting version attributes Since and Until, modifiers, synthetic fields, anonymous and local classes, inner classes, and fields with the Expose annotation.

This class is a type adapter factory; types that are excluded will be adapted to null. It may delegate to another type adapter if only one direction is excluded.

Authors
Joel Leitch, Jesse Wilson

Field Summary

Modifier and TypeField and Description
public static final Excluder
private List<ExclusionStrategy>
private static final double
private int
private boolean
private List<ExclusionStrategy>
private boolean
private double

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Excluder
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

public <T> TypeAdapter<T>
create(Gson gson, TypeToken<T> type)

Implements com.google.gson.TypeAdapterFactory.create.

Returns a type adapter for type, or null if this factory doesn't support type.

public Excluder
public boolean
excludeClass(Class<?> clazz, boolean serialize)

public boolean
excludeField(Field field, boolean serialize)

public Excluder
private static boolean
isInnerClass(Class<?> clazz)

private boolean
isValidSince(Since annotation)

private boolean
isValidUntil(Until annotation)

private boolean
isValidVersion(Since since, Until until)

public Excluder
withExclusionStrategy(ExclusionStrategy exclusionStrategy, boolean serialization, boolean deserialization)

public Excluder
withModifiers(int... modifiers)

public Excluder
withVersion(double ignoreVersionsAfter)

Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULTback to summary
public static final Excluder DEFAULT
deserializationStrategiesback to summary
private List<ExclusionStrategy> deserializationStrategies
IGNORE_VERSIONSback to summary
private static final double IGNORE_VERSIONS
modifiersback to summary
private int modifiers
requireExposeback to summary
private boolean requireExpose
serializationStrategiesback to summary
private List<ExclusionStrategy> serializationStrategies
serializeInnerClassesback to summary
private boolean serializeInnerClasses
versionback to summary
private double version

Constructor Detail

Excluderback to summary
public Excluder()

Method Detail

cloneback to summary
protected Excluder clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Annotations
@Override
createback to summary
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type)

Implements com.google.gson.TypeAdapterFactory.create.

Doc from com.google.gson.TypeAdapterFactory.create.

Returns a type adapter for type, or null if this factory doesn't support type.

Annotations
@Override
disableInnerClassSerializationback to summary
public Excluder disableInnerClassSerialization()
excludeClassback to summary
public boolean excludeClass(Class<?> clazz, boolean serialize)
excludeFieldback to summary
public boolean excludeField(Field field, boolean serialize)
excludeFieldsWithoutExposeAnnotationback to summary
public Excluder excludeFieldsWithoutExposeAnnotation()
isInnerClassback to summary
private static boolean isInnerClass(Class<?> clazz)
isValidSinceback to summary
private boolean isValidSince(Since annotation)
isValidUntilback to summary
private boolean isValidUntil(Until annotation)
isValidVersionback to summary
private boolean isValidVersion(Since since, Until until)
withExclusionStrategyback to summary
public Excluder withExclusionStrategy(ExclusionStrategy exclusionStrategy, boolean serialization, boolean deserialization)
withModifiersback to summary
public Excluder withModifiers(int... modifiers)
withVersionback to summary
public Excluder withVersion(double ignoreVersionsAfter)