summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2019-01-04 15:20:40 +0100
committergjoranv <gv@oath.com>2019-01-21 15:09:30 +0100
commit79f7da786489e4e6f5966519e6de12381a07c7a2 (patch)
tree80dc571d17544bb4196fc33dac96a1ee41afc29c
parent21c6924e98b35a93edc3322296a8d7a3bfd39a2c (diff)
Remove deprecated duplicate Version class
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java27
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/model/api/ModelFactory.java9
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/Version.java184
-rw-r--r--config-provisioning/src/test/java/com/yahoo/config/provision/VersionTest.java70
4 files changed, 2 insertions, 288 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java b/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java
index 06da1eccf27..06f8034453d 100644
--- a/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java
+++ b/config-model-api/src/main/java/com/yahoo/config/application/api/ApplicationPackage.java
@@ -185,17 +185,7 @@ public interface ApplicationPackage {
Optional<Reader> getDeployment();
Optional<Reader> getValidationOverrides();
- /** @deprecated do not override or call. Use the other Version class */
- @Deprecated
- default List<ComponentInfo> getComponentsInfo(com.yahoo.config.provision.Version vespaVersion) {
- return getComponentsInfo(vespaVersion.toVersion());
- }
-
- // TODO: Remove the default implementation after December 2018
- @SuppressWarnings("deprecation")
- default List<ComponentInfo> getComponentsInfo(Version vespaVersion) {
- return getComponentsInfo(com.yahoo.config.provision.Version.from(vespaVersion));
- }
+ List<ComponentInfo> getComponentsInfo(Version vespaVersion);
/**
* Reads a ranking expression from file to a string and returns it.
@@ -248,12 +238,6 @@ public interface ApplicationPackage {
throw new UnsupportedOperationException("This application package cannot validate XML");
}
- /** @deprecated do not override or call. Use the other Version class */
- @Deprecated
- default void validateXML(Optional<com.yahoo.config.provision.Version> vespaVersion) throws IOException {
- validateXMLFor(vespaVersion.map(com.yahoo.config.provision.Version::toVersion));
- }
-
default void validateXMLFor(Optional<Version> vespaVersion) throws IOException {
throw new UnsupportedOperationException("This application package cannot validate XML");
}
@@ -267,15 +251,6 @@ public interface ApplicationPackage {
return Optional.empty();
}
- /** @deprecated do not override or call. Use getFileRegistries */
- @Deprecated
- default Map<com.yahoo.config.provision.Version, FileRegistry> getFileRegistryMap() {
- return getFileRegistries().entrySet()
- .stream()
- .collect(Collectors.toMap(e -> com.yahoo.config.provision.Version.from(e.getKey()),
- e -> e.getValue()));
- }
-
default Map<Version, FileRegistry> getFileRegistries() {
return Collections.emptyMap();
}
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelFactory.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelFactory.java
index 23782162725..0c4e5087d62 100644
--- a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelFactory.java
+++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelFactory.java
@@ -13,14 +13,7 @@ public interface ModelFactory {
*
* @return the version of a {@link Model} instance that this factory can create.
*/
- @SuppressWarnings("deprecation")
- default Version version() { // TODO: Remove this default implementationm after December 2018
- return getVersion().toVersion();
- }
-
- /** @deprecated use and override version(). TODO: Remove this method after December 2018 */
- @Deprecated
- default com.yahoo.config.provision.Version getVersion() { return com.yahoo.config.provision.Version.from(version()); }
+ Version version();
/**
* Creates an instance of a {@link Model}. The resulting instance will be used to serve config. No model
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Version.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Version.java
deleted file mode 100644
index bd6e7d62833..00000000000
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/Version.java
+++ /dev/null
@@ -1,184 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.config.provision;
-
-/**
- * The {@link Version} class is used in providing versioned config for applications.
- *
- * A {@link Version} object has three components:
- *
- * * Major version. A non-negative integer.
- * * Minor version. A non-negative integer.
- * * Micro version. A non-negative integer.
- *
- * @author Vegard Sjonfjell
- * @since 5.39
- * Loosely based on component/Version.java
- * {@link Version} objects are immutable.
- * @deprecated use com.yahoo.component.Version
- */
-// TODO: Replace usage of this by com.yahoo.component.Version
-@Deprecated
-public final class Version implements Comparable<Version> {
-
- private final int major;
- private final int minor;
- private final int micro;
- private final String stringValue;
-
- /**
- * @see #fromIntValues
- */
- private Version(int major, int minor, int micro) {
- this.major = major;
- this.minor = minor;
- this.micro = micro;
- stringValue = toSerializedForm();
- verify();
- }
-
- /**
- * @see #fromString
- */
- private Version(String versionString) {
- try {
- String[] components = versionString.split("\\.", 3);
- assert (components.length == 3);
- major = Integer.parseInt(components[0]);
- minor = Integer.parseInt(components[1]);
- micro = Integer.parseInt(components[2]);
- stringValue = toSerializedForm();
- verify();
- } catch (AssertionError | ArrayIndexOutOfBoundsException | IllegalArgumentException e) {
- throw new IllegalArgumentException(String.format("Invalid version specification: \"%s\": %s", versionString, e.getMessage()));
- }
- }
-
- public com.yahoo.component.Version toVersion() {
- return new com.yahoo.component.Version(major, minor, micro);
- }
-
- /**
- * Verifies that the numerical components in a version are legal.
- * Must be called on construction after the component values are set
- *
- * @throws IllegalArgumentException if one of the numerical components are negative.
- */
- private void verify() {
- if (major < 0)
- throw new IllegalArgumentException("Negative major value");
- if (minor < 0)
- throw new IllegalArgumentException("Negative minor value");
- if (micro < 0)
- throw new IllegalArgumentException("Negative micro value");
- }
-
- public String toSerializedForm() {
- return String.format("%d.%d.%d", major, minor, micro);
- }
-
- /**
- * Creates a {@link Version} object from the specified components.
- *
- * @param major major component of the version identifier.
- * @param minor minor component of the version identifier.
- * @param micro micro component of the version identifier.
- * @throws IllegalArgumentException if one of the numerical components are negative.
- * @return {@link Version} identifier object constructed from integer components.
- */
- public static Version fromIntValues(int major, int minor, int micro) {
- return new Version(major, minor, micro);
- }
-
- /**
- * Creates a version object from the specified string. Version strings are in the format major.minor.micro
- *
- * @param versionString String representation of the version.
- * @throws IllegalArgumentException If version string is improperly formatted.
- * @return {@link Version} object constructed from string representation.
- */
- public static Version fromString(String versionString) {
- return new Version(versionString);
- }
-
- public static Version from(com.yahoo.component.Version version) {
- return new Version(version.getMajor(), version.getMinor(), version.getMicro());
- }
-
- /**
- * Returns a string representation of this version identifier, encoded as major.minor.micro
- */
- public String toString() { return stringValue; }
-
- /**
- * Returns major version component
- */
- public int getMajor() { return major; }
-
- /**
- * Returns minor version component
- */
- public int getMinor() { return minor; }
-
- /**
- * Returns micro version component
- */
- public int getMicro() { return micro; }
-
- @Override
- public int hashCode() { return stringValue.hashCode(); }
-
- /**
- * Performs an equality test between this {@link Version} object and another.
- *
- * A version is considered to be equal to another version if the
- * major, minor and micro components are equal.
- *
- * @param object The {@link Version} object to be compared to this version.
- * @return <code>true</code> if object is a
- * {@link Version} and is equal to this object;
- * <code>false</code> otherwise.
- */
- @Override
- public boolean equals(Object object) {
- if (object == null || object.getClass() != this.getClass()) {
- return false;
- }
-
- Version other = (Version)object;
- return this.major == other.major && this.minor == other.minor && this.micro == other.micro;
- }
-
- /**
- * Compares this {@link Version} object to another.
- *
- * A version is considered to be less than another version if its
- * major component is less than the other version's major component, or the
- * major components are equal and its minor component is less than the other
- * version's minor component, or the major and minor components are equal
- * and its micro component is less than the other version's micro component.
- *
- * A version is considered to be equal to another version if the
- * major, minor and micro components are equal.
- *
- * @param other the {@link Version} object to be compared to this version.
- * @return A negative integer, zero, or a positive integer if this object is
- * less than, equal to, or greater than the specified {@link Version} object.
- * @throws ClassCastException if the specified object is not a {@link Version}.
- */
- @Override
- public int compareTo(Version other) {
- if (this == other) return 0;
-
- int comparison = Integer.compare(getMajor(), other.getMajor());
- if (comparison != 0) {
- return comparison;
- }
-
- comparison = Integer.compare(getMinor(), other.getMinor());
- if (comparison != 0) {
- return comparison;
- }
-
- return Integer.compare(getMicro(), other.getMicro());
- }
-}
diff --git a/config-provisioning/src/test/java/com/yahoo/config/provision/VersionTest.java b/config-provisioning/src/test/java/com/yahoo/config/provision/VersionTest.java
deleted file mode 100644
index e5d9cb2c8c9..00000000000
--- a/config-provisioning/src/test/java/com/yahoo/config/provision/VersionTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.config.provision;
-
-import com.yahoo.test.TotalOrderTester;
-import org.junit.Test;
-import static org.junit.Assert.assertThat;
-import static org.hamcrest.Matchers.*;
-import com.google.common.testing.EqualsTester;
-
-/**
- * @author Vegard Sjonfjell
- * @since 5.39
- */
-public class VersionTest {
- @Test
- public void testConstructFromIntegers() {
- Version exampleVersion = Version.fromIntValues(3, 2, 1);
- assertThat(exampleVersion.getMajor(), is(3));
- assertThat(exampleVersion.getMinor(), is(2));
- assertThat(exampleVersion.getMicro(), is(1));
- }
-
- @Test (expected = IllegalArgumentException.class)
- public void testConstructFromIntegersNegativesShouldFail() throws IllegalArgumentException {
- Version.fromIntValues(2, -1, 1);
- }
-
- @Test (expected = IllegalArgumentException.class)
- public void testConstructFromStringTooLongVersionStringShouldFail() throws IllegalArgumentException {
- Version.fromString("3.2.1.4");
- }
-
- @Test (expected = IllegalArgumentException.class)
- public void testConstructFromStringTooShortVersionStringShouldFail() throws IllegalArgumentException {
- Version.fromString("3.2");
- }
-
- @Test (expected = IllegalArgumentException.class)
- public void testConstructFromStringInvalidVersionStringShouldFail() throws IllegalArgumentException {
- Version.fromString("4.34.3a");
- }
-
- @Test
- public void testEncodeToStringRepresentation() {
- assertThat(Version.fromIntValues(3, 2, 1).toSerializedForm(), is("3.2.1"));
- assertThat(Version.fromIntValues(0, 0, 0).toSerializedForm(), is("0.0.0"));
- }
-
- @Test
- public void testEqualityAndHashCode() {
- new EqualsTester()
- .addEqualityGroup(Version.fromIntValues(3, 2, 1), Version.fromIntValues(3, 2, 1))
- .addEqualityGroup(Version.fromIntValues(1, 2, 3), Version.fromString("1.2.3"))
- .addEqualityGroup(Version.fromString("1.5.1"))
- .addEqualityGroup(Version.fromIntValues(1, 2, 1))
- .addEqualityGroup(Version.fromString("0.0.0"))
- .testEquals();
- }
-
- @Test
- public void testCompareTo() {
- new TotalOrderTester<Version>()
- .theseObjects(Version.fromIntValues(1, 1, 1), Version.fromIntValues(1, 1, 1))
- .areLessThan(Version.fromIntValues(2, 1, 1))
- .areLessThan(Version.fromIntValues(2, 2, 1))
- .areLessThan(Version.fromIntValues(2, 2, 2))
- .areLessThan(Version.fromIntValues(3, 0, 0))
- .testOrdering();
- }
-}