compile error fix

master
yixian 4 years ago
parent 8fe1b1256f
commit f1cf317943

@ -10,13 +10,18 @@ import com.yixsoft.support.mybatis.utils.FieldDescription;
import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.hibernate.validator.constraints.Range; import org.hibernate.validator.constraints.Range;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotatedElementUtils;
import java.lang.reflect.InvocationTargetException;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@JSONType(naming = PropertyNamingStrategy.SnakeCase) @JSONType(naming = PropertyNamingStrategy.SnakeCase)
public class DefaultClientProfile { public class DefaultClientProfile {
private final Logger logger = LoggerFactory.getLogger(getClass());
@ProfileDesc(value = "周末延迟清算", detail = "周末交易延迟到周二清算") @ProfileDesc(value = "周末延迟清算", detail = "周末交易延迟到周二清算")
private boolean weekendDelay = true; private boolean weekendDelay = true;
@ProfileDesc("手续费包含GST") @ProfileDesc("手续费包含GST")
@ -35,10 +40,12 @@ public class DefaultClientProfile {
return new ClassFieldsDescription<>(getClass()).getFields().stream() return new ClassFieldsDescription<>(getClass()).getFields().stream()
.filter(field -> !"class".equalsIgnoreCase(field.getFieldName())) .filter(field -> !"class".equalsIgnoreCase(field.getFieldName()))
.map(this::convertFieldInfo) .map(this::convertFieldInfo)
.filter(Objects::nonNull)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private JSONObject convertFieldInfo(FieldDescription field) { private JSONObject convertFieldInfo(FieldDescription field) {
try {
Object value = field.readField(this); Object value = field.readField(this);
String fieldName = CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.LOWER_UNDERSCORE).convert(field.getFieldName()); String fieldName = CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.LOWER_UNDERSCORE).convert(field.getFieldName());
JSONObject info = new JSONObject(); JSONObject info = new JSONObject();
@ -69,6 +76,10 @@ public class DefaultClientProfile {
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
} }
return info; return info;
} catch (IllegalAccessException | InvocationTargetException e) {
logger.error("failed to access getter of field {}", field.getFieldName(), e);
return null;
}
} }
public void applyToClientConfig(JSONObject client) { public void applyToClientConfig(JSONObject client) {

Loading…
Cancel
Save