Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dom refactoring #15

Merged
merged 3 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,126 +12,98 @@
*
* @author Sergey Evdokimov
*/
public class DependencyConflictId
{
private final String groupId;
private final String artifactId;
private final String type;
private final String classifier;

public DependencyConflictId(@Nonnull String groupId, @Nonnull String artifactId, @Nullable String type, @Nullable String classifier)
{
this.groupId = groupId;
this.artifactId = artifactId;
this.type = StringUtil.isEmpty(type) ? "jar" : type;
this.classifier = classifier;
}

@Nullable
public static DependencyConflictId create(@Nonnull MavenDomDependency dep)
{
String groupId = dep.getGroupId().getStringValue();
if(StringUtil.isEmpty(groupId))
{
return null;
}

String artifactId = dep.getArtifactId().getStringValue();
if(StringUtil.isEmpty(artifactId))
{
return null;
}

//noinspection ConstantConditions
return new DependencyConflictId(groupId, artifactId, dep.getType().getStringValue(), dep.getClassifier().getStringValue());
}

@Nullable
public static DependencyConflictId create(@Nonnull MavenArtifact dep)
{
return create(dep.getGroupId(), dep.getArtifactId(), dep.getType(), dep.getClassifier());
}

@Nullable
public static DependencyConflictId create(String groupId, String artifactId, String type, String classifier)
{
if(StringUtil.isEmpty(groupId))
{
return null;
}
if(StringUtil.isEmpty(artifactId))
{
return null;
}

return new DependencyConflictId(groupId, artifactId, type, classifier);
}

@Nonnull
public String getGroupId()
{
return groupId;
}

@Nonnull
public String getArtifactId()
{
return artifactId;
}

@Nonnull
public String getType()
{
return type;
}

@Nullable
public String getClassifier()
{
return classifier;
}

@Override
public boolean equals(Object o)
{
if(this == o)
{
return true;
}
if(!(o instanceof DependencyConflictId))
{
return false;
}

DependencyConflictId id = (DependencyConflictId) o;

if(!artifactId.equals(id.artifactId))
{
return false;
}
if(classifier != null ? !classifier.equals(id.classifier) : id.classifier != null)
{
return false;
}
if(!groupId.equals(id.groupId))
{
return false;
}
if(!type.equals(id.type))
{
return false;
}

return true;
}

@Override
public int hashCode()
{
int result = groupId.hashCode();
result = 31 * result + artifactId.hashCode();
result = 31 * result + type.hashCode();
result = 31 * result + (classifier != null ? classifier.hashCode() : 0);
return result;
}
public class DependencyConflictId {
private final String groupId;
private final String artifactId;
private final String type;
private final String classifier;

public DependencyConflictId(@Nonnull String groupId, @Nonnull String artifactId, @Nullable String type, @Nullable String classifier) {
this.groupId = groupId;
this.artifactId = artifactId;
this.type = StringUtil.isEmpty(type) ? "jar" : type;
this.classifier = classifier;
}

@Nullable
public static DependencyConflictId create(@Nonnull MavenDomDependency dep) {
String groupId = dep.getGroupId().getStringValue();
if (StringUtil.isEmpty(groupId)) {
return null;
}

String artifactId = dep.getArtifactId().getStringValue();
if (StringUtil.isEmpty(artifactId)) {
return null;
}

//noinspection ConstantConditions
return new DependencyConflictId(groupId, artifactId, dep.getType().getStringValue(), dep.getClassifier().getStringValue());
}

@Nullable
public static DependencyConflictId create(@Nonnull MavenArtifact dep) {
return create(dep.getGroupId(), dep.getArtifactId(), dep.getType(), dep.getClassifier());
}

@Nullable
public static DependencyConflictId create(String groupId, String artifactId, String type, String classifier) {
if (StringUtil.isEmpty(groupId)) {
return null;
}
if (StringUtil.isEmpty(artifactId)) {
return null;
}

return new DependencyConflictId(groupId, artifactId, type, classifier);
}

@Nonnull
public String getGroupId() {
return groupId;
}

@Nonnull
public String getArtifactId() {
return artifactId;
}

@Nonnull
public String getType() {
return type;
}

@Nullable
public String getClassifier() {
return classifier;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof DependencyConflictId)) {
return false;
}

DependencyConflictId id = (DependencyConflictId)o;

if (!artifactId.equals(id.artifactId)) {
return false;
}
if (classifier != null ? !classifier.equals(id.classifier) : id.classifier != null) {
return false;
}
return groupId.equals(id.groupId) && type.equals(id.type);
}

@Override
public int hashCode() {
int result = groupId.hashCode();
result = 31 * result + artifactId.hashCode();
result = 31 * result + type.hashCode();
result = 31 * result + (classifier != null ? classifier.hashCode() : 0);
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,42 @@
*/
package org.jetbrains.idea.maven.dom;

import consulo.annotation.DeprecationInfo;
import consulo.annotation.internal.MigratedExtensionsTo;
import consulo.application.CommonBundle;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.PropertyKey;
import org.jetbrains.idea.maven.localize.MavenDomLocalize;

import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
import java.util.ResourceBundle;

@Deprecated
@DeprecationInfo("Use MavenDomLocalize")
@MigratedExtensionsTo(MavenDomLocalize.class)
public class MavenDomBundle {
private static Reference<ResourceBundle> ourBundle;
private static Reference<ResourceBundle> ourBundle;

@NonNls
private static final String BUNDLE = "MavenDomBundle";
@NonNls
private static final String BUNDLE = "MavenDomBundle";

private MavenDomBundle() {
}
private MavenDomBundle() {
}

public static String message(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) {
return CommonBundle.message(getBundle(), key, params);
}
public static String message(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) {
return CommonBundle.message(getBundle(), key, params);
}

private static ResourceBundle getBundle() {
ResourceBundle bundle = null;
if (ourBundle != null) bundle = ourBundle.get();
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference<ResourceBundle>(bundle);
private static ResourceBundle getBundle() {
ResourceBundle bundle = null;
if (ourBundle != null) {
bundle = ourBundle.get();
}
if (bundle == null) {
bundle = ResourceBundle.getBundle(BUNDLE);
ourBundle = new SoftReference<>(bundle);
}
return bundle;
}
return bundle;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@
import consulo.xml.util.xml.NameStrategy;

@NameStrategy(JavaNameStrategy.class)
public interface MavenDomElement extends DomElement
{
public interface MavenDomElement extends DomElement {
}
Loading
Loading