com.github.nmorel.gwtjackson.client.JsonDeserializerParameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gwt-jackson Show documentation
Show all versions of gwt-jackson Show documentation
gwt-jackson is a GWT JSON serializer/deserializer mechanism based on Jackson annotations
/*
* Copyright 2013 Nicolas Morel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.nmorel.gwtjackson.client;
import java.util.HashSet;
import java.util.Set;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.github.nmorel.gwtjackson.client.deser.bean.IdentityDeserializationInfo;
import com.github.nmorel.gwtjackson.client.deser.bean.TypeDeserializationInfo;
import com.github.nmorel.gwtjackson.client.deser.collection.ListJsonDeserializer;
/**
* This class includes parameters defined through properties annotations like {@link JsonIgnoreProperties}. They are specific to one
* {@link JsonDeserializer} and that's why they are not contained inside {@link JsonDeserializationContext}.
*
* For container deserializers like {@link ListJsonDeserializer}, these parameters are passed to the value deserializer.
*
*
* @author Nicolas Morel
* @version $Id: $
*/
public final class JsonDeserializerParameters {
/** Constant DEFAULT
*/
public static final JsonDeserializerParameters DEFAULT = new JsonDeserializerParameters();
/**
* Datatype-specific additional piece of configuration that may be used
* to further refine formatting aspects. This may, for example, determine
* low-level format String used for {@link java.util.Date} serialization;
* however, exact use is determined by specific {@link JsonDeserializer}
*/
private String pattern;
/**
* Structure to use for serialization: definition of mapping depends on datatype,
* but usually has straight-forward counterpart in data format (JSON).
* Note that commonly only a subset of shapes is available; and if 'invalid' value
* is chosen, defaults are usually used.
*/
private Shape shape = Shape.ANY;
/**
* Locale to use for deserialization (if needed).
*/
private String locale;
/**
* Names of properties to ignore.
*/
private Set ignoredProperties;
/**
* Property that defines whether it is ok to just ignore any
* unrecognized properties during deserialization.
* If true, all properties that are unrecognized -- that is,
* there are no setters or creators that accept them -- are
* ignored without warnings (although handlers for unknown
* properties, if any, will still be called) without
* exception.
*/
private boolean ignoreUnknown = false;
/**
* Bean identity informations
*/
private IdentityDeserializationInfo identityInfo;
/**
* Bean type informations
*/
private TypeDeserializationInfo typeInfo;
/**
* Getter for the field pattern
.
*
* @return a {@link java.lang.String} object.
*/
public String getPattern() {
return pattern;
}
/**
* Setter for the field pattern
.
*
* @param pattern a {@link java.lang.String} object.
* @return a {@link com.github.nmorel.gwtjackson.client.JsonDeserializerParameters} object.
*/
public JsonDeserializerParameters setPattern( String pattern ) {
this.pattern = pattern;
return this;
}
/**
* Getter for the field shape
.
*
* @return a {@link com.fasterxml.jackson.annotation.JsonFormat.Shape} object.
*/
public Shape getShape() {
return shape;
}
/**
* Setter for the field shape
.
*
* @param shape a {@link com.fasterxml.jackson.annotation.JsonFormat.Shape} object.
* @return a {@link com.github.nmorel.gwtjackson.client.JsonDeserializerParameters} object.
*/
public JsonDeserializerParameters setShape( Shape shape ) {
this.shape = shape;
return this;
}
/**
* Getter for the field locale
.
*
* @return a {@link java.lang.String} object.
*/
public String getLocale() {
return locale;
}
/**
* Setter for the field locale
.
*
* @param locale a {@link java.lang.String} object.
* @return a {@link com.github.nmorel.gwtjackson.client.JsonDeserializerParameters} object.
*/
public JsonDeserializerParameters setLocale( String locale ) {
this.locale = locale;
return this;
}
/**
* Getter for the field ignoredProperties
.
*
* @return a {@link java.util.Set} object.
*/
public Set getIgnoredProperties() {
return ignoredProperties;
}
/**
* addIgnoredProperty
*
* @param ignoredProperty a {@link java.lang.String} object.
* @return a {@link com.github.nmorel.gwtjackson.client.JsonDeserializerParameters} object.
*/
public JsonDeserializerParameters addIgnoredProperty( String ignoredProperty ) {
if ( null == ignoredProperties ) {
ignoredProperties = new HashSet();
}
ignoredProperties.add( ignoredProperty );
return this;
}
/**
* isIgnoreUnknown
*
* @return a boolean.
*/
public boolean isIgnoreUnknown() {
return ignoreUnknown;
}
/**
* Setter for the field ignoreUnknown
.
*
* @param ignoreUnknown a boolean.
* @return a {@link com.github.nmorel.gwtjackson.client.JsonDeserializerParameters} object.
*/
public JsonDeserializerParameters setIgnoreUnknown( boolean ignoreUnknown ) {
this.ignoreUnknown = ignoreUnknown;
return this;
}
/**
* Getter for the field identityInfo
.
*
* @return a {@link com.github.nmorel.gwtjackson.client.deser.bean.IdentityDeserializationInfo} object.
*/
public IdentityDeserializationInfo getIdentityInfo() {
return identityInfo;
}
/**
* Setter for the field identityInfo
.
*
* @param identityInfo a {@link com.github.nmorel.gwtjackson.client.deser.bean.IdentityDeserializationInfo} object.
* @return a {@link com.github.nmorel.gwtjackson.client.JsonDeserializerParameters} object.
*/
public JsonDeserializerParameters setIdentityInfo( IdentityDeserializationInfo identityInfo ) {
this.identityInfo = identityInfo;
return this;
}
/**
* Getter for the field typeInfo
.
*
* @return a {@link com.github.nmorel.gwtjackson.client.deser.bean.TypeDeserializationInfo} object.
*/
public TypeDeserializationInfo getTypeInfo() {
return typeInfo;
}
/**
* Setter for the field typeInfo
.
*
* @param typeInfo a {@link com.github.nmorel.gwtjackson.client.deser.bean.TypeDeserializationInfo} object.
* @return a {@link com.github.nmorel.gwtjackson.client.JsonDeserializerParameters} object.
*/
public JsonDeserializerParameters setTypeInfo( TypeDeserializationInfo typeInfo ) {
this.typeInfo = typeInfo;
return this;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy