Examples of EnumType


Examples of com.alibaba.common.lang.enumeration.Enum.EnumType

     * @param name 枚举量的名称
     *
     * @return 枚举量, 如果不存在, 则返回<code>null</code>
     */
    public static Enum getEnumByName(Class enumClass, String name) {
        EnumType enumType = getEnumType(enumClass);

        if (enumType.enumList.size() != enumType.nameMap.size()) {
            enumType.populateNames(enumClass);
        }

        return (Enum) enumType.nameMap.get(name);
    }
View Full Code Here

Examples of com.google.javascript.jscomp.newtypes.EnumType

    private void visitNamespacePropertyDeclaration(
        Node declNode, Node recv, String pname) {
      Preconditions.checkArgument(
          declNode.isGetProp() || declNode.isStringKey());
      Preconditions.checkArgument(currentScope.isNamespace(recv));
      EnumType et = currentScope.getEnum(recv.getQualifiedName());
      // If there is a reassignment to one of the enum's members, don't consider
      // that a definition of a new property.
      if (et != null && et.enumLiteralHasKey(pname)) {
        return;
      }
      Namespace ns = currentScope.getNamespace(QualifiedName.fromNode(recv));
      JSDocInfo jsdoc = NodeUtil.getBestJSDocInfo(declNode);
      JSType propDeclType = getTypeAtPropDeclNode(declNode, jsdoc);
View Full Code Here

Examples of com.google.javascript.jscomp.newtypes.EnumType

        }
        case Token.GETPROP:
          Node recv = n.getFirstChild();
          JSType recvType = simpleInferExprType(recv);
          if (recvType == null) {
            EnumType et = currentScope.getEnum(recv.getQualifiedName());
            if (et == null) {
              return null;
            }
            if (et.enumLiteralHasKey(n.getLastChild().getString())) {
              return et.getEnumeratedType();
            }
            return null;
          }
          QualifiedName qname = new QualifiedName(n.getLastChild().getString());
          if (!recvType.mayHaveProp(qname)) {
View Full Code Here

Examples of com.google.javascript.jscomp.newtypes.EnumType

        return;
      }
      Node init = NodeUtil.getInitializer(qnameNode);
      // First check if the definition is an alias of a previous enum.
      if (init != null && init.isQualifiedName()) {
        EnumType et = currentScope.getEnum(init.getQualifiedName());
        if (et != null) {
          currentScope.addEnum(qnameNode, et);
          return;
        }
      }
View Full Code Here

Examples of com.google.javascript.rhino.jstype.EnumType

    private EnumType createEnumTypeFromNodes(Node rValue, String name,
        JSDocInfo info, Node lValueNode) {
      Preconditions.checkNotNull(info);
      Preconditions.checkState(info.hasEnumParameterType());

      EnumType enumType = null;
      if (rValue != null && rValue.isQualifiedName()) {
        // Handle an aliased enum.
        Var var = scope.getVar(rValue.getQualifiedName());
        if (var != null && var.getType() instanceof EnumType) {
          enumType = (EnumType) var.getType();
        }
      }

      if (enumType == null) {
        JSType elementsType =
            info.getEnumParameterType().evaluate(scope, typeRegistry);
        enumType = typeRegistry.createEnumType(name, rValue, elementsType);

        if (rValue != null && rValue.isObjectLit()) {
          // collect enum elements
          Node key = rValue.getFirstChild();
          while (key != null) {
            String keyName = NodeUtil.getStringValue(key);
            if (keyName == null) {
              // GET and SET don't have a String value;
              compiler.report(
                  JSError.make(key, ENUM_NOT_CONSTANT, keyName));
            } else if (!codingConvention.isValidEnumKey(keyName)) {
              compiler.report(
                  JSError.make(key, ENUM_NOT_CONSTANT, keyName));
            } else {
              enumType.defineElement(keyName, key);
            }
            key = key.getNext();
          }
        }
      }

      if (name != null && scope.isGlobal()) {
        typeRegistry.declareType(name, enumType.getElementsType());
      }

      return enumType;
    }
View Full Code Here

Examples of com.google.javascript.rhino.jstype.EnumType

    JSType valueType = getJSType(value);
    if (!valueType.isEnumType()) {
      return;
    }

    EnumType valueEnumType = valueType.toMaybeEnumType();
    JSType valueEnumPrimitiveType =
        valueEnumType.getElementsType().getPrimitiveType();
    validator.expectCanAssignTo(t, value, valueEnumPrimitiveType,
        declInfo.getEnumParameterType().evaluate(t.getScope(), typeRegistry),
        "incompatible enum element types");
  }
View Full Code Here

Examples of javax.persistence.EnumType

                        }
                    }
                }
                else if (Enum.class.isAssignableFrom(field.getType()) && annName.equals(JPAAnnotationUtils.ENUMERATED))
                {
                    EnumType type = (EnumType)annotationValues.get("value");
                    jdbcType = (type == EnumType.STRING ? "VARCHAR" : "INTEGER");
                }
                else if (JPAAnnotationUtils.isTemporalType(field.getType()) && annName.equals(JPAAnnotationUtils.TEMPORAL_TYPE))
                {
                    TemporalType type = (TemporalType)annotationValues.get("value");
View Full Code Here

Examples of javax.persistence.EnumType

                    columnDdl = tmp;
                }
            }
            else if (Enum.class.isAssignableFrom(fieldType) && annName.equals(JPAAnnotationUtils.ENUMERATED))
            {
                EnumType type = (EnumType)annotationValues.get("value");
                jdbcType = (type == EnumType.STRING ? "VARCHAR" : "INTEGER");
            }
            else if (JPAAnnotationUtils.isTemporalType(fieldType) && annName.equals(JPAAnnotationUtils.TEMPORAL))
            {
                TemporalType type = (TemporalType)annotationValues.get("value");
View Full Code Here

Examples of javax.persistence.EnumType

   */
  private void getMapKeyEnumerated(List<Annotation> annotationList, Element element) {
    Element subelement = element != null ? element.element( "map-key-enumerated" ) : null;
    if ( subelement != null ) {
      AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyEnumerated.class );
      EnumType value = EnumType.valueOf( subelement.getTextTrim() );
      ad.setValue( "value", value );
      annotationList.add( AnnotationFactory.create( ad ) );
    }
  }
View Full Code Here

Examples of javax.persistence.EnumType

        if (temporal != null) {
            addAnnotation(Temporal.class, fmd).
                add(null, temporal);
        }

        EnumType enumType = getEnumType(field);
        if (enumType != null && enumType != EnumType.ORDINAL) {
            addAnnotation(Enumerated.class, fmd).
                add(null, enumType);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.