// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.common.plugin;

import java.util.Objects;
import javax.annotation.Nullable;
import javax.annotation.Nonnull;

public class PluginIdentifier
{
    @Nonnull
    private final String group;
    @Nonnull
    private final String name;
    
    public PluginIdentifier(@Nonnull final String group, @Nonnull final String name) {
        this.group = group;
        this.name = name;
    }
    
    public PluginIdentifier(@Nonnull final PluginManifest manifest) {
        this(manifest.getGroup(), manifest.getName());
    }
    
    @Nonnull
    public String getGroup() {
        return this.group;
    }
    
    @Nonnull
    public String getName() {
        return this.name;
    }
    
    @Override
    public int hashCode() {
        int result = this.group.hashCode();
        result = 31 * result + this.name.hashCode();
        return result;
    }
    
    @Override
    public boolean equals(@Nullable final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || this.getClass() != o.getClass()) {
            return false;
        }
        final PluginIdentifier that = (PluginIdentifier)o;
        return Objects.equals(this.group, that.group) && Objects.equals(this.name, that.name);
    }
    
    @Nonnull
    @Override
    public String toString() {
        return this.group + ":" + this.name;
    }
    
    @Nonnull
    public static PluginIdentifier fromString(@Nonnull final String str) {
        final String[] split = str.split(":");
        if (split.length != 2) {
            throw new IllegalArgumentException("String does not match <group>:<name>");
        }
        return new PluginIdentifier(split[0], split[1]);
    }
}
