eu.toop.connector.api.dsd.DSDParticipantIDProviderConstant Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tc-api Show documentation
Show all versions of tc-api Show documentation
Contains the TOOP Connector shared API
/**
* Copyright (C) 2018-2020 toop.eu
*
* 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 eu.toop.connector.api.dsd;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.helger.commons.ValueEnforcer;
import com.helger.commons.annotation.ReturnsMutableCopy;
import com.helger.commons.collection.impl.CommonsLinkedHashSet;
import com.helger.commons.collection.impl.ICommonsOrderedSet;
import com.helger.commons.string.ToStringGenerator;
import com.helger.peppolid.IDocumentTypeIdentifier;
import com.helger.peppolid.IParticipantIdentifier;
import eu.toop.connector.api.error.ITCErrorHandler;
/**
* This class implements the {@link IDSDParticipantIDProvider} interface using a
* constant set of participant identifiers. This implementation is meant for
* testing purposes only. Don't use in production.
*
* @author Philip Helger
*/
public class DSDParticipantIDProviderConstant implements IDSDParticipantIDProvider
{
private final ICommonsOrderedSet m_aSet = new CommonsLinkedHashSet <> ();
/**
* Constructor to return an empty participant identifier set.
*/
public DSDParticipantIDProviderConstant ()
{}
/**
* Constructor with a single participant ID.
*
* @param aPI
* The participant ID to return. May not be null
.
*/
public DSDParticipantIDProviderConstant (@Nonnull final IParticipantIdentifier aPI)
{
ValueEnforcer.notNull (aPI, "ParticipantID");
m_aSet.add (aPI);
}
/**
* Constructor with a collection of participant IDs
*
* @param aPIs
* The participant IDs to be returned. May not be null
and
* may not contain null
values.
*/
public DSDParticipantIDProviderConstant (@Nonnull final Iterable extends IParticipantIdentifier> aPIs)
{
ValueEnforcer.notNullNoNullValue (aPIs, "ParticipantIDs");
m_aSet.addAll (aPIs);
}
/**
* Constructor with an array of participant IDs
*
* @param aPIs
* The participant IDs to be returned. May not be null
and
* may not contain null
values.
*/
public DSDParticipantIDProviderConstant (@Nonnull final IParticipantIdentifier... aPIs)
{
ValueEnforcer.notNullNoNullValue (aPIs, "ParticipantIDs");
m_aSet.addAll (aPIs);
}
@Nonnull
@ReturnsMutableCopy
public ICommonsOrderedSet getAllParticipantIDs (@Nonnull final String sLogPrefix,
@Nonnull final String sDatasetType,
@Nullable final String sCountryCode,
@Nonnull final IDocumentTypeIdentifier aDocumentTypeID,
@Nonnull final ITCErrorHandler aErrorHandler)
{
return m_aSet.getClone ();
}
@Override
public String toString ()
{
return new ToStringGenerator (this).append ("ParticipantIDs", m_aSet).getToString ();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy