代码优化
This commit is contained in:
parent
90416839ff
commit
80e0a9773a
@ -106,6 +106,10 @@ public class MagicFunctionManager {
|
||||
public void register(FunctionInfo functionInfo) {
|
||||
FunctionInfo oldFunctionInfo = mappings.get(functionInfo.getId());
|
||||
if (oldFunctionInfo != null) {
|
||||
// 完全一致时不用注册
|
||||
if(functionInfo.equals(oldFunctionInfo)){
|
||||
return;
|
||||
}
|
||||
// 如果路径不一致,则需要取消注册
|
||||
if (!Objects.equals(functionInfo.getPath(), oldFunctionInfo.getPath())) {
|
||||
unregister(functionInfo.getId());
|
||||
|
||||
@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FunctionInfo extends MagicEntity {
|
||||
@ -72,4 +73,24 @@ public class FunctionInfo extends MagicEntity {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
FunctionInfo functionInfo = (FunctionInfo) o;
|
||||
return Objects.equals(id, functionInfo.id) &&
|
||||
Objects.equals(path, functionInfo.path) &&
|
||||
Objects.equals(script, functionInfo.script) &&
|
||||
Objects.equals(name, functionInfo.name) &&
|
||||
Objects.equals(groupId, functionInfo.groupId) &&
|
||||
Objects.equals(description, functionInfo.description) &&
|
||||
Objects.equals(parameter, functionInfo.parameter) &&
|
||||
Objects.equals(returnType, functionInfo.returnType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, path, script, name, groupId, parameter, description, returnType);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user