package com.capgemini.framework.teamcenter.policies;

import lombok.Getter;

/**
 * Simple storage class to represent a policy.<br>
 * Contains:
 * <ul>
 * <li>A policy IDENTIFIER (to tell Teamcenter which file to load)</li>
 * <li>A file PATH to a policy file for the xmlDomParser</li>
 * </ul>
 */
public final class PolicyLocation {

    /** The identifier of the policy as it exists on the TC servers. */
    @Getter
    private final String identifier;
    /** The file path to the policy within the "src/main/resources" folder. */
    @Getter
    private final String location;

    /**
     * Makes a policyLocation object.
     * 
     * @param identifier the Id of the policy as it exists on the TC servers
     * @param location the file path to the policy within the "src/main/resources" folder
     * @return the PolicyLocation created.
     */
    public static PolicyLocation make(final String identifier, final String location) {
        return new PolicyLocation(identifier, location);
    }

    private PolicyLocation(final String identifier, final String location) {
        this.identifier = identifier == null ? "" : identifier;
        this.location = location == null ? "" : location;
    }

    @Override
    public boolean equals(final Object obj) {
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        PolicyLocation other = (PolicyLocation) obj;
        return identifier.equals(other.identifier) && location.equals(other.location);
    }

    @Override
    public int hashCode() {
        return identifier.hashCode() ^ location.hashCode();

    }

}
