Returns the compile-time constant value of a tree if it is of type clazz, or {@code null}.
974480
@Nullable
  public static <T> T constValue(Tree tree, Class<? extends T> clazz) {
    Object value = constValue(tree);
    return clazz.isInstance(value) ? clazz.cast(value) : null;
  }
973024
@SuppressWarnings("unchecked")
    public <T> T getValue(final ShardingPropertiesConstant shardingPropertiesConstant) {
        if (cachedProperties.containsKey(shardingPropertiesConstant)) {
            return (T) cachedProperties.get(shardingPropertiesConstant);
        }
        String value = props.getProperty(shardingPropertiesConstant.getKey());
        if (Strings.isNullOrEmpty(value)) {
            Object obj = props.get(shardingPropertiesConstant.getKey());
            if (null == obj) {
                value = shardingPropertiesConstant.getDefaultValue();
            } else {
                value = obj.toString();
            }
        }
        Object result;
        if (boolean.class == shardingPropertiesConstant.getType()) {
            result = Boolean.valueOf(value);
        } else if (int.class == shardingPropertiesConstant.getType()) {
            result = Integer.valueOf(value);
        } else if (long.class == shardingPropertiesConstant.getType()) {
            result = Long.valueOf(value);
        } else {
            result = value;
        }
        cachedProperties.put(shardingPropertiesConstant, result);
        return (T) result;
    }
256764
private String getDefaultValue(GroovySourceAST t) {
        GroovySourceAST child = (GroovySourceAST) t.getFirstChild();
        if (t.getNumberOfChildren() != 4) return null;
        for (int i = 1; i < t.getNumberOfChildren(); i++) {
            child = (GroovySourceAST) child.getNextSibling();
        }
        GroovySourceAST nodeToProcess = child;
        if (child.getType() != ANNOTATION_ARRAY_INIT && child.getNumberOfChildren() > 0) {
            nodeToProcess = (GroovySourceAST) child.getFirstChild();
        }
        return getChildTextFromSource(nodeToProcess, ";");
    }
394045
public static String type(Class<? extends ParaObject> clazz) {
		return (clazz == null) ? "" : clazz.getSimpleName().toLowerCase();
	}
89806
public static Tree getErasedTypeTree(Tree tree) {
    return tree.accept(
        new SimpleTreeVisitor<Tree, Void>() {
          @Override
          public Tree visitIdentifier(IdentifierTree tree, Void unused) {
            return tree;
          }

          @Override
          public Tree visitParameterizedType(ParameterizedTypeTree tree, Void unused) {
            return tree.getType();
          }
        },
        null);
  }
796568
@SuppressWarnings("unchecked")
    private <T> Optional<T> getValue(Object object, Supplier<Object> method, Class<T> cls) {

        T source = null;
        if (cls.isInstance(method.get())) {
            source = (T) method.get();
        } else {
            if (CoreParameters.DEVELOPER_MODE.get()) {
                throw new CoreRuntimeException("Cannot cast object " + method.get() + " to " + cls.toGenericString());
            }
        }
        return Optional.ofNullable(source);
    }
202392
@SuppressWarnings("unchecked")
	public static <T> Constructor<T> getConstructor(Class<T> clazz, Class<?>... parameterTypes) {
		if (null == clazz) {
			return null;
		}

		final Constructor<?>[] constructors = getConstructors(clazz);
		Class<?>[] pts;
		for (Constructor<?> constructor : constructors) {
			pts = constructor.getParameterTypes();
			if (ClassUtil.isAllAssignableFrom(pts, parameterTypes)) {
				// 构造可访问
				constructor.setAccessible(true);
				return (Constructor<T>) constructor;
			}
		}
		return null;
	}
438110
@SuppressWarnings("unchecked")
    static <T> T getEnumValue(Class<T> cls, String name) {
        HashMap<String, Object> enumMap = enumMaps.get(cls);
        if (enumMap == null) {
            T[] consts = cls.getEnumConstants();
            enumMap = new HashMap<String, Object>(consts.length);
            for (T e : consts) {
                enumMap.put(((Enum<?>) e).toString(), e);
            }
            enumMaps.put(cls, enumMap);
        }
        T v = (T) enumMap.get(name);
        if (v == null) {
            v = (T) enumMap.get("Other");
        }
        return v;
    }
203672
@Override
    @Nullable
    public Constant getConstant(int column) throws OntopResultConversionException {
        final MainTypeLangValues cell = row.get(column - 1);
        if (cell.getMainValue() == null) {
            return null;
        } else {
            return constantRetriever.getConstantFromJDBC(cell);
        }
    }
449353
public static <T> T getValue(Object target, String dPath, Class<T> clazz) {
        if (clazz == null) {
            throw new NullPointerException("Class parameter is null!");
        }
        Object temp = getValue(target, dPath);
        return ValueUtils.convertValue(temp, clazz);
    }
668285
private static Node getValueParent(Ref ref) {
    // there are four types of declarations: VARs, LETs, CONSTs, and ASSIGNs
    Node n = ref.getNode().getParent();
    return (n != null && NodeUtil.isNameDeclaration(n)) ? ref.getNode() : ref.getNode().getParent();
  }
429506
@Nullable
  public static Type getType(@Nullable Tree tree) {
    return tree instanceof JCTree ? ((JCTree) tree).type : null;
  }
966224
@Nullable
  public static MethodSymbol getSymbol(MemberReferenceTree tree) {
    Symbol sym = ((JCMemberReference) tree).sym;
    return sym instanceof MethodSymbol ? (MethodSymbol) sym : null;
  }
489844
public <T extends UserProperty> T getProperty(Class<T> clazz) {
        for (UserProperty p : properties) {
            if (clazz.isInstance(p))
                return clazz.cast(p);
        }
        return null;
    }
9837
public static <T> Clazz<T> FindClazz( Class<T> clazz )
	{
		return impl.FindClazz( clazz );
	}
890131
public static Nullness getNullnessValue(
      ExpressionTree expr, VisitorState state, NullnessAnalysis nullnessAnalysis) {
    TreePath pathToExpr = new TreePath(state.getPath(), expr);
    return nullnessAnalysis.getNullness(pathToExpr, state.context);
  }
5981
@Nullable
  private static <T> TreePath findEnclosingMethodOrLambdaOrInitializer(TreePath path) {
    while (path != null) {
      if (path.getLeaf() instanceof MethodTree) {
        return path;
      }
      TreePath parent = path.getParentPath();
      if (parent != null) {
        if (parent.getLeaf() instanceof ClassTree) {
          if (path.getLeaf() instanceof BlockTree) {
            // this is a class or instance initializer block
            return path;
          }
          if (path.getLeaf() instanceof VariableTree
              && ((VariableTree) path.getLeaf()).getInitializer() != null) {
            // this is a field with an inline initializer
            return path;
          }
        }
        if (parent.getLeaf() instanceof LambdaExpressionTree) {
          return parent;
        }
      }
      path = parent;
    }
    return null;
  }