Try to create a sensible default for validation pattern, in the case where the java type
of the parameter is an enum type or a primitive or primitive wrapper type
@param javaType
@return
324370
private Optional<Pattern> getDefaultValidationPattern(Class javaType) {
        return javaType.isEnum() ?
                Optional.of(createValidationPatternFromEnumType(javaType)) :
                getDefaultPatternIfPrimitive(javaType);
    }
1120271
public void validateFor(final int type) throws ValueFormatException
   {
      if (constraints == null || constraints.length <= 0)
      {
         return;
      }

      if (type == PropertyType.DATE)
      {
         for (String constrString : constraints)
         {
            try
            {
               MinMaxConstraint constraint = parseAsMinMax(constrString);
               if (constraint.getMin().getThreshold().length() > 0)
               {
                  JCRDateFormat.parse(constraint.getMin().getThreshold());
               }

               if (constraint.getMax().getThreshold().length() > 0)
               {
                  JCRDateFormat.parse(constraint.getMax().getThreshold());
               }
            }
            catch (ValueFormatException e)
            {
               throw new ValueFormatException("Wrong DATE constraint format " + constrString, e);
            }
            catch (ConstraintViolationException e)
            {
               throw new ValueFormatException("Wrong DATE constraint format " + constrString, e);
            }
         }
      }
      else if (type == PropertyType.DOUBLE)
      {
         for (String constrString : constraints)
         {
            try
            {
               MinMaxConstraint constraint = parseAsMinMax(constrString);
               if (constraint.getMin().getThreshold().length() > 0)
               {
                  Double.parseDouble(constraint.getMin().getThreshold());
               }
               if (constraint.getMax().getThreshold().length() > 0)
               {
                  Double.parseDouble(constraint.getMax().getThreshold());
               }
            }
            catch (NumberFormatException e)
            {
               throw new ValueFormatException("Wrong DOUBLE constraint format " + constrString, e);
            }
            catch (ConstraintViolationException e)
            {
               throw new ValueFormatException("Wrong DOUBLE constraint format " + constrString, e);
            }
         }
      }
      else if (type == PropertyType.LONG || type == PropertyType.BINARY)
      {
         for (String constrString : constraints)
         {
            try
            {
               MinMaxConstraint constraint = parseAsMinMax(constrString);
               if (constraint.getMin().getThreshold().length() > 0)
               {
                  Long.parseLong(constraint.getMin().getThreshold());
               }
               if (constraint.getMax().getThreshold().length() > 0)
               {
                  Long.parseLong(constraint.getMax().getThreshold());
               }
            }
            catch (NumberFormatException e)
            {
               throw new ValueFormatException("Wrong LONG (or BINARY size) constraint format " + constrString, e);
            }
            catch (ConstraintViolationException e)
            {
               throw new ValueFormatException("Wrong LONG (or BINARY size) constraint format " + constrString, e);
            }
         }
      }
      else if (type == PropertyType.BOOLEAN)
      {
         for (String constrString : constraints)
         {
            if (!constrString.equalsIgnoreCase("true") && !constrString.equalsIgnoreCase("false"))
            {
               throw new ValueFormatException("Wrong BOOLEAN constraint format: " + constrString);
            }
         }
      }
   }
709799
@Check
	public void checkDefaultValueTypeCompatibleWithParameterType(SarlFormalParameter param) {
		final XExpression defaultValue = param.getDefaultValue();
		if (defaultValue != null) {
			final JvmTypeReference rawType = param.getParameterType();
			assert rawType != null;
			final LightweightTypeReference toType = toLightweightTypeReference(rawType, true);
			if (toType == null) {
				error(MessageFormat.format(
						Messages.SARLValidator_20,
						param.getName()),
						param,
						XtendPackage.Literals.XTEND_PARAMETER__PARAMETER_TYPE,
						ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
						INVALID_TYPE);
				return;
			}
			LightweightTypeReference fromType = getExpectedType(defaultValue);
			if (fromType == null) {
				fromType = getActualType(defaultValue);
				if (fromType == null) {
					error(MessageFormat.format(
							Messages.SARLValidator_21,
							param.getName()),
							param,
							SARL_FORMAL_PARAMETER__DEFAULT_VALUE,
							ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
							INVALID_TYPE);
					return;
				}
			}
			if (!Utils.canCast(fromType, toType, true, false, true)) {
				error(MessageFormat.format(
						Messages.SARLValidator_38,
						getNameOfTypes(fromType), canonicalName(toType)),
						param,
						SARL_FORMAL_PARAMETER__DEFAULT_VALUE,
						ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
						INCOMPATIBLE_TYPES,
						canonicalName(fromType),
						canonicalName(toType));
			}
		}
	}
339612
static Set<String> getJavaDefaultTypes() {
        if (javaDefaultTypes == null) {
            javaDefaultTypes = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
                    "AbstractMethodError",
                    "Appendable",
                    "ArithmeticException",
                    "ArrayIndexOutOfBoundsException",
                    "ArrayStoreException",
                    "AssertionError",
                    "AutoCloseable",
                    "Boolean",
                    "BootstrapMethodError",
                    "Byte",
                    "Character",
                    "CharSequence",
                    "Class",
                    "ClassCastException",
                    "ClassCircularityError",
                    "ClassFormatError",
                    "ClassLoader",
                    "ClassNotFoundException",
                    "ClassValue",
                    "Cloneable",
                    "CloneNotSupportedException",
                    "Comparable",
                    "Compiler",
                    "Deprecated",
                    "Double",
                    "Enum",
                    "EnumConstantNotPresentException",
                    "Error",
                    "Exception",
                    "ExceptionInInitializerError",
                    "Float",
                    "FunctionalInterface",
                    "IllegalAccessError",
                    "IllegalAccessException",
                    "IllegalArgumentException",
                    "IllegalCallerException",
                    "IllegalMonitorStateException",
                    "IllegalStateException",
                    "IllegalThreadStateException",
                    "IncompatibleClassChangeError",
                    "IndexOutOfBoundsException",
                    "InheritableThreadLocal",
                    "InstantiationError",
                    "InstantiationException",
                    "Integer",
                    "InternalError",
                    "InterruptedException",
                    "Iterable",
                    "LayerInstantiationException",
                    "LinkageError",
                    "Long",
                    "Math",
                    "Module",
                    "ModuleLayer",
                    "NegativeArraySizeException",
                    "NoClassDefFoundError",
                    "NoSuchFieldError",
                    "NoSuchFieldException",
                    "NoSuchMethodError",
                    "NoSuchMethodException",
                    "NullPointerException",
                    "Number",
                    "NumberFormatException",
                    "Object",
                    "OutOfMemoryError",
                    "Override",
                    "Package",
                    "Process",
                    "ProcessBuilder",
                    "ProcessHandle",
                    "Readable",
                    "ReflectiveOperationException",
                    "Runnable",
                    "Runtime",
                    "RuntimeException",
                    "RuntimePermission",
                    "SafeVarargs",
                    "SecurityException",
                    "SecurityManager",
                    "Short",
                    "StackOverflowError",
                    "StackTraceElement",
                    "StackWalker",
                    "StrictMath",
                    "String",
                    "StringBuffer",
                    "StringBuilder",
                    "StringIndexOutOfBoundsException",
                    "SuppressWarnings",
                    "System",
                    "Thread",
                    "ThreadDeath",
                    "ThreadGroup",
                    "ThreadLocal",
                    "Throwable",
                    "TypeNotPresentException",
                    "UnknownError",
                    "UnsatisfiedLinkError",
                    "UnsupportedClassVersionError",
                    "UnsupportedOperationException",
                    "VerifyError",
                    "VirtualMachineError",
                    "Void",
                    "boolean",
                    "byte",
                    "char",
                    "double",
                    "float",
                    "int",
                    "long",
                    "short",
                    "void")));
        }
        return javaDefaultTypes;
    }
473084
public static Object defaultValue(final Class<?> type) {
	final Object value = WRAPPER_DEFAULTS.get(Objects.requireNonNull(type));
	if (value == null) {
	    throw new IllegalArgumentException("Not primitive wrapper");
	}
	return value;
    }
293726
public static String getValidType(String type)
    {
        return (validationClassMapper.get(type) == null) ? "binary" : validationClassMapper.get(type);
    }
558506
@Pure
	public String getDefaultValueForType(String type) {
		//TODO: Check if a similar function exists in the Xbase library.
		String defaultValue = "";
		if (!Strings.isEmpty(type) && !"void".equals(type)) {
			switch (type) {
			case "boolean":
				defaultValue = "true";
				break;
			case "double":
				defaultValue = "0.0";
				break;
			case "float":
				defaultValue = "0.0f";
				break;
			case "int":
				defaultValue = "0";
				break;
			case "long":
				defaultValue = "0";
				break;
			case "byte":
				defaultValue = "(0 as byte)";
				break;
			case "short":
				defaultValue = "(0 as short)";
				break;
			case "char":
				defaultValue = "(0 as char)";
				break;
			default:
				defaultValue = "null";
				break;
			}
		}
		return defaultValue;
	}
80727
private Class<?> resolveResultJavaType(Class<?> resultType, String property, Class<?> javaType) {
    if (javaType == null && property != null) {
      try {
        MetaClass metaResultType = MetaClass.forClass(resultType, REFLECTOR_FACTORY);
        javaType = metaResultType.getSetterType(property);
      } catch (Exception ignored) {
        // ignore, following null check statement will deal with the
        // situation
      }
    }
    if (javaType == null) {
      javaType = Object.class;
    }
    return javaType;
  }
433391
protected TypeCodec<?> createCodec(GenericType<?> javaType, boolean isJavaCovariant) {
    TypeToken<?> token = javaType.__getToken();
    if (List.class.isAssignableFrom(token.getRawType())
        && token.getType() instanceof ParameterizedType) {
      Type[] typeArguments = ((ParameterizedType) token.getType()).getActualTypeArguments();
      GenericType<?> elementType = GenericType.of(typeArguments[0]);
      TypeCodec<?> elementCodec = codecFor(elementType, isJavaCovariant);
      return TypeCodecs.listOf(elementCodec);
    } else if (Set.class.isAssignableFrom(token.getRawType())
        && token.getType() instanceof ParameterizedType) {
      Type[] typeArguments = ((ParameterizedType) token.getType()).getActualTypeArguments();
      GenericType<?> elementType = GenericType.of(typeArguments[0]);
      TypeCodec<?> elementCodec = codecFor(elementType, isJavaCovariant);
      return TypeCodecs.setOf(elementCodec);
    } else if (Map.class.isAssignableFrom(token.getRawType())
        && token.getType() instanceof ParameterizedType) {
      Type[] typeArguments = ((ParameterizedType) token.getType()).getActualTypeArguments();
      GenericType<?> keyType = GenericType.of(typeArguments[0]);
      GenericType<?> valueType = GenericType.of(typeArguments[1]);
      TypeCodec<?> keyCodec = codecFor(keyType, isJavaCovariant);
      TypeCodec<?> valueCodec = codecFor(valueType, isJavaCovariant);
      return TypeCodecs.mapOf(keyCodec, valueCodec);
    }
    throw new CodecNotFoundException(null, javaType);
  }
978451
public T annotationType(@NonNull AnnotationType annotationType) {
      this.annotationType.add(annotationType);
      return Cast.as(this);
   }
984244
public <T extends ManagedType> T getJaversManagedType(Class javaClass, Class<T> expectedType) {
        JaversType mType = getJaversType(javaClass);

        if (expectedType.isAssignableFrom(mType.getClass())) {
            return (T) mType;
        } else {
            throw new JaversException(JaversExceptionCode.MANAGED_CLASS_MAPPING_ERROR,
                    javaClass,
                    mType.getClass().getSimpleName(),
                    expectedType.getSimpleName());
        }
    }
455181
public CodeElement setType(String type) {
        Optional<CodeElement> optional = codeElements.stream().filter(ce -> ce.getRole() == CodeElementRole.Primary).findFirst();
        optional.ifPresent(codeElement -> codeElements.remove(codeElement));

        CodeElement codeElement = new CodeElement(type);
        codeElement.setRole(CodeElementRole.Primary);
        this.codeElements.add(codeElement);

        return codeElement;
    }
147344
public static <E extends Enum<E>> EnumStringConverter<E> create(Class<E> enumType) {
        return new EnumStringConverter<E>(enumType);
    }
1332857
public static Type toHibernateType(Class<?> javaType){
		if (javaType == byte.class || javaType == Byte.class) {
			return  ByteType.INSTANCE;
		} 
		if (javaType == char.class || javaType == Character.class) {
			return   CharacterType.INSTANCE;
		} 
		if (javaType == short.class || javaType == Short.class) {
			return  ShortType.INSTANCE;
		} 
		if (javaType == int.class || javaType == Integer.class) {
			return  IntegerType.INSTANCE;
		}
		if (javaType == long.class || javaType == Long.class) {
			return  LongType.INSTANCE;
		}
		if (javaType == float.class || javaType == Float.class) {
			return  FloatType.INSTANCE;
		} 
		if (javaType == double.class || javaType == Double.class) {
			return  DoubleType.INSTANCE;
		}
		if (javaType == String.class) {
			return  StringType.INSTANCE;
		} 
		if (javaType == Date.class) {
			return  DateType.INSTANCE;
		} 
		if (javaType == Timestamp.class) {
			return  TimestampType.INSTANCE;
		}
		throw new IllegalArgumentException("does not support type: " + javaType);
	}
739869
public static Object getPrimitiveDefaultValue(final Class<?> type) {
        ArgUtils.notNull(type, "type");

        if(!type.isPrimitive()) {
            return null;
        }

        if(type.equals(boolean.class)) {
            return false;

        } else if(type.equals(char.class)) {
            return '\u0000';

        } else if(type.equals(byte.class)) {
            return (byte)0;

        } else if(type.equals(short.class)) {
            return (short)0;

        } else if(type.equals(int.class)) {
            return 0;

        } else if(type.equals(long.class)) {
            return 0l;

        } else if(type.equals(float.class)) {
            return 0.0f;

        } else if(type.equals(double.class)) {
            return 0.0d;

        }

        return null;
    }
816284
@Pure
	public XExpression getDefaultXExpressionForType(String type) {
		//TODO: Check if a similar function exists in the Xbase library.
		XExpression expr = null;
		if (type != null && !"void".equals(type) && !Void.class.getName().equals(type)) {
			switch (type) {
			case "boolean":
			case "java.lang.Boolean":
				XBooleanLiteral booleanLiteral = XbaseFactory.eINSTANCE.createXBooleanLiteral();
				booleanLiteral.setIsTrue(false);
				expr = booleanLiteral;
				break;
			case "float":
			case "java.lang.Float":
				XNumberLiteral numberLiteral = XbaseFactory.eINSTANCE.createXNumberLiteral();
				numberLiteral.setValue("0.0f");
				expr = numberLiteral;
				break;
			case "double":
			case "java.lang.Double":
			case "java.lang.BigDecimal":
				numberLiteral = XbaseFactory.eINSTANCE.createXNumberLiteral();
				numberLiteral.setValue("0.0");
				expr = numberLiteral;
				break;
			case "int":
			case "long":
			case "java.lang.Integer":
			case "java.lang.Long":
			case "java.lang.BigInteger":
				numberLiteral = XbaseFactory.eINSTANCE.createXNumberLiteral();
				numberLiteral.setValue("0");
				expr = numberLiteral;
				break;
			case "byte":
			case "short":
			case "char":
			case "java.lang.Byte":
			case "java.lang.Short":
			case "java.lang.Character":
				numberLiteral = XbaseFactory.eINSTANCE.createXNumberLiteral();
				numberLiteral.setValue("0");
				XCastedExpression castExpression = XbaseFactory.eINSTANCE.createXCastedExpression();
				castExpression.setTarget(numberLiteral);
				castExpression.setType(newTypeRef(this.context, type));
				expr = numberLiteral;
				break;
			default:
				expr = XbaseFactory.eINSTANCE.createXNullLiteral();
				break;
			}
		}
		return expr;
	}
6125
public static @Nonnull Optional<Class> arrayTypeForPrimitive(String primitiveType) {
        if (primitiveType != null) {
            return Optional.ofNullable(PRIMITIVE_ARRAY_MAP.get(primitiveType));
        }
        return Optional.empty();
    }