at.austriapro.ebinterface.ubl.from.helper.SchemedID Maven / Gradle / Ivy
/*
* Copyright (c) 2010-2015 Bundesrechenzentrum GmbH - www.brz.gv.at
* Copyright (c) 2015-2024 AUSTRIAPRO - www.austriapro.at
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package at.austriapro.ebinterface.ubl.from.helper;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import com.helger.commons.ValueEnforcer;
import com.helger.commons.annotation.Nonempty;
import com.helger.commons.equals.EqualsHelper;
import com.helger.commons.hashcode.HashCodeGenerator;
import com.helger.commons.string.ToStringGenerator;
/**
* Represents a generic ID consisting of schemeID and the main ID value.
*
* @author philip
*/
@Immutable
public final class SchemedID
{
private final String m_sSchemeID;
private final String m_sID;
public SchemedID (@Nullable final String sSchemeID, @Nonnull @Nonempty final String sID)
{
m_sSchemeID = sSchemeID;
m_sID = ValueEnforcer.notEmpty (sID, "ID");
}
@Nullable
public String getSchemeID ()
{
return m_sSchemeID;
}
@Nonnull
@Nonempty
public String getID ()
{
return m_sID;
}
@Override
public boolean equals (final Object o)
{
if (o == this)
return true;
if (o == null || !getClass ().equals (o.getClass ()))
return false;
final SchemedID rhs = (SchemedID) o;
return EqualsHelper.equals (m_sSchemeID, rhs.m_sSchemeID) && m_sID.equals (rhs.m_sID);
}
@Override
public int hashCode ()
{
return new HashCodeGenerator (this).append (m_sSchemeID).append (m_sID).getHashCode ();
}
@Override
public String toString ()
{
return new ToStringGenerator (this).appendIfNotNull ("schemeID", m_sSchemeID).append ("ID", m_sID).getToString ();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy