@JSONField(serialize = false) public boolean isSymmetric(){ if (getRowCount() != getColumnCount()) return false; for (Map.Entry<Integer, Vec> rowEntry : rows.entrySet()) { int row = rowEntry.getKey(); Vec rowVec = rowEntry.getValue(); for (Integer col : rowVec.getData().keySet()) { if (row == col.intValue()) continue; if(DoubleUtils.equals(rowVec.get(col), this.get(col, row))){ return false; } } } return true; }
public FieldDeserializer createFieldDeserializer(ParserConfig mapping, // JavaBeanInfo beanInfo, // FieldInfo fieldInfo) { Class<?> clazz = beanInfo.clazz; Class<?> fieldClass = fieldInfo.fieldClass; Class<?> deserializeUsing = null; JSONField annotation = fieldInfo.getAnnotation(); if (annotation != null) { deserializeUsing = annotation.deserializeUsing(); if (deserializeUsing == Void.class) { deserializeUsing = null; } } if (deserializeUsing == null && (fieldClass == List.class || fieldClass == ArrayList.class)) { return new ArrayListTypeFieldDeserializer(mapping, clazz, fieldInfo); } return new DefaultFieldDeserializer(mapping, clazz, fieldInfo); }
public static JSONField getSupperMethodAnnotation(Class<?> clazz, Method method) { for (Class<?> interfaceClass : clazz.getInterfaces()) { for (Method interfaceMethod : interfaceClass.getMethods()) { if (interfaceMethod.getName().equals(method.getName()) && interfaceMethod.getParameterTypes().length == method.getParameterTypes().length) { boolean match = true; for (int i = 0; i < interfaceMethod.getParameterTypes().length; i++) { if (!interfaceMethod.getParameterTypes()[i].equals(method.getParameterTypes()[i])) { match = false; break; } } if (match) { JSONField annotation = (JSONField) interfaceMethod.getAnnotation(JSONField.class); if (annotation != null) { return annotation; } } else { continue; } } } } return null; }
public FieldDeserializer createFieldDeserializer(ParserConfig mapping, // JavaBeanInfo beanInfo, // FieldInfo fieldInfo) { Class<?> clazz = beanInfo.clazz; Class<?> fieldClass = fieldInfo.fieldClass; Class<?> deserializeUsing = null; JSONField annotation = fieldInfo.getAnnotation(); if (annotation != null) { deserializeUsing = annotation.deserializeUsing(); if (deserializeUsing == Void.class) { deserializeUsing = null; } } if (deserializeUsing == null && (fieldClass == List.class || fieldClass == ArrayList.class)) { return new ArrayListTypeFieldDeserializer(mapping, clazz, fieldInfo); } return new DefaultFieldDeserializerBug569(mapping, clazz, fieldInfo); }
public FieldSerializer(FieldInfo fieldInfo){ super(); this.fieldInfo = fieldInfo; fieldInfo.setAccessible(true); this.double_quoted_fieldPrefix = '"' + fieldInfo.getName() + "\":"; this.single_quoted_fieldPrefix = '\'' + fieldInfo.getName() + "\':"; this.un_quoted_fieldPrefix = fieldInfo.getName() + ":"; JSONField annotation = fieldInfo.getAnnotation(JSONField.class); if (annotation != null) { for (SerializerFeature feature : annotation.serialzeFeatures()) { if (feature == SerializerFeature.WriteMapNullValue) { writeNull = true; } } } }
public JSONField getAnnotation() { if (this.fieldAnnotation != null) { return this.fieldAnnotation; } return this.methodAnnotation; }
@JSONField(serialize = false) protected String getPrimaryKey() { if (primaryKey != null) { return primaryKey; } String[] primaryKeys = getPrimaryKeys(); if (null != primaryKeys && primaryKeys.length == 1) { primaryKey = primaryKeys[0]; } JbootAssert.assertTrue(primaryKey != null, String.format("get PrimaryKey is error in[%s]", getClass())); return primaryKey; }
@JSONField(serialize = false) public RemotingCommandType getType() { if (this.isResponseType()) { return RemotingCommandType.RESPONSE_COMMAND; } return RemotingCommandType.REQUEST_COMMAND; }
private void _enum(Class<?> cls, MethodVisitor mw, FieldInfo property, Context context) { boolean writeEnumUsingToString = false; JSONField annotation = (JSONField) property.getAnnotation(JSONField.class); if (annotation != null) { for (SerializerFeature feature : annotation.serialzeFeatures()) { if (feature == SerializerFeature.WriteEnumUsingToString) { writeEnumUsingToString = true; } } } Label _not_null = new Label(); Label _end_if = new Label(); Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitTypeInsn(192, "java/lang/Enum"); mw.visitVarInsn(58, context.var("enum")); _filters(mw, property, context, _end); mw.visitVarInsn(25, context.var("enum")); mw.visitJumpInsn(199, _not_null); _if_write_null(mw, property, context); mw.visitJumpInsn(167, _end_if); mw.visitLabel(_not_null); mw.visitVarInsn(25, context.var("out")); mw.visitVarInsn(21, context.var("seperator")); mw.visitVarInsn(25, context.fieldName()); mw.visitVarInsn(25, context.var("enum")); if (writeEnumUsingToString) { mw.visitMethodInsn(182, "java/lang/Object", "toString", "()Ljava/lang/String;"); mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;Ljava/lang/String;)V"); } else { mw.visitMethodInsn(182, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;Ljava/lang/Enum;)V"); } _seperator(mw, context); mw.visitLabel(_end_if); mw.visitLabel(_end); }
@JSONField(serialize = false) public TransactionType getTransactionType() { return transactionType; }
@JSONField(serialize = false) public boolean isRefundSuccess(int num) { return String.valueOf(num).equals(successNum); }
@JSONField(name="id") public VOBuilder kkId(int id) { vo.id = id; return this; }
@JSONField(name = "next_openid") public void setNextOpenid(String nextOpenid) { this.nextOpenid = nextOpenid; }
@JSONField(deserialize = true) public void setA3(String a3) { this.a3 = a3; }
@JSONField(serialize = false) public boolean isOnewayRPC() { int bits = 1 << RPC_ONEWAY; return (this.flag & bits) == bits; }
@JSONField(name="DESC") public void setDescription(String description) { this.description = description; }
@JSONField(name = "sub_button") public void setSubButton(List<MenuButton> subButton) { this.subButton = subButton; }
@JSONField(name = "kf_nick") public void setKfNick(String kfNick) { this.kfNick = kfNick; }
@JSONField(name="CName") public String getCompanyName() { return companyName; }
@JSONField(name="CName") public void setCompanyName(String companyName) { this.companyName = companyName; }
@JSONField(name = "sub_button") public List<MenuButton> getSubButton() { return subButton; }
@JSONField(deserialize = false) public void setA2(String a2) { this.a2 = a2; }
@JSONField(name="KV") public void setKeepgoingValidate(boolean keepgoingValidate) { this.keepgoingValidate = keepgoingValidate; }
@JSONField(name = "mid") public void setId(Long id) { this.id = id; }
@JSONField(name="CR") public void setCheckCircularReference(boolean checkCircularReference) { this.checkCircularReference = checkCircularReference; }
@JSONField(serialize = true, deserialize = false) public void setSpec(Spec spec) { this.spec = spec; }
@JSONField(label = "secret") public String getPassword() { return password; }
/** * 用户所在的分组ID */ @JSONField(name = "groupid") public int getGroupId() { return groupId; }
/** @return the TSUID */ @JSONField(name = "tsuid") public final String getTSUID() { return tsuid; }
@JSONField(serialzeFeatures=SerializerFeature.DisableCircularReferenceDetect) public Object getB() { return b; }
@JSONField(name = "status") public void setStatus(Integer status) { this.status = status; }
private void _enum(Class<?> clazz, MethodVisitor mw, FieldInfo property, Context context) { boolean writeEnumUsingToString = false; JSONField annotation = property.getAnnotation(JSONField.class); if (annotation != null) { for (SerializerFeature feature : annotation.serialzeFeatures()) { if (feature == SerializerFeature.WriteEnumUsingToString) { writeEnumUsingToString = true; } } } Label _not_null = new Label(); Label _end_if = new Label(); Label _end = new Label(); _nameApply(mw, property, context, _end); _get(mw, context, property); mw.visitTypeInsn(CHECKCAST, "java/lang/Enum"); // cast mw.visitVarInsn(ASTORE, context.var("enum")); _filters(mw, property, context, _end); mw.visitVarInsn(ALOAD, context.var("enum")); mw.visitJumpInsn(IFNONNULL, _not_null); _if_write_null(mw, property, context); mw.visitJumpInsn(GOTO, _end_if); mw.visitLabel(_not_null); mw.visitVarInsn(ALOAD, context.var("out")); mw.visitVarInsn(ILOAD, context.var("seperator")); mw.visitVarInsn(ALOAD, context.fieldName()); mw.visitVarInsn(ALOAD, context.var("enum")); if (writeEnumUsingToString) { mw.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "toString", "()Ljava/lang/String;"); mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;Ljava/lang/String;)V"); } else { mw.visitMethodInsn(INVOKEVIRTUAL, "com/alibaba/fastjson/serializer/SerializeWriter", "writeFieldValue", "(CLjava/lang/String;Ljava/lang/Enum;)V"); } _seperator(mw, context); mw.visitLabel(_end_if); mw.visitLabel(_end); }
/** @param tsuid the TSUID to set */ @JSONField(name = "tsuid") public final void setTSUID(String tsuid) { this.tsuid = tsuid; }
@Override @JSONField(serialize = false) public String getX() { return x; }
@JSONCreator public HostPoint(@JSONField(name = "address") HostAddress addr) { this.address = addr; }
@JSONCreator public Fingerprint(@JSONField(name = "source") String fingerprint) { this.source = fingerprint; }
/** * 用户关注时间,为时间戳。 * 如果用户曾多次关注,则取最后关注时间 */ @JSONField(name = "subscribe_time") public String getSubscribeTime() { return subscribeTime; }
@JSONField(name = "groupid") public void setGroupId(int groupId) { this.groupId = groupId; }
@JSONField(name = "_id") public void set_id(Long _id) { this._id = _id; }
@JSONField void setBig(boolean value);