本文整理匯總了Java中javax.lang.model.type.TypeKind.BOOLEAN屬性的典型用法代碼示例。如果您正苦於以下問題:Java TypeKind.BOOLEAN屬性的具體用法?Java TypeKind.BOOLEAN怎麽用?Java TypeKind.BOOLEAN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javax.lang.model.type.TypeKind
的用法示例。
在下文中一共展示了TypeKind.BOOLEAN屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPrimitiveTypeKind
public TypeKind getPrimitiveTypeKind() {
switch (this) {
case BOOLEAN:
return TypeKind.BOOLEAN;
case BYTE:
return TypeKind.BYTE;
case SHORT:
return TypeKind.SHORT;
case INT:
return TypeKind.INT;
case LONG:
return TypeKind.LONG;
case CHAR:
return TypeKind.CHAR;
case FLOAT:
return TypeKind.FLOAT;
case DOUBLE:
return TypeKind.DOUBLE;
case VOID:
return TypeKind.VOID;
default:
throw new AssertionError("unknown primitive type " + this);
}
}
示例2: correspondingGSNames
private static String[] correspondingGSNames(Tree member) {
if (isSetter(member)) {
String name = name(member);
VariableTree param = ((MethodTree)member).getParameters().get(0);
if (param.getType().getKind() == Tree.Kind.PRIMITIVE_TYPE && ((PrimitiveTypeTree)param.getType()).getPrimitiveTypeKind() == TypeKind.BOOLEAN) {
return new String[] {'g' + name.substring(1), "is" + name.substring(3)};
}
return new String[] {'g' + name.substring(1)};
}
if (isGetter(member)) {
return new String[] {'s' + name(member).substring(1)};
}
if (isBooleanGetter(member)) {
return new String[] {"set" + name(member).substring(2)}; //NOI18N
}
return null;
}
示例3: fromPrimitiveOrVoidTypeChar
/**
* Returns the kind from the character describing a primitive or void.
*
* @param ch the character
* @return the kind
*/
public static TypeKind fromPrimitiveOrVoidTypeChar(char ch) {
switch (ch) {
case 'Z':
return TypeKind.BOOLEAN;
case 'C':
return TypeKind.CHAR;
case 'F':
return TypeKind.FLOAT;
case 'D':
return TypeKind.DOUBLE;
case 'B':
return TypeKind.BYTE;
case 'S':
return TypeKind.SHORT;
case 'I':
return TypeKind.INT;
case 'J':
return TypeKind.LONG;
case 'V':
return TypeKind.VOID;
}
throw new IllegalArgumentException("unknown primitive or void type character: " + ch);
}
示例4: getPropertyAccessorName
@Nonnull
private String getPropertyAccessorName( @Nonnull final ExecutableElement method, @Nonnull final String specifiedName )
throws ArezProcessorException
{
String name = ProcessorUtil.deriveName( method, GETTER_PATTERN, specifiedName );
if ( null != name )
{
return name;
}
if ( method.getReturnType().getKind() == TypeKind.BOOLEAN )
{
name = ProcessorUtil.deriveName( method, ISSER_PATTERN, specifiedName );
if ( null != name )
{
return name;
}
}
return method.getSimpleName().toString();
}
示例5: parseResourceBool
private void parseResourceBool(Element element,
Map<TypeElement, BindingSet.Builder> builderMap, Set<TypeElement> erasedTargetNames) {
boolean hasError = false;
TypeElement enclosingElement = (TypeElement) element.getEnclosingElement();
// Verify that the target type is bool.
if (element.asType().getKind() != TypeKind.BOOLEAN) {
error(element, "@%s field type must be 'boolean'. (%s.%s)",
BindBool.class.getSimpleName(), enclosingElement.getQualifiedName(),
element.getSimpleName());
hasError = true;
}
// Verify common generated code restrictions.
hasError |= isInaccessibleViaGeneratedCode(BindBool.class, "fields", element);
hasError |= isBindingInWrongPackage(BindBool.class, element);
if (hasError) {
return;
}
// Assemble information on the field.
String name = element.getSimpleName().toString();
int id = element.getAnnotation(BindBool.class).value();
QualifiedId qualifiedId = elementToQualifiedId(element, id);
BindingSet.Builder builder = getOrCreateBindingBuilder(builderMap, enclosingElement);
builder.addResource(
new FieldResourceBinding(getId(qualifiedId), name, FieldResourceBinding.Type.BOOL));
erasedTargetNames.add(enclosingElement);
}
示例6: findIntrinsifyFactoryMethod
private List<ExecutableElement> findIntrinsifyFactoryMethod(TypeElement nodeClass, TypeMirror[] signature, Map<ExecutableElement, String> nonMatches, boolean requiresInjectedStamp) {
List<ExecutableElement> methods = ElementFilter.methodsIn(nodeClass.getEnclosedElements());
List<ExecutableElement> found = new ArrayList<>(methods.size());
for (ExecutableElement method : methods) {
if (!method.getSimpleName().toString().equals("intrinsify")) {
continue;
}
if (method.getParameters().size() < 2) {
continue;
}
VariableElement firstArg = method.getParameters().get(0);
if (!isTypeCompatible(firstArg.asType(), graphBuilderContextType())) {
continue;
}
VariableElement secondArg = method.getParameters().get(1);
if (!isTypeCompatible(secondArg.asType(), resolvedJavaMethodType())) {
continue;
}
if (method.getReturnType().getKind() != TypeKind.BOOLEAN) {
continue;
}
if (matchSignature(2, method, signature, nonMatches, requiresInjectedStamp)) {
found.add(method);
}
}
return found;
}
示例7: isBeanGetter
static boolean isBeanGetter(final ExecutableElement method) {
final String methodName = simpleName(method);
return isMethod(method)
&& method.getParameters().isEmpty()
&& (GETTER_PATTERN.matcher(methodName).find()
|| (BOOL_IS_GETTER_PATTERN.matcher(methodName).find()
&& method.getReturnType().getKind() == TypeKind.BOOLEAN));
}
示例8: isGetter
public static boolean isGetter(ExecutableElement x) {
final String simpleName = x != null && x.getSimpleName() != null ? x.getSimpleName().toString() : null;
if (simpleName != null && TypeKind.BOOLEAN == x.getReturnType().getKind()) {
return isBooleanGetter(simpleName);
}
return isGetter(simpleName);
}
示例9: createHashCodeLineForField
private String createHashCodeLineForField(VariableTree field) {
Name fieldName = field.getName();
Tree fieldType = field.getType();
if (fieldType.getKind() == Tree.Kind.PRIMITIVE_TYPE) {
if (((PrimitiveTypeTree) fieldType).getPrimitiveTypeKind() == TypeKind.BOOLEAN) {
return "hash += (" + fieldName + " ? 1 : 0"; // NOI18N
}
return "hash += (int)" + fieldName + ";"; // NOI18N
}
return "hash += (" + fieldName + " != null ? " + fieldName + ".hashCode() : 0);"; // NOI18N
}
示例10: isBooleanGetter
private static boolean isBooleanGetter(Tree member) {
return member.getKind() == Tree.Kind.METHOD
&& name(member).startsWith("is") //NOI18N
&& ((MethodTree)member).getParameters().isEmpty()
&& ((MethodTree)member).getReturnType().getKind() == Tree.Kind.PRIMITIVE_TYPE
&& ((PrimitiveTypeTree)((MethodTree)member).getReturnType()).getPrimitiveTypeKind() == TypeKind.BOOLEAN;
}
示例11: prefixedGettersIn
private static ImmutableSet<ExecutableElement> prefixedGettersIn(Iterable<ExecutableElement> methods) {
ImmutableSet.Builder<ExecutableElement> getters = ImmutableSet.builder();
for (ExecutableElement method : methods) {
String name = method.getSimpleName().toString();
// TODO(emcmanus): decide whether getfoo() (without a capital) is a getter. Currently it is.
boolean get = name.startsWith("get") && !name.equals("get");
boolean is = name.startsWith("is") && !name.equals("is")
&& method.getReturnType().getKind() == TypeKind.BOOLEAN;
if (get || is) {
getters.add(method);
}
}
return getters.build();
}
示例12: getterInfo
AbstractJsonMapperGenerator.AccessorInfo getterInfo() {
final String upperCaseFirstLetter = upperCaseFirstLetter(field.getSimpleName().toString());
String prefix = field.asType().getKind() == TypeKind.BOOLEAN ? "is" : "get";
if (allBeanMethods(beanType).contains(prefix + upperCaseFirstLetter)) {
return new AbstractJsonMapperGenerator.AccessorInfo(true, prefix + upperCaseFirstLetter);
}
return new AbstractJsonMapperGenerator.AccessorInfo(false, field.getSimpleName().toString());
}
示例13: createType
public Tree createType(String typeName, TypeElement scope) {
TreeMaker make = getTreeMaker();
TypeKind primitiveTypeKind = null;
if ("boolean".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.BOOLEAN;
} else if ("byte".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.BYTE;
} else if ("short".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.SHORT;
} else if ("int".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.INT;
} else if ("long".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.LONG;
} else if ("char".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.CHAR;
} else if ("float".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.FLOAT;
} else if ("double".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.DOUBLE;
} else if ("void".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.VOID;
}
if (primitiveTypeKind != null) {
return getTreeMaker().PrimitiveType(primitiveTypeKind);
}
Tree typeTree = makeQualIdent(typeName);
if (typeTree == null) {
// XXX does not handle imports; temporary until issue 102149 is fixed
TypeMirror typeMirror = copy.getTreeUtilities().parseType(typeName, scope);
typeTree = make.Type(typeMirror);
}
return typeTree;
}
示例14: createType
public Tree createType(String typeName, TypeElement scope) {
TreeMaker make = getTreeMaker();
TypeKind primitiveTypeKind = null;
if ("boolean".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.BOOLEAN;
} else if ("byte".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.BYTE;
} else if ("short".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.SHORT;
} else if ("int".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.INT;
} else if ("long".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.LONG;
} else if ("char".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.CHAR;
} else if ("float".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.FLOAT;
} else if ("double".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.DOUBLE;
} else if ("void".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.VOID;
}
if (primitiveTypeKind != null) {
return getTreeMaker().PrimitiveType(primitiveTypeKind);
}
Tree typeTree = tryCreateQualIdent(typeName);
if (typeTree == null) {
// XXX does not handle imports; temporary until issue 102149 is fixed
TypeMirror typeMirror = copy.getTreeUtilities().parseType(typeName, scope);
if ( typeMirror == null || typeMirror.getKind() == TypeKind.ERROR ){
typeTree = getTreeMaker().QualIdent( typeName );
}
else {
typeTree = make.Type(typeMirror);
}
}
return typeTree;
}
示例15: getTypeTree
private static Tree getTypeTree(WorkingCopy workingCopy, String typeName) {
TreeMaker make = workingCopy.getTreeMaker();
TypeKind primitiveTypeKind = null;
if ("boolean".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.BOOLEAN;
} else if ("byte".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.BYTE;
} else if ("short".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.SHORT;
} else if ("int".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.INT;
} else if ("long".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.LONG;
} else if ("char".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.CHAR;
} else if ("float".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.FLOAT;
} else if ("double".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.DOUBLE;
} else if ("void".equals(typeName)) { // NOI18N
primitiveTypeKind = TypeKind.VOID;
}
if (primitiveTypeKind != null) {
return make.PrimitiveType(primitiveTypeKind);
} else {
return createQualIdent(workingCopy, typeName);
}
}