本文整理汇总了Java中com.fasterxml.jackson.annotation.JsonFormat.Shape类的典型用法代码示例。如果您正苦于以下问题:Java Shape类的具体用法?Java Shape怎么用?Java Shape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Shape类属于com.fasterxml.jackson.annotation.JsonFormat包,在下文中一共展示了Shape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEquality
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
public void testEquality() {
assertTrue(EMPTY.equals(EMPTY));
assertTrue(new JsonFormat.Value().equals(new JsonFormat.Value()));
JsonFormat.Value v1 = JsonFormat.Value.forShape(Shape.BOOLEAN);
JsonFormat.Value v2 = JsonFormat.Value.forShape(Shape.BOOLEAN);
JsonFormat.Value v3 = JsonFormat.Value.forShape(Shape.SCALAR);
assertTrue(v1.equals(v2));
assertTrue(v2.equals(v1));
assertFalse(v1.equals(v3));
assertFalse(v3.equals(v1));
assertFalse(v2.equals(v3));
assertFalse(v3.equals(v2));
// not strictly guaranteed but...
assertFalse(v1.hashCode() == v3.hashCode());
// then let's converge
assertEquals(v1, v3.withShape(Shape.BOOLEAN));
assertFalse(v1.equals(v1.withPattern("ZBC")));
assertFalse(v1.equals(v1.withFeature(Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)));
assertFalse(v1.equals(v1.withoutFeature(Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)));
}
示例2: useTimestamp
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
protected boolean useTimestamp(SerializerProvider provider) {
if (_useTimestamp != null) {
return _useTimestamp.booleanValue();
}
if (_shape != null) {
if (_shape == Shape.STRING) {
return false;
}
if (_shape == Shape.NUMBER_INT) {
return true;
}
}
// assume that explicit formatter definition implies use of textual format
if (_formatter != null) {
return false;
}
return provider.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
}
示例3: _isShapeWrittenUsingIndex
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
protected static Boolean _isShapeWrittenUsingIndex(Class<?> paramClass, JsonFormat.Value paramValue, boolean paramBoolean)
{
JsonFormat.Shape localShape1;
if (paramValue == null)
localShape1 = null;
else
localShape1 = paramValue.getShape();
JsonFormat.Shape localShape2 = localShape1;
if (localShape1 == null)
return null;
if ((localShape2 == JsonFormat.Shape.ANY) || (localShape2 == JsonFormat.Shape.SCALAR))
return null;
if (localShape2 == JsonFormat.Shape.STRING)
return Boolean.FALSE;
if (localShape2.isNumeric())
return Boolean.TRUE;
StringBuilder localStringBuilder = new StringBuilder("Unsupported serialization shape (").append(localShape2).append(") for Enum ").append(paramClass.getName()).append(", not supported as ");
String str;
if (paramBoolean)
str = "class";
else
str = "property";
throw new IllegalArgumentException(str + " annotation");
}
示例4: buildEnumSerializer
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
protected JsonSerializer<?> buildEnumSerializer(SerializationConfig paramSerializationConfig, JavaType paramJavaType, BeanDescription paramBeanDescription)
{
JsonFormat.Value localValue = paramBeanDescription.findExpectedFormat(null);
if ((localValue != null) && (localValue.getShape() == JsonFormat.Shape.OBJECT))
{
((BasicBeanDescription)paramBeanDescription).removeProperty("declaringClass");
return null;
}
Object localObject = EnumSerializer.construct(paramJavaType.getRawClass(), paramSerializationConfig, paramBeanDescription, localValue);
if (this._factoryConfig.hasSerializerModifiers())
{
Iterator localIterator = this._factoryConfig.serializerModifiers().iterator();
while (localIterator.hasNext())
localObject = ((BeanSerializerModifier)localIterator.next()).modifyEnumSerializer(paramSerializationConfig, paramJavaType, paramBeanDescription, (JsonSerializer)localObject);
}
return localObject;
}
示例5: buildCommonPropertyParameters
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
/**
* Add the common property parameters to the code builder.
*
* @param paramBuilder the code builder
* @param property the information about the property
*/
protected final void buildCommonPropertyParameters( CodeBlock.Builder paramBuilder, PropertyInfo property ) {
if ( property.getFormat().isPresent() ) {
JsonFormat format = property.getFormat().get();
if ( !Strings.isNullOrEmpty( format.pattern() ) ) {
paramBuilder.add( "\n.setPattern($S)", format.pattern() );
}
paramBuilder.add( "\n.setShape($T.$L)", Shape.class, format.shape().name() );
if ( !Strings.isNullOrEmpty( format.locale() ) && !JsonFormat.DEFAULT_LOCALE.equals( format.locale() ) ) {
logger.log( Type.WARN, "JsonFormat.locale is not supported by default" );
paramBuilder.add( "\n.setLocale($S)", format.locale() );
}
}
if ( property.getIgnoredProperties().isPresent() ) {
for ( String ignoredProperty : property.getIgnoredProperties().get() ) {
paramBuilder.add( "\n.addIgnoredProperty($S)", ignoredProperty );
}
}
}
示例6: _isShapeWrittenUsingIndex
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
/**
* Helper method called to check whether
*/
protected static Boolean _isShapeWrittenUsingIndex(Class<?> enumClass,
JsonFormat.Value format, boolean fromClass)
{
JsonFormat.Shape shape = (format == null) ? null : format.getShape();
if (shape == null) {
return null;
}
if (shape == Shape.ANY || shape == Shape.SCALAR) { // i.e. "default", check dynamically
return null;
}
if (shape == Shape.STRING) {
return Boolean.FALSE;
}
if (shape.isNumeric()) {
return Boolean.TRUE;
}
throw new IllegalArgumentException("Unsupported serialization shape ("+shape+") for Enum "+enumClass.getName()
+", not supported as "
+ (fromClass? "class" : "property")
+" annotation");
}
示例7: testFromAnnotation
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
public void testFromAnnotation()
{
JsonFormat ann = Bogus.class.getAnnotation(JsonFormat.class);
JsonFormat.Value v = JsonFormat.Value.from(ann);
assertEquals("xyz", v.getPattern());
assertEquals(JsonFormat.Shape.BOOLEAN, v.getShape());
// note: since it's not valid, should not try access as real thing
assertEquals("bogus", v.timeZoneAsString());
// also:
assertSame(EMPTY, JsonFormat.Value.from(null));
}
示例8: testShape
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
public void testShape() {
assertFalse(JsonFormat.Shape.STRING.isNumeric());
assertFalse(JsonFormat.Shape.STRING.isStructured());
assertTrue(JsonFormat.Shape.NUMBER_INT.isNumeric());
assertTrue(JsonFormat.Shape.NUMBER_FLOAT.isNumeric());
assertTrue(JsonFormat.Shape.NUMBER.isNumeric());
assertTrue(JsonFormat.Shape.ARRAY.isStructured());
assertTrue(JsonFormat.Shape.OBJECT.isStructured());
}
示例9: doSerialize
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
@Override
protected void doSerialize(JsonWriter writer, Date value, JsonSerializationContext ctx, JsonSerializerParameters params) {
if ((ctx.isWriteDatesAsTimestamps() || params.getShape().isNumeric()) && params.getShape() != Shape.STRING) {
writer.value(value.getTime());
} else {
String date = JacksonContextProvider.get().dateFormat().format(params, value);
if (null == params.getPattern()) {
writer.unescapeValue(date);
} else {
writer.value(date);
}
}
}
示例10: JSR310FormattedSerializerBase
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
protected JSR310FormattedSerializerBase(JSR310FormattedSerializerBase<?> base,
Boolean useTimestamp, DateTimeFormatter dtf, JsonFormat.Shape shape)
{
super(base.handledType());
_useTimestamp = useTimestamp;
_formatter = dtf;
_shape = shape;
}
示例11: BeanSerializerBase
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
public BeanSerializerBase(JavaType paramJavaType, BeanSerializerBuilder paramBeanSerializerBuilder, BeanPropertyWriter[] paramArrayOfBeanPropertyWriter1, BeanPropertyWriter[] paramArrayOfBeanPropertyWriter2)
{
super(paramJavaType);
this._props = paramArrayOfBeanPropertyWriter1;
this._filteredProps = paramArrayOfBeanPropertyWriter2;
BeanSerializerBase localBeanSerializerBase;
JsonFormat.Shape localShape;
if (paramBeanSerializerBuilder == null)
{
this._typeId = null;
this._anyGetterWriter = null;
this._propertyFilterId = null;
this._objectIdWriter = null;
localBeanSerializerBase = this;
localShape = null;
}
else
{
this._typeId = paramBeanSerializerBuilder.getTypeId();
this._anyGetterWriter = paramBeanSerializerBuilder.getAnyGetter();
this._propertyFilterId = paramBeanSerializerBuilder.getFilterId();
this._objectIdWriter = paramBeanSerializerBuilder.getObjectIdWriter();
JsonFormat.Value localValue = paramBeanSerializerBuilder.getBeanDescription().findExpectedFormat(null);
localBeanSerializerBase = this;
if (localValue == null)
localShape = null;
else
localShape = localValue.getShape();
}
localBeanSerializerBase._serializationShape = localShape;
}
示例12: _createDeserializer2
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
protected final JsonDeserializer<?> _createDeserializer2(DeserializationContext paramDeserializationContext, DeserializerFactory paramDeserializerFactory, JavaType paramJavaType, BeanDescription paramBeanDescription)
{
DeserializationConfig localDeserializationConfig = paramDeserializationContext.getConfig();
if (paramJavaType.isEnumType())
return paramDeserializerFactory.createEnumDeserializer(paramDeserializationContext, paramJavaType, paramBeanDescription);
if (paramJavaType.isContainerType())
{
if (paramJavaType.isArrayType())
return paramDeserializerFactory.createArrayDeserializer(paramDeserializationContext, (ArrayType)paramJavaType, paramBeanDescription);
if (paramJavaType.isMapLikeType())
{
MapLikeType localMapLikeType = (MapLikeType)paramJavaType;
if (localMapLikeType.isTrueMapType())
return paramDeserializerFactory.createMapDeserializer(paramDeserializationContext, (MapType)localMapLikeType, paramBeanDescription);
return paramDeserializerFactory.createMapLikeDeserializer(paramDeserializationContext, localMapLikeType, paramBeanDescription);
}
if (paramJavaType.isCollectionLikeType())
{
JsonFormat.Value localValue = paramBeanDescription.findExpectedFormat(null);
if ((localValue == null) || (localValue.getShape() != JsonFormat.Shape.OBJECT))
{
CollectionLikeType localCollectionLikeType = (CollectionLikeType)paramJavaType;
if (localCollectionLikeType.isTrueCollectionType())
return paramDeserializerFactory.createCollectionDeserializer(paramDeserializationContext, (CollectionType)localCollectionLikeType, paramBeanDescription);
return paramDeserializerFactory.createCollectionLikeDeserializer(paramDeserializationContext, localCollectionLikeType, paramBeanDescription);
}
}
}
if (JsonNode.class.isAssignableFrom(paramJavaType.getRawClass()))
return paramDeserializerFactory.createTreeDeserializer(localDeserializationConfig, paramJavaType, paramBeanDescription);
return paramDeserializerFactory.createBeanDeserializer(paramDeserializationContext, paramJavaType, paramBeanDescription);
}
示例13: BeanDeserializerBase
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
protected BeanDeserializerBase(BeanDeserializerBuilder paramBeanDeserializerBuilder, BeanDescription paramBeanDescription, BeanPropertyMap paramBeanPropertyMap, Map<String, SettableBeanProperty> paramMap, HashSet<String> paramHashSet, boolean paramBoolean1, boolean paramBoolean2)
{
super(paramBeanDescription.getType());
this._classAnnotations = paramBeanDescription.getClassInfo().getAnnotations();
this._beanType = paramBeanDescription.getType();
this._valueInstantiator = paramBeanDeserializerBuilder.getValueInstantiator();
this._beanProperties = paramBeanPropertyMap;
this._backRefs = paramMap;
this._ignorableProps = paramHashSet;
this._ignoreAllUnknown = paramBoolean1;
this._anySetter = paramBeanDeserializerBuilder.getAnySetter();
List localList = paramBeanDeserializerBuilder.getInjectables();
ValueInjector[] arrayOfValueInjector;
if ((localList == null) || (localList.isEmpty()))
arrayOfValueInjector = null;
else
arrayOfValueInjector = (ValueInjector[])localList.toArray(new ValueInjector[localList.size()]);
this._injectables = arrayOfValueInjector;
this._objectIdReader = paramBeanDeserializerBuilder.getObjectIdReader();
boolean bool1;
if ((this._unwrappedPropertyHandler != null) || (this._valueInstantiator.canCreateUsingDelegate()) || (this._valueInstantiator.canCreateFromObjectWith()) || (!this._valueInstantiator.canCreateUsingDefault()))
bool1 = true;
else
bool1 = false;
this._nonStandardCreation = bool1;
JsonFormat.Value localValue = paramBeanDescription.findExpectedFormat(null);
JsonFormat.Shape localShape;
if (localValue == null)
localShape = null;
else
localShape = localValue.getShape();
this._serializationShape = localShape;
this._needViewProcesing = paramBoolean2;
boolean bool2;
if ((!this._nonStandardCreation) && (this._injectables == null) && (!this._needViewProcesing) && (this._objectIdReader != null))
bool2 = true;
else
bool2 = false;
this._vanillaProcessing = bool2;
}
示例14: doSerialize
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
@Override
protected void doSerialize( JsonWriter writer, Date value, JsonSerializationContext ctx, JsonSerializerParameters params ) {
if ( (ctx.isWriteDatesAsTimestamps() || params.getShape().isNumeric()) && params.getShape() != Shape.STRING ) {
writer.value( value.getTime() );
} else {
String date = DateFormat.format( params, value );
if ( null == params.getPattern() ) {
writer.unescapeValue( date );
} else {
writer.value( date );
}
}
}
示例15: testToString
import com.fasterxml.jackson.annotation.JsonFormat.Shape; //导入依赖的package包/类
public void testToString() {
assertEquals("JsonFormat.Value(pattern=null,shape=STRING,lenient=null,locale=null,timezone=null)",
JsonFormat.Value.forShape(JsonFormat.Shape.STRING).toString());
assertEquals("JsonFormat.Value(pattern=[.],shape=ANY,lenient=null,locale=null,timezone=null)",
JsonFormat.Value.forPattern("[.]").toString());
}