Nuke DependencySubsystemVector.Builder inner class
All checks were successful
build-and-test / test (push) Successful in 1m28s
build-and-test / build (push) Successful in 1m34s
build-and-test / generate-javadoc (push) Successful in 1m33s

This commit is contained in:
JeremyStar™ 2024-09-04 17:20:24 +02:00
parent 9b97390a9c
commit 48b0126e5c
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -20,13 +20,9 @@
package de.staropensource.sosengine.base.internal.type;
import de.staropensource.sosengine.base.implementable.SubsystemClass;
import de.staropensource.sosengine.base.implementable.VersioningSystem;
import de.staropensource.sosengine.base.type.DependencyVector;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
/**
* Represents a dependency vector with an additional {@code mainClass} field.
@ -61,104 +57,4 @@ public final class DependencySubsystemVector extends DependencyVector {
super(subsystemClass.getName(), vector.getVersioningSystem(), vector.getVersion(), vector.getDependencies(), vector.getProvides());
this.subsystemClass = subsystemClass;
}
/**
* Creates a new {@link DependencySubsystemVector}.
*
* @param versioningSystem versioning system to use
* @param version version
* @param dependencies dependencies in the usual format ({@code dependencyA}, {@code dependencyB=5.1}, {@code dependencyC>3.1}, {@code dependencyD<6.1}, {@code dependencyE>5.3<5.4})
* @param provides vectors this vector provides, in the usual format ({@code identifier=version})
* @param subsystemClass {@link SubsystemClass} to associate
* @since v1-alpha1
*/
public DependencySubsystemVector(@NotNull Class<? extends VersioningSystem> versioningSystem, @NotNull String version, @NotNull Set<@NotNull String> dependencies, @NotNull Set<@NotNull String> provides, @NotNull SubsystemClass subsystemClass) {
super(subsystemClass.getName(), versioningSystem, version, dependencies, provides);
this.subsystemClass = subsystemClass;
}
/**
* Provides an API for building {@link DependencySubsystemVector}s more easily.
*
* @since v1-alpha4
*/
public static final class Builder extends DependencyVector.Builder {
/**
* Constructs this class.
*
* @since v1-alpha4
*/
public Builder() {}
/**
* Contains the {@link SubsystemClass} to associate.
*
* @see DependencySubsystemVector#subsystemClass
* @since v1-alpha4
*/
private @Nullable SubsystemClass subsystemClass;
/**
* {@inheritDoc}
* @deprecated Use {@link #buildCustom()} instead
*/
@Deprecated
@Override
public @NotNull DependencyVector build() {
return super.build();
}
/**
* Builds a new {@link DependencySubsystemVector} instance.
*
* @return new {@link DependencySubsystemVector}
* @throws IllegalStateException if the identifier, versioning system, version or main class is unset
* @since v1-alpha4
*/
public DependencySubsystemVector buildCustom() {
setIdentifier("this does not need to be set");
// Check for required fields
checkRequiredFields();
// Set defaults
setDefaults();
//noinspection DataFlowIssue // IDE is dumb
return new DependencySubsystemVector(getVersioningSystem(), getVersion(), getDependencies(), getProvides(), subsystemClass);
}
/** {@inheritDoc} */
@Override
protected void checkRequiredFields() throws IllegalStateException {
super.checkRequiredFields();
if (subsystemClass == null)
throw new IllegalStateException("The main class is unset");
}
/**
* Returns the {@link SubsystemClass} to associate.
*
* @return {@link SubsystemClass} to associcate
* @see DependencySubsystemVector#subsystemClass
* @since v1-alpha4
*/
public @Nullable SubsystemClass getSubsystemClass() {
return subsystemClass;
}
/**
* Sets the {@link SubsystemClass} to associate.
*
* @param subsystemClass new {@link SubsystemClass} to associate
* @return builder instance
* @see DependencySubsystemVector#subsystemClass
* @since v1-alpha4
*/
public @NotNull DependencyVector.Builder setIdentifier(@Nullable SubsystemClass subsystemClass) {
this.subsystemClass = subsystemClass;
return this;
}
}
}