-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* check connection by default #401 (#456) * enhancement:support more type value as parameter in session.value2Nvalue (#511) * enhancement:support more type value as parameter in session.value2Nvalue * code style for #511 * code style for #511 * Add maven wrapper (#513) Co-authored-by: Will Droste <[email protected]> * recreate session for both session error and connection exception * fix style check * sleep for docker restart --------- Co-authored-by: vchangpengfei <[email protected]> Co-authored-by: 大叶 <[email protected]> Co-authored-by: Will Droste <[email protected]>
- Loading branch information
1 parent
21415fe
commit 9e484eb
Showing
10 changed files
with
777 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip | ||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
client/src/main/java/com/vesoft/nebula/util/ReflectUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* Copyright (c) 2023 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
|
||
package com.vesoft.nebula.util; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
|
||
/** | ||
* The util of reflect | ||
* | ||
* @author yeweicheng | ||
* <br>Now is history! | ||
*/ | ||
public class ReflectUtil { | ||
|
||
/** | ||
* Break through the access rights of the object | ||
* and obtain the specified field value. | ||
* | ||
* @param o object of field value source | ||
* @param field field used for get value | ||
* @return field value in obj | ||
*/ | ||
public static Object getValue(Object o, Field field) { | ||
try { | ||
boolean accessible = field.isAccessible(); | ||
if (accessible) { | ||
return field.get(o); | ||
} else { | ||
field.setAccessible(true); | ||
Object value = field.get(o); | ||
field.setAccessible(false); | ||
return value; | ||
} | ||
} catch (IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
/** | ||
* Determine whether parentType is paramType or its parent class or interface | ||
* | ||
* @param paramType type to be determined - subclass | ||
* @param parentType type to be determined - parent class or interface | ||
* @return whether paramType is a subclass or implementation class of parentType | ||
*/ | ||
public static boolean isCurrentTypeOrParentType(Class<?> paramType, Class<?> parentType) { | ||
if (paramType == parentType) { | ||
return true; | ||
} | ||
Set<Class<?>> parentTypes = getParentTypes(paramType); | ||
return parentTypes.contains(parentType); | ||
} | ||
|
||
/** | ||
* Get the super class and interface type collection according to paramType. | ||
* | ||
* @param paramType subclass type. | ||
* @return super class and interface. | ||
*/ | ||
public static Set<Class<?>> getParentTypes(Class<?> paramType) { | ||
if (paramType == null) { | ||
return Collections.EMPTY_SET; | ||
} | ||
List<Class<?>> interfaces = Arrays.asList(paramType.getInterfaces()); | ||
Set<Class<?>> parents = new HashSet<>(interfaces); | ||
|
||
for (Class<?> anInterface : interfaces) { | ||
parents.addAll(getParentTypes(anInterface)); | ||
} | ||
|
||
Class<?> superclass = paramType.getSuperclass(); | ||
parents.add(superclass); | ||
parents.addAll(getParentTypes(superclass)); | ||
return parents; | ||
} | ||
} |
Oops, something went wrong.