/*
 * $Id$
 *
 * SARL is an general-purpose agent programming language.
 * More details on http://www.sarl.io
 *
 * Copyright (C) 2014-2020 the original authors or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.sarl.lang.typesystem;

import java.io.File;
import java.net.InetAddress;
import java.net.URI;
import java.net.URL;
import java.util.Date;
import java.util.Locale;
import java.util.UUID;

import com.google.inject.Singleton;
import org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference;

/**
 * Tool for validating the types against their immutability.
 *
 * <p>An immutable type is a type those state cannot be changed after it is constructed.
 *
 * @author $Author: sgalland$
 * @version $FullVersion$
 * @mavengroupid $GroupId$
 * @mavenartifactid $ArtifactId$
 * @since 0.8
 */
@Singleton
public class DefaultImmutableTypeValidator implements IImmutableTypeValidator {

	private static final Class<?>[] IMMUTABLE_TYPES = {
		String.class,
		UUID.class,
		URL.class,
		URI.class,
		Enum.class,
		Number.class,
		Date.class,
		File.class,
		Locale.class,
		InetAddress.class,
		StackTraceElement.class,
	};

	@Override
	public boolean isImmutable(LightweightTypeReference type) {
		assert type != null;
		final LightweightTypeReference ref = type.getPrimitiveIfWrapperType();
		if (ref.isArray()) {
			return false;
		}
		if (ref.isPrimitive() || ref.isPrimitiveVoid()) {
			return true;
		}
		for (final Class<?> jvmType : IMMUTABLE_TYPES) {
			if (type.isSubtypeOf(jvmType)) {
				return true;
			}
		}
		return false;
	}

}

@@ -856,16 +856,465 @@
 et.URL;%0A
+import java.security.Permission;%0Aimport java.time.Clock;%0Aimport java.time.Duration;%0Aimport java.time.Instant;%0Aimport java.time.LocalDate;%0Aimport java.time.LocalDateTime;%0Aimport java.time.LocalTime;%0Aimport java.time.MonthDay;%0Aimport java.time.OffsetDateTime;%0Aimport java.time.OffsetTime;%0Aimport java.time.Period;%0Aimport java.time.Year;%0Aimport java.time.YearMonth;%0Aimport java.time.ZoneId;%0Aimport java.time.ZoneOffset;%0Aimport java.time.ZonedDateTime;%0A
 import j
@@ -2008,105 +2008,517 @@
 ,%0A%09%09
-Number.class,%0A%09%09Date.class,%0A%09%09File.class,%0A%09%09Locale.class,%0A%09%09InetAddress.class,%0A%09%09StackTraceElemen
+Byte.class,%0A%09%09Short.class,%0A%09%09Integer.class,%0A%09%09Long.class,%0A%09%09Double.class,%0A%09%09Float.class,%0A%09%09Character.class,%0A%09%09Boolean.class,%0A%09%09Date.class,%0A%09%09File.class,%0A%09%09Locale.class,%0A%09%09InetAddress.class,%0A%09%09StackTraceElement.class,%0A%09%09Permission.class,%0A%09%09Clock.class,%0A%09%09Duration.class,%0A%09%09Instant.class,%0A%09%09LocalDate.class,%0A%09%09LocalDateTime.class,%0A%09%09LocalTime.class,%0A%09%09MonthDay.class,%0A%09%09OffsetDateTime.class,%0A%09%09OffsetTime.class,%0A%09%09Period.class,%0A%09%09Year.class,%0A%09%09YearMonth.class,%0A%09%09ZonedDateTime.class,%0A%09%09ZoneId.class,%0A%09%09ZoneOffse
 t.cl

Add more definitions of known immutable types.