GH-1153 - Removed deprecated FormatableType.
This commit is contained in:
@@ -44,15 +44,6 @@ public enum DependencyType {
|
||||
*/
|
||||
USES_COMPONENT {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.modulith.model.Module.DependencyType#format(org.springframework.modulith.model.FormatableJavaClass, org.springframework.modulith.model.FormatableJavaClass)
|
||||
*/
|
||||
@Override
|
||||
public String format(FormatableType source, FormatableType target) {
|
||||
return String.format("Component %s using %s", source.getAbbreviatedFullName(), target.getAbbreviatedFullName());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.modulith.core.DependencyType#format(org.springframework.modulith.core.FormattableType, org.springframework.modulith.core.FormattableType)
|
||||
@@ -68,16 +59,6 @@ public enum DependencyType {
|
||||
*/
|
||||
ENTITY {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.modulith.model.Module.DependencyType#format(org.springframework.modulith.model.FormatableJavaClass, org.springframework.modulith.model.FormatableJavaClass)
|
||||
*/
|
||||
@Override
|
||||
public String format(FormatableType source, FormatableType target) {
|
||||
return String.format("Entity %s depending on %s", source.getAbbreviatedFullName(),
|
||||
target.getAbbreviatedFullName());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.modulith.core.DependencyType#format(org.springframework.modulith.core.FormattableType, org.springframework.modulith.core.FormattableType)
|
||||
@@ -95,16 +76,6 @@ public enum DependencyType {
|
||||
*/
|
||||
EVENT_LISTENER {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.modulith.model.Module.DependencyType#format(org.springframework.modulith.model.FormatableJavaClass, org.springframework.modulith.model.FormatableJavaClass)
|
||||
*/
|
||||
@Override
|
||||
public String format(FormatableType source, FormatableType target) {
|
||||
return String.format("%s listening to events of type %s", source.getAbbreviatedFullName(),
|
||||
target.getAbbreviatedFullName());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.modulith.core.DependencyType#format(org.springframework.modulith.core.FormattableType, org.springframework.modulith.core.FormattableType)
|
||||
@@ -127,15 +98,6 @@ public enum DependencyType {
|
||||
return supplier.get();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.modulith.model.Module.DependencyType#format(org.springframework.modulith.model.FormatableJavaClass, org.springframework.modulith.model.FormatableJavaClass)
|
||||
*/
|
||||
@Override
|
||||
public String format(FormatableType source, FormatableType target) {
|
||||
return String.format("%s depending on %s", source.getAbbreviatedFullName(), target.getAbbreviatedFullName());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.modulith.core.DependencyType#format(org.springframework.modulith.core.FormattableType, org.springframework.modulith.core.FormattableType)
|
||||
@@ -175,12 +137,6 @@ public enum DependencyType {
|
||||
return forParameter(dependency.getTargetClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.3, prefer {@link #format(FormattableType, FormattableType)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract String format(FormatableType source, FormatableType target);
|
||||
|
||||
public abstract String format(FormattableType source, FormattableType target);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright 2020-2025 the original author 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
|
||||
*
|
||||
* https://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 org.springframework.modulith.core;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.tngtech.archunit.core.domain.JavaClass;
|
||||
|
||||
/**
|
||||
* Wrapper around {@link JavaClass} that allows creating additional formatted names.
|
||||
*
|
||||
* @author Oliver Drotbohm
|
||||
* @deprecated since 1.3, use {@link FormattableType} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class FormatableType {
|
||||
|
||||
/**
|
||||
* Creates a new {@link FormatableType} for the given {@link JavaClass}.
|
||||
*
|
||||
* @param type must not be {@literal null}.
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public static FormatableType of(JavaClass type) {
|
||||
|
||||
Assert.notNull(type, "JavaClass must not be null!");
|
||||
|
||||
return FormattableType.of(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link FormatableType} for the given {@link Class}.
|
||||
*
|
||||
* @param type must not be {@literal null}.
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public static FormatableType of(Class<?> type) {
|
||||
return FormattableType.of(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the given {@link JavaClass}es by rendering a comma-separated list with the abbreviated class names.
|
||||
*
|
||||
* @param types must not be {@literal null}.
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public static String format(Iterable<JavaClass> types) {
|
||||
return FormattableType.format(types);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the abbreviated (i.e. every package fragment reduced to its first character) full name, e.g.
|
||||
* {@code com.acme.MyType} will result in {@code c.a.MyType}.
|
||||
*
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public abstract String getAbbreviatedFullName();
|
||||
|
||||
/**
|
||||
* Returns the abbreviated full name of the type abbreviating only the part of the given {@link ApplicationModule}'s
|
||||
* base package.
|
||||
*
|
||||
* @param module can be {@literal null}.
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public abstract String getAbbreviatedFullName(@Nullable ApplicationModule module);
|
||||
|
||||
/**
|
||||
* Returns the type's full name.
|
||||
*
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
public abstract String getFullName();
|
||||
}
|
||||
@@ -35,8 +35,7 @@ import com.tngtech.archunit.core.domain.JavaClass;
|
||||
*
|
||||
* @author Oliver Drotbohm
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class FormattableType extends FormatableType {
|
||||
public class FormattableType {
|
||||
|
||||
private static final Map<String, FormattableType> CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -44,7 +43,7 @@ public class FormattableType extends FormatableType {
|
||||
private final Supplier<String> abbreviatedName;
|
||||
|
||||
/**
|
||||
* Creates a new {@link FormatableType} for the given source {@link String} and lazily computed abbreviated name.
|
||||
* Creates a new {@link FormattableType} for the given source {@link String} and lazily computed abbreviated name.
|
||||
*
|
||||
* @param type must not be {@literal null} or empty.
|
||||
* @param abbreviatedName must not be {@literal null}.
|
||||
@@ -59,7 +58,7 @@ public class FormattableType extends FormatableType {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link FormatableType} for the given fully-qualified type name.
|
||||
* Creates a new {@link FormattableType} for the given fully-qualified type name.
|
||||
*
|
||||
* @param type must not be {@literal null} or empty.
|
||||
*/
|
||||
@@ -81,7 +80,7 @@ public class FormattableType extends FormatableType {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link FormatableType} for the given {@link JavaClass}.
|
||||
* Creates a new {@link FormattableType} for the given {@link JavaClass}.
|
||||
*
|
||||
* @param type must not be {@literal null}.
|
||||
* @return will never be {@literal null}.
|
||||
@@ -94,7 +93,7 @@ public class FormattableType extends FormatableType {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link FormatableType} for the given {@link Class}.
|
||||
* Creates a new {@link FormattableType} for the given {@link Class}.
|
||||
*
|
||||
* @param type must not be {@literal null}.
|
||||
* @return will never be {@literal null}.
|
||||
@@ -119,20 +118,23 @@ public class FormattableType extends FormatableType {
|
||||
.collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.modulith.core.FormatableType#getAbbreviatedFullName()
|
||||
/**
|
||||
* Returns the abbreviated (i.e. every package fragment reduced to its first character) full name, e.g.
|
||||
* {@code com.acme.MyType} will result in {@code c.a.MyType}.
|
||||
*
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
@Override
|
||||
public String getAbbreviatedFullName() {
|
||||
return abbreviatedName.get();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.modulith.core.FormatableType#getAbbreviatedFullName(org.springframework.modulith.core.ApplicationModule)
|
||||
/**
|
||||
* Returns the abbreviated full name of the type abbreviating only the part of the given {@link ApplicationModule}'s
|
||||
* base package.
|
||||
*
|
||||
* @param module can be {@literal null}.
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
@Override
|
||||
public String getAbbreviatedFullName(@Nullable ApplicationModule module) {
|
||||
|
||||
if (module == null) {
|
||||
@@ -161,11 +163,11 @@ public class FormattableType extends FormatableType {
|
||||
.concat(ClassUtils.getShortName(type));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.modulith.core.FormatableType#getFullName()
|
||||
/**
|
||||
* Returns the type's full name.
|
||||
*
|
||||
* @return will never be {@literal null}.
|
||||
*/
|
||||
@Override
|
||||
public String getFullName() {
|
||||
return type.replace("$", ".");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user