// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.api;

import java.util.Objects;

/**
 * @author bjorncs
 */
public class AthenzService implements AthenzIdentity {

    private final AthenzDomain domain;
    private final String serviceName;

    public AthenzService(AthenzDomain domain, String serviceName) {
        this.domain = domain;
        this.serviceName = serviceName;
    }

    public AthenzService(String domain, String serviceName) {
        this(new AthenzDomain(domain), serviceName);
    }


    @Override
    public AthenzDomain getDomain() {
        return domain;
    }

    @Override
    public String getName() {
        return serviceName;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AthenzService that = (AthenzService) o;
        return Objects.equals(domain, that.domain) &&
                Objects.equals(serviceName, that.serviceName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(domain, serviceName);
    }

    @Override
    public String toString() {
        return String.format("AthenzService(%s)", getFullName());
    }
}

@@ -149,16 +149,71 @@
 z.api;%0A%0A
+import com.yahoo.vespa.athenz.utils.AthenzIdentities;%0A%0A
 import j
@@ -659,16 +659,450 @@
 %0A    %7D%0A%0A
+    public AthenzService(String fullName) %7B%0A        AthenzIdentity identity = AthenzIdentities.from(fullName);%0A        if (!(identity instanceof AthenzService)) %7B%0A            throw new IllegalArgumentException(String.format(%22'%25s' is not an Athenz service%22, fullName));%0A        %7D%0A        AthenzService service = (AthenzService) identity;%0A        this.domain = service.getDomain();%0A        this.serviceName = service.serviceName;%0A    %7D%0A
 %0A    @Ov

Add AthenzService constructor taking full name as input