本文整理匯總了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();
}