Commit 8cb5b3aa authored by Lei Jiang's avatar Lei Jiang Committed by kezhenxu94

[Style] Add curly braces after `if` statements

parent 99a6f5dd
...@@ -47,8 +47,10 @@ public class NamespaceController { ...@@ -47,8 +47,10 @@ public class NamespaceController {
@PathVariable("clusterName") String clusterName, @PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName, @RequestParam String operator) { @PathVariable("namespaceName") String namespaceName, @RequestParam String operator) {
Namespace entity = namespaceService.findOne(appId, clusterName, namespaceName); Namespace entity = namespaceService.findOne(appId, clusterName, namespaceName);
if (entity == null) throw new NotFoundException( if (entity == null) {
throw new NotFoundException(
String.format("namespace not found for %s %s %s", appId, clusterName, namespaceName)); String.format("namespace not found for %s %s %s", appId, clusterName, namespaceName));
}
namespaceService.deleteNamespace(entity, operator); namespaceService.deleteNamespace(entity, operator);
} }
...@@ -63,8 +65,9 @@ public class NamespaceController { ...@@ -63,8 +65,9 @@ public class NamespaceController {
@GetMapping("/namespaces/{namespaceId}") @GetMapping("/namespaces/{namespaceId}")
public NamespaceDTO get(@PathVariable("namespaceId") Long namespaceId) { public NamespaceDTO get(@PathVariable("namespaceId") Long namespaceId) {
Namespace namespace = namespaceService.findOne(namespaceId); Namespace namespace = namespaceService.findOne(namespaceId);
if (namespace == null) if (namespace == null) {
throw new NotFoundException(String.format("namespace not found for %s", namespaceId)); throw new NotFoundException(String.format("namespace not found for %s", namespaceId));
}
return BeanUtils.transform(NamespaceDTO.class, namespace); return BeanUtils.transform(NamespaceDTO.class, namespace);
} }
...@@ -73,8 +76,10 @@ public class NamespaceController { ...@@ -73,8 +76,10 @@ public class NamespaceController {
@PathVariable("clusterName") String clusterName, @PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) { @PathVariable("namespaceName") String namespaceName) {
Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName); Namespace namespace = namespaceService.findOne(appId, clusterName, namespaceName);
if (namespace == null) throw new NotFoundException( if (namespace == null) {
throw new NotFoundException(
String.format("namespace not found for %s %s %s", appId, clusterName, namespaceName)); String.format("namespace not found for %s %s %s", appId, clusterName, namespaceName));
}
return BeanUtils.transform(NamespaceDTO.class, namespace); return BeanUtils.transform(NamespaceDTO.class, namespace);
} }
......
...@@ -90,8 +90,12 @@ public abstract class BaseEntity { ...@@ -90,8 +90,12 @@ public abstract class BaseEntity {
@PrePersist @PrePersist
protected void prePersist() { protected void prePersist() {
if (this.dataChangeCreatedTime == null) dataChangeCreatedTime = new Date(); if (this.dataChangeCreatedTime == null) {
if (this.dataChangeLastModifiedTime == null) dataChangeLastModifiedTime = new Date(); dataChangeCreatedTime = new Date();
}
if (this.dataChangeLastModifiedTime == null) {
dataChangeLastModifiedTime = new Date();
}
} }
@PreUpdate @PreUpdate
......
...@@ -66,7 +66,9 @@ public class BeanUtils { ...@@ -66,7 +66,9 @@ public class BeanUtils {
Set<String> emptyNames = new HashSet<>(); Set<String> emptyNames = new HashSet<>();
for (PropertyDescriptor pd : pds) { for (PropertyDescriptor pd : pds) {
Object srcValue = src.getPropertyValue(pd.getName()); Object srcValue = src.getPropertyValue(pd.getName());
if (srcValue == null) emptyNames.add(pd.getName()); if (srcValue == null) {
emptyNames.add(pd.getName());
}
} }
String[] result = new String[emptyNames.size()]; String[] result = new String[emptyNames.size()];
return emptyNames.toArray(result); return emptyNames.toArray(result);
...@@ -91,7 +93,9 @@ public class BeanUtils { ...@@ -91,7 +93,9 @@ public class BeanUtils {
try { try {
Class<?> clazz = list.get(0).getClass(); Class<?> clazz = list.get(0).getClass();
Field field = deepFindField(clazz, key); Field field = deepFindField(clazz, key);
if (field == null) throw new IllegalArgumentException("Could not find the key"); if (field == null) {
throw new IllegalArgumentException("Could not find the key");
}
field.setAccessible(true); field.setAccessible(true);
for (Object o : list) { for (Object o : list) {
map.put((K) field.get(o), (V) o); map.put((K) field.get(o), (V) o);
...@@ -119,7 +123,9 @@ public class BeanUtils { ...@@ -119,7 +123,9 @@ public class BeanUtils {
try { try {
Class<?> clazz = list.get(0).getClass(); Class<?> clazz = list.get(0).getClass();
Field field = deepFindField(clazz, key); Field field = deepFindField(clazz, key);
if (field == null) throw new IllegalArgumentException("Could not find the key"); if (field == null) {
throw new IllegalArgumentException("Could not find the key");
}
field.setAccessible(true); field.setAccessible(true);
for (Object o : list) { for (Object o : list) {
K k = (K) field.get(o); K k = (K) field.get(o);
...@@ -149,7 +155,9 @@ public class BeanUtils { ...@@ -149,7 +155,9 @@ public class BeanUtils {
try { try {
Class<?> clazz = list.get(0).getClass(); Class<?> clazz = list.get(0).getClass();
Field field = deepFindField(clazz, key); Field field = deepFindField(clazz, key);
if (field == null) throw new IllegalArgumentException("Could not find the key"); if (field == null) {
throw new IllegalArgumentException("Could not find the key");
}
field.setAccessible(true); field.setAccessible(true);
for (Object o : list) { for (Object o : list) {
set.add((K)field.get(o)); set.add((K)field.get(o));
......
...@@ -242,8 +242,12 @@ public class InstanceConfigAuditUtil implements InitializingBean { ...@@ -242,8 +242,12 @@ public class InstanceConfigAuditUtil implements InitializingBean {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) {
if (o == null || getClass() != o.getClass()) return false; return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
InstanceConfigAuditModel model = (InstanceConfigAuditModel) o; InstanceConfigAuditModel model = (InstanceConfigAuditModel) o;
return Objects.equals(appId, model.appId) && return Objects.equals(appId, model.appId) &&
Objects.equals(clusterName, model.clusterName) && Objects.equals(clusterName, model.clusterName) &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment