static PropertyType of(final Type type) {
		requireNonNull(type);

		// 1) Check for ArrayType.
		if (type instanceof Class<?> arrayType && arrayType.isArray()) {
			if (arrayType.componentType().isPrimitive()) {
				return new ElementType(arrayType);
			} else {
				return new ArrayType(
					arrayType,
					arrayType.getComponentType()
				);
			}
		}

		// 2) Check for OptionalType.
		if (type instanceof ParameterizedType parameterizedType &&
			parameterizedType.getRawType() instanceof Class<?> optionalType &&
			Optional.class.isAssignableFrom(optionalType))
		{
			final var typeArguments = parameterizedType.getActualTypeArguments();
			if (typeArguments.length == 1 &&
				toRawType(typeArguments[0]) != null)
			{
				return new OptionalType(toRawType(typeArguments[0]) );
			}
		}
		if (type instanceof Class<?> optionalType &&
			Optional.class.isAssignableFrom(optionalType))
		{
			return new OptionalType(Object.class);
		}

		// 3) Check for ListType.
		if (type instanceof ParameterizedType parameterizedType &&
			parameterizedType.getRawType() instanceof Class<?> listType &&
			List.class.isAssignableFrom(listType))
		{
			final var typeArguments = parameterizedType.getActualTypeArguments();
			if (typeArguments.length == 1 &&
				toRawType(typeArguments[0]) != null)
			{
				return new ListType(listType, toRawType(typeArguments[0]) );
			}
		}
		if (type instanceof Class<?> listType &&
			List.class.isAssignableFrom(listType))
		{
			return new ListType(listType, Object.class);
		}

		// 4) Check for RecordType.
		if (type instanceof Class<?> cls && cls.isRecord()) {
			return new RecordType(cls);
		}

		final Class<?> rawType = toRawType(type);

		// 5) Check for ElementType.
		if (rawType != null) {
			if (isElementType(rawType)) {
				return new ElementType(rawType);
			}
		}

		// 5) Rest must be BeanType
		if (rawType != null) {
			return new BeanType(rawType);
		}

		throw new IllegalArgumentException("Unknown type '%s'.".formatted(type));
	}
Creates a property type from the given {@code type}.

@param type the java type
@return the converted property type
jenetics.incubator/src/main/java/io/jenetics/incubator/beans/reflect/PropertyType.java