Cleanup (missing annotations; formatting)

GitOrigin-RevId: 54745a667f128cd1d639da8e2e8db581ccb68b2d
This commit is contained in:
Roman Shevchenko
2020-10-27 13:19:02 +00:00
committed by intellij-monorepo-bot
parent 23340e1e51
commit b1e8b301ee
4 changed files with 49 additions and 92 deletions
@@ -19,7 +19,7 @@ public final class BuildNumber implements Comparable<BuildNumber> {
public static final int SNAPSHOT_VALUE = Integer.MAX_VALUE;
@NotNull private final String myProductCode;
private final @NotNull String myProductCode;
private final int @NotNull [] myComponents;
public BuildNumber(@NotNull String productCode, int baselineVersion, int buildNumber) {
@@ -35,8 +35,7 @@ public final class BuildNumber implements Comparable<BuildNumber> {
return "__BUILD_NUMBER__".equals(value) || "__BUILD__".equals(value);
}
@NotNull
public String getProductCode() {
public @NotNull String getProductCode() {
return myProductCode;
}
@@ -57,31 +56,24 @@ public final class BuildNumber implements Comparable<BuildNumber> {
return false;
}
@NotNull
@Contract(pure = true)
public BuildNumber withoutProductCode() {
public @NotNull BuildNumber withoutProductCode() {
return myProductCode.isEmpty() ? this : new BuildNumber("", myComponents);
}
@NotNull
@NlsSafe
public String asString() {
public @NotNull @NlsSafe String asString() {
return asString(true, true);
}
@NotNull
@NlsSafe
public String asStringWithoutProductCode() {
public @NotNull @NlsSafe String asStringWithoutProductCode() {
return asString(false, true);
}
@NotNull
public String asStringWithoutProductCodeAndSnapshot() {
public @NotNull String asStringWithoutProductCodeAndSnapshot() {
return asString(false, false);
}
@NotNull
private String asString(boolean includeProductCode, boolean withSnapshotMarker) {
private @NotNull String asString(boolean includeProductCode, boolean withSnapshotMarker) {
StringBuilder builder = new StringBuilder();
if (includeProductCode && !myProductCode.isEmpty()) {
@@ -107,19 +99,17 @@ public final class BuildNumber implements Comparable<BuildNumber> {
* Attempts to parse build number from the specified string.
* Returns {@code null} if the string is not a valid build number.
*/
@Nullable
public static BuildNumber fromStringOrNull(@NotNull @NonNls String version) {
public static @Nullable BuildNumber fromStringOrNull(@NotNull @NonNls String version) {
try {
return fromString(version);
} catch (RuntimeException ignored) {
}
catch (RuntimeException ignored) {
return null;
}
}
public static @Nullable BuildNumber fromString(@Nullable @NonNls String version) {
if (version == null) {
return null;
}
if (version == null) return null;
version = version.trim();
return version.isEmpty() ? null : fromString(version, null, null);
}
@@ -292,8 +282,7 @@ public final class BuildNumber implements Comparable<BuildNumber> {
* This method is for internal platform use only. In regular code use {@link com.intellij.openapi.application.ApplicationInfo#getBuild()} instead.
*/
@ApiStatus.Internal
@NotNull
public static BuildNumber currentVersion() {
public static @NotNull BuildNumber currentVersion() {
return Holder.CURRENT_VERSION;
}
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util;
import com.intellij.openapi.util.text.StringUtil;
@@ -10,27 +10,23 @@ import java.util.Map;
public final class LocalFileUrl implements Url {
private final String path;
/**
* Use {@link Urls#newLocalFileUrl(String)} instead
*/
/** Use {@link Urls#newLocalFileUrl(String)} instead */
public LocalFileUrl(@NotNull String path) {
this.path = path;
}
@Override
public Url resolve(@NotNull String subPath) {
public @NotNull Url resolve(@NotNull String subPath) {
return new LocalFileUrl(path.isEmpty() ? subPath : (path + "/" + subPath));
}
@NotNull
@Override
public Url addParameters(@NotNull Map<String, String> parameters) {
public @NotNull Url addParameters(@NotNull Map<String, String> parameters) {
throw new UnsupportedOperationException("File URL doesn't support parameters");
}
@NotNull
@Override
public String getPath() {
public @NotNull String getPath() {
return path;
}
@@ -44,33 +40,28 @@ public final class LocalFileUrl implements Url {
return path;
}
@NotNull
@Override
public String toExternalForm() {
public @NotNull String toExternalForm() {
return path;
}
@Nullable
@Override
public String getScheme() {
public @Nullable String getScheme() {
return null;
}
@Nullable
@Override
public String getAuthority() {
public @Nullable String getAuthority() {
return null;
}
@Nullable
@Override
public String getParameters() {
public @Nullable String getParameters() {
return null;
}
@NotNull
@Override
public Url trimParameters() {
public @NotNull Url trimParameters() {
return this;
}
@@ -103,4 +94,4 @@ public final class LocalFileUrl implements Url {
public int hashCodeCaseInsensitive() {
return StringUtil.stringHashCodeInsensitive(path);
}
}
}
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util;
import com.intellij.openapi.util.NlsSafe;
@@ -15,40 +15,34 @@ public interface Url {
/**
* System-independent path
*/
@NotNull
String getPath();
@NotNull String getPath();
@Contract(pure = true)
boolean isInLocalFileSystem();
@NlsSafe String toDecodedForm();
@NotNull
String toExternalForm();
@NotNull String toExternalForm();
@Nullable
String getScheme();
@Nullable String getScheme();
@Nullable
String getAuthority();
@Nullable String getAuthority();
@Nullable
String getParameters();
@Nullable String getParameters();
boolean equalsIgnoreParameters(@Nullable Url url);
boolean equalsIgnoreCase(@Nullable Url url);
@NotNull
Url trimParameters();
@NotNull Url trimParameters();
int hashCodeCaseInsensitive();
Url resolve(@NotNull String subPath);
@NotNull Url resolve(@NotNull String subPath);
/**
* Creates a new url with added parameters.
*/
@NotNull
Url addParameters(@NotNull Map<String, String> parameters);
@Contract(pure = true)
@NotNull Url addParameters(@NotNull Map<String, String> parameters);
}
@@ -1,4 +1,4 @@
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util;
import com.intellij.openapi.util.text.StringUtil;
@@ -20,9 +20,7 @@ public final class UrlImpl implements Url {
private String externalForm;
private UrlImpl withoutParameters;
/**
* @deprecated Use {@link Urls#newUnparsable(String)}
*/
/** @deprecated Use {@link Urls#newUnparsable(String)} */
@Deprecated
public UrlImpl(@NotNull String path) {
this(null, null, path, null);
@@ -40,13 +38,12 @@ public final class UrlImpl implements Url {
}
@Override
public Url resolve(@NotNull String subPath) {
public @NotNull Url resolve(@NotNull String subPath) {
return new UrlImpl(scheme, authority, path.isEmpty() ? subPath : (path + "/" + subPath), parameters);
}
@NotNull
@Override
public Url addParameters(@NotNull Map<String, String> parameters) {
public @NotNull Url addParameters(@NotNull Map<String, String> parameters) {
if (parameters.isEmpty()) {
return this;
}
@@ -63,24 +60,21 @@ public final class UrlImpl implements Url {
return new UrlImpl(scheme, authority, path, builder.toString());
}
@NotNull
@Override
public String getPath() {
public @NotNull String getPath() {
if (decodedPath == null) {
decodedPath = URLUtil.unescapePercentSequences(path);
}
return decodedPath;
}
@Nullable
@Override
public String getScheme() {
public @Nullable String getScheme() {
return scheme;
}
@Override
@Nullable
public String getAuthority() {
public @Nullable String getAuthority() {
return authority;
}
@@ -89,9 +83,8 @@ public final class UrlImpl implements Url {
return URLUtil.FILE_PROTOCOL.equals(scheme);
}
@Nullable
@Override
public String getParameters() {
public @Nullable String getParameters() {
return parameters;
}
@@ -119,8 +112,7 @@ public final class UrlImpl implements Url {
}
@Override
@NotNull
public String toExternalForm() {
public @NotNull String toExternalForm() {
if (externalForm != null) {
return externalForm;
}
@@ -142,8 +134,7 @@ public final class UrlImpl implements Url {
}
@Override
@NotNull
public Url trimParameters() {
public @NotNull Url trimParameters() {
if (parameters == null) {
return this;
}
@@ -160,12 +151,8 @@ public final class UrlImpl implements Url {
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof UrlImpl)) {
return false;
}
if (this == o) return true;
if (!(o instanceof UrlImpl)) return false;
UrlImpl url = (UrlImpl)o;
return StringUtil.equals(scheme, url.scheme) && StringUtil.equals(authority, url.authority) && getPath().equals(url.getPath()) && StringUtil.equals(parameters, url.parameters);
@@ -173,12 +160,8 @@ public final class UrlImpl implements Url {
@Override
public boolean equalsIgnoreCase(@Nullable Url o) {
if (this == o) {
return true;
}
if (!(o instanceof UrlImpl)) {
return false;
}
if (this == o) return true;
if (!(o instanceof UrlImpl)) return false;
UrlImpl url = (UrlImpl)o;
return StringUtil.equalsIgnoreCase(scheme, url.scheme) &&
@@ -213,4 +196,4 @@ public final class UrlImpl implements Url {
public int hashCodeCaseInsensitive() {
return computeHashCode(false);
}
}
}