当前位置: 首页>>代码示例>>Java>>正文


Java Flags.isFinal方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.Flags.isFinal方法的典型用法代码示例。如果您正苦于以下问题:Java Flags.isFinal方法的具体用法?Java Flags.isFinal怎么用?Java Flags.isFinal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.Flags的用法示例。


在下文中一共展示了Flags.isFinal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDelegateCandidates

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
private static IMethodBinding[] getDelegateCandidates(
    ITypeBinding binding, ITypeBinding hierarchy) {
  List<IMethodBinding> allMethods = new ArrayList<IMethodBinding>();
  boolean isInterface = binding.isInterface();
  IMethodBinding[] typeMethods = binding.getDeclaredMethods();
  for (int index = 0; index < typeMethods.length; index++) {
    final int modifiers = typeMethods[index].getModifiers();
    if (!typeMethods[index].isConstructor()
        && !Modifier.isStatic(modifiers)
        && (isInterface || Modifier.isPublic(modifiers))) {
      IMethodBinding result =
          Bindings.findOverriddenMethodInHierarchy(hierarchy, typeMethods[index]);
      if (result != null && Flags.isFinal(result.getModifiers())) continue;
      ITypeBinding[] parameterBindings = typeMethods[index].getParameterTypes();
      boolean upper = false;
      for (int offset = 0; offset < parameterBindings.length; offset++) {
        if (parameterBindings[offset].isWildcardType()
            && parameterBindings[offset].isUpperbound()) upper = true;
      }
      if (!upper) allMethods.add(typeMethods[index]);
    }
  }
  return allMethods.toArray(new IMethodBinding[allMethods.size()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:StubUtility2.java

示例2: parseKasper3BeanFieldGetter

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
private static DtoField parseKasper3BeanFieldGetter(IMethod method) throws JavaModelException {
	if (method.isConstructor() || !Flags.isPublic(method.getFlags()) || !Flags.isFinal(method.getFlags())) {
		return null;
	}
	String methodName = method.getElementName();
	if (!methodName.startsWith("get")) {
		return null;
	}

	String constantCaseName = StringUtils.toConstantCase(KspStringUtils.getFieldNameFromGetter(method.getElementName()));
	String label = "Unknown";
	Boolean persistent = false;

	return new DtoField(constantCaseName, label, "Unknown", persistent);
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:16,代码来源:DtoUtils.java

示例3: isVertigoDtoType

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
/**
 * Indique si le type donné est un DtObject Vertigo.
 * 
 * @param type Type JDT.
 * @return <code>true</code> si le type est un DtObject.
 */
public static boolean isVertigoDtoType(IType type) {
	try {
		/* Vérifie que c'est une classe publique final. */
		if (!type.isClass() || !Flags.isPublic(type.getFlags()) || !Flags.isFinal(type.getFlags())) {
			return false;
		}
		/* Vérifie les interfaces. */
		return hasVertigoDtoTypeInterface(type);
	} catch (JavaModelException e) {
		ErrorUtils.handle(e);
	}
	return false;
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:20,代码来源:JdtUtils.java

示例4: getFieldNameSuggestions

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
public static String[] getFieldNameSuggestions(IJavaProject project, String baseName, int dimensions, int modifiers,
		String[] excluded) {
	if (Flags.isFinal(modifiers) && Flags.isStatic(modifiers)) {
		return getVariableNameSuggestions(NamingConventions.VK_STATIC_FINAL_FIELD, project, baseName, dimensions,
				new ExcludedCollection(excluded), true);
	} else if (Flags.isStatic(modifiers)) {
		return getVariableNameSuggestions(NamingConventions.VK_STATIC_FIELD, project, baseName, dimensions,
				new ExcludedCollection(excluded), true);
	}
	return getVariableNameSuggestions(NamingConventions.VK_INSTANCE_FIELD, project, baseName, dimensions,
			new ExcludedCollection(excluded), true);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:13,代码来源:StubUtility.java

示例5: getModifier

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
private String getModifier(int modifiers) {
	if (Flags.isPublic(modifiers) && Flags.isStatic(modifiers) && Flags.isFinal(modifiers))
		return "constant ";
	if (Flags.isPublic(modifiers))
		return "public ";
	if (Flags.isPrivate(modifiers))
		return "private ";
	if (Flags.isProtected(modifiers))
		return "protected ";
	return "";
}
 
开发者ID:ioanaverebi,项目名称:Sparrow,代码行数:12,代码来源:ModelVisitor.java

示例6: getFieldNameSuggestions

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
public static String[] getFieldNameSuggestions(
    IJavaProject project, String baseName, int dimensions, int modifiers, String[] excluded) {
  if (Flags.isFinal(modifiers) && Flags.isStatic(modifiers)) {
    return getVariableNameSuggestions(
        NamingConventions.VK_STATIC_FINAL_FIELD,
        project,
        baseName,
        dimensions,
        new ExcludedCollection(excluded),
        true);
  } else if (Flags.isStatic(modifiers)) {
    return getVariableNameSuggestions(
        NamingConventions.VK_STATIC_FIELD,
        project,
        baseName,
        dimensions,
        new ExcludedCollection(excluded),
        true);
  }
  return getVariableNameSuggestions(
      NamingConventions.VK_INSTANCE_FIELD,
      project,
      baseName,
      dimensions,
      new ExcludedCollection(excluded),
      true);
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:StubUtility.java

示例7: isDelegateCreationAvailable

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
public static boolean isDelegateCreationAvailable(final IField field) throws JavaModelException {
  return field.exists()
      && (Flags.isStatic(field.getFlags()) && Flags.isFinal(field.getFlags()) /*
 * &&
 * hasInitializer(field)
 */);
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:RefactoringAvailabilityTester.java

示例8: appendFieldDeclaration

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
protected void appendFieldDeclaration(final IField field) throws JavaModelException {
  appendFlags(field);
  fBuffer.append(" "); // $NON-NLS-1$
  final String signature = field.getTypeSignature();
  fBuffer.append(Signature.toString(signature));
  fBuffer.append(" "); // $NON-NLS-1$
  fBuffer.append(field.getElementName());
  if (Flags.isFinal(field.getFlags())) {
    fBuffer.append("="); // $NON-NLS-1$
    appendExpression(signature);
  }
  fBuffer.append(";"); // $NON-NLS-1$
}
 
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:StubCreator.java

示例9: AccessAnalyzer

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
public AccessAnalyzer(
    SelfEncapsulateFieldRefactoring refactoring,
    ICompilationUnit unit,
    IVariableBinding field,
    ITypeBinding declaringClass,
    ASTRewrite rewriter,
    ImportRewrite importRewrite) {
  Assert.isNotNull(refactoring);
  Assert.isNotNull(unit);
  Assert.isNotNull(field);
  Assert.isNotNull(declaringClass);
  Assert.isNotNull(rewriter);
  Assert.isNotNull(importRewrite);
  fCUnit = unit;
  fFieldBinding = field.getVariableDeclaration();
  fDeclaringClassBinding = declaringClass;
  fRewriter = rewriter;
  fImportRewriter = importRewrite;
  fGroupDescriptions = new ArrayList<TextEditGroup>();
  fGetter = refactoring.getGetterName();
  fSetter = refactoring.getSetterName();
  fEncapsulateDeclaringClass = refactoring.getEncapsulateDeclaringClass();
  try {
    fIsFieldFinal = Flags.isFinal(refactoring.getField().getFlags());
  } catch (JavaModelException e) {
    // assume non final field
  }
  fStatus = new RefactoringStatus();
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:AccessAnalyzer.java

示例10: areAllFinalFields

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
private static boolean areAllFinalFields(IField[] fields) throws JavaModelException {
    for (int i = 0; i < fields.length; i++) {
        if (!Flags.isFinal(fields[i].getFlags())) {
            return false;
        }
    }
    return true;
}
 
开发者ID:maximeAudrain,项目名称:jenerate,代码行数:9,代码来源:MethodContentGenerations.java

示例11: getSetterStub

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
/**
 * Create a stub for a getter of the given field using getter/setter
 * templates. The resulting code has to be formatted and indented.
 *
 * @param field
 *            The field to create a getter for
 * @param setterName
 *            The chosen name for the setter
 * @param addComments
 *            If <code>true</code>, comments will be added.
 * @param flags
 *            The flags signaling visibility, if static, synchronized or
 *            final
 * @return Returns the generated stub.
 * @throws CoreException
 *             when stub creation failed
 */
public static String getSetterStub(IField field, String setterName, boolean addComments, int flags) throws CoreException {

	String fieldName = field.getElementName();
	IType parentType = field.getDeclaringType();

	String returnSig = field.getTypeSignature();
	String typeName = Signature.toString(returnSig);

	IJavaProject project = field.getJavaProject();

	String accessorName = StubUtility.getBaseName(field);
	String argname = StubUtility.suggestArgumentName(project, accessorName, EMPTY);

	boolean isStatic = Flags.isStatic(flags);
	boolean isSync = Flags.isSynchronized(flags);
	boolean isFinal = Flags.isFinal(flags);

	String lineDelim = "\n"; // Use default line delimiter, as generated stub has to be formatted anyway //$NON-NLS-1$
	StringBuffer buf = new StringBuffer();
	if (addComments) {
		String comment = CodeGeneration.getSetterComment(field.getCompilationUnit(), parentType.getTypeQualifiedName('.'), setterName, field.getElementName(), typeName, argname, accessorName, lineDelim);
		if (comment != null) {
			buf.append(comment);
		}
	}
	buf.append(JdtFlags.getVisibilityString(flags));
	buf.append(' ');
	if (isStatic) {
		buf.append("static "); //$NON-NLS-1$
	}
	if (isSync) {
		buf.append("synchronized "); //$NON-NLS-1$
	}
	if (isFinal) {
		buf.append("final "); //$NON-NLS-1$
	}

	buf.append("void "); //$NON-NLS-1$
	buf.append(setterName);
	buf.append('(');
	buf.append(typeName);
	buf.append(' ');
	buf.append(argname);
	buf.append(") {"); //$NON-NLS-1$
	buf.append(lineDelim);

	if (argname.equals(fieldName) || !isStatic) {
		if (isStatic) {
			fieldName = parentType.getElementName() + '.' + fieldName;
		} else {
			fieldName = "this." + fieldName; //$NON-NLS-1$
		}
	}
	String body = CodeGeneration.getSetterMethodBodyContent(field.getCompilationUnit(), parentType.getTypeQualifiedName('.'), setterName, fieldName, argname, lineDelim);
	if (body != null) {
		buf.append(body);
	}
	buf.append("}"); //$NON-NLS-1$
	return buf.toString();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:78,代码来源:GetterSetterUtil.java

示例12: getGetterStub

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
/**
 * Create a stub for a getter of the given field using getter/setter
 * templates. The resulting code has to be formatted and indented.
 *
 * @param field
 *            The field to create a getter for
 * @param getterName
 *            The chosen name for the getter
 * @param addComments
 *            If <code>true</code>, comments will be added.
 * @param flags
 *            The flags signaling visibility, if static, synchronized or
 *            final
 * @return Returns the generated stub.
 * @throws CoreException
 *             when stub creation failed
 */
public static String getGetterStub(IField field, String getterName, boolean addComments, int flags) throws CoreException {
	String fieldName = field.getElementName();
	IType parentType = field.getDeclaringType();

	boolean isStatic = Flags.isStatic(flags);
	boolean isSync = Flags.isSynchronized(flags);
	boolean isFinal = Flags.isFinal(flags);

	String typeName = Signature.toString(field.getTypeSignature());
	String accessorName = StubUtility.getBaseName(field);

	String lineDelim = "\n"; // Use default line delimiter, as generated stub has to be formatted anyway //$NON-NLS-1$
	StringBuffer buf = new StringBuffer();
	if (addComments) {
		String comment = CodeGeneration.getGetterComment(field.getCompilationUnit(), parentType.getTypeQualifiedName('.'), getterName, field.getElementName(), typeName, accessorName, lineDelim);
		if (comment != null) {
			buf.append(comment);
		}
	}

	buf.append(JdtFlags.getVisibilityString(flags));
	buf.append(' ');
	if (isStatic) {
		buf.append("static "); //$NON-NLS-1$
	}
	if (isSync) {
		buf.append("synchronized "); //$NON-NLS-1$
	}
	if (isFinal) {
		buf.append("final "); //$NON-NLS-1$
	}

	buf.append(typeName);
	buf.append(' ');
	buf.append(getterName);
	buf.append("() {"); //$NON-NLS-1$
	buf.append(lineDelim);

	String body = CodeGeneration.getGetterMethodBodyContent(field.getCompilationUnit(), parentType.getTypeQualifiedName('.'), getterName, fieldName, lineDelim);
	if (body != null) {
		buf.append(body);
	}
	buf.append("}"); //$NON-NLS-1$
	return buf.toString();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:63,代码来源:GetterSetterUtil.java

示例13: getModifiers

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
private String getModifiers(int flags, int typeFlags) {
  StringBuilder modifiers = new StringBuilder();
  // package private modifier has no string representation

  if (Flags.isPublic(flags)) {
    modifiers.append("public ");
  }

  if (Flags.isProtected(flags)) {
    modifiers.append("protected ");
  }

  if (Flags.isPrivate(flags)) {
    modifiers.append("private ");
  }

  if (Flags.isStatic(flags)) {
    modifiers.append("static ");
  }

  if (Flags.isAbstract(flags) && !Flags.isInterface(typeFlags)) {
    modifiers.append("abstract ");
  }

  if (Flags.isFinal(flags)) {
    modifiers.append("final ");
  }

  if (Flags.isNative(flags)) {
    modifiers.append("native ");
  }

  if (Flags.isSynchronized(flags)) {
    modifiers.append("synchronized ");
  }

  if (Flags.isVolatile(flags)) {
    modifiers.append("volatile ");
  }

  int len = modifiers.length();
  if (len == 0) return "";
  modifiers.setLength(len - 1);
  return modifiers.toString();
}
 
开发者ID:eclipse,项目名称:che,代码行数:46,代码来源:SourcesFromBytecodeGenerator.java

示例14: decorateImageDescriptor

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
/**
 * Returns a version of <code>descriptor</code> decorated according to the passed <code>modifier
 * </code> flags.
 *
 * @param descriptor the image descriptor to decorate
 * @param proposal the proposal
 * @return an image descriptor for a method proposal
 * @see org.eclipse.jdt.core.Flags
 */
private ImageDescriptor decorateImageDescriptor(
    ImageDescriptor descriptor, CompletionProposal proposal) {
  int adornments = 0;
  int flags = proposal.getFlags();
  int kind = proposal.getKind();

  boolean deprecated = Flags.isDeprecated(flags);
  if (!deprecated) {
    CompletionProposal[] requiredProposals = proposal.getRequiredProposals();
    if (requiredProposals != null) {
      for (int i = 0; i < requiredProposals.length; i++) {
        CompletionProposal requiredProposal = requiredProposals[i];
        if (requiredProposal.getKind() == CompletionProposal.TYPE_REF) {
          deprecated |= Flags.isDeprecated(requiredProposal.getFlags());
        }
      }
    }
  }
  if (deprecated) adornments |= JavaElementImageDescriptor.DEPRECATED;

  if (kind == CompletionProposal.FIELD_REF
      || kind == CompletionProposal.METHOD_DECLARATION
      || kind == CompletionProposal.METHOD_NAME_REFERENCE
      || kind == CompletionProposal.METHOD_REF
      || kind == CompletionProposal.CONSTRUCTOR_INVOCATION)
    if (Flags.isStatic(flags)) adornments |= JavaElementImageDescriptor.STATIC;

  if (kind == CompletionProposal.METHOD_DECLARATION
      || kind == CompletionProposal.METHOD_NAME_REFERENCE
      || kind == CompletionProposal.METHOD_REF
      || kind == CompletionProposal.CONSTRUCTOR_INVOCATION)
    if (Flags.isSynchronized(flags)) adornments |= JavaElementImageDescriptor.SYNCHRONIZED;
  if (kind == CompletionProposal.METHOD_DECLARATION
      || kind == CompletionProposal.METHOD_NAME_REFERENCE
      || kind == CompletionProposal.METHOD_REF)
    if (Flags.isDefaultMethod(flags)) adornments |= JavaElementImageDescriptor.DEFAULT_METHOD;
  if (kind == CompletionProposal.ANNOTATION_ATTRIBUTE_REF)
    if (Flags.isAnnnotationDefault(flags))
      adornments |= JavaElementImageDescriptor.ANNOTATION_DEFAULT;

  if (kind == CompletionProposal.TYPE_REF && Flags.isAbstract(flags) && !Flags.isInterface(flags))
    adornments |= JavaElementImageDescriptor.ABSTRACT;

  if (kind == CompletionProposal.FIELD_REF) {
    if (Flags.isFinal(flags)) adornments |= JavaElementImageDescriptor.FINAL;
    if (Flags.isTransient(flags)) adornments |= JavaElementImageDescriptor.TRANSIENT;
    if (Flags.isVolatile(flags)) adornments |= JavaElementImageDescriptor.VOLATILE;
  }

  return new JavaElementImageDescriptor(
      descriptor, adornments /*, JavaElementImageProvider.SMALL_SIZE*/);
}
 
开发者ID:eclipse,项目名称:che,代码行数:62,代码来源:CompletionProposalLabelProvider.java

示例15: isFinal

import org.eclipse.jdt.core.Flags; //导入方法依赖的package包/类
public static boolean isFinal(IMember member) throws JavaModelException {
  if (isInterfaceOrAnnotationField(member)) return true;
  if (isAnonymousType(member)) return true;
  if (isEnumConstant(member) || isEnumTypeFinal(member)) return true;
  return Flags.isFinal(member.getFlags());
}
 
开发者ID:eclipse,项目名称:che,代码行数:7,代码来源:JdtFlags.java


注:本文中的org.eclipse.jdt.core.Flags.isFinal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。